Skip to content

feat: Add htmlhint --init command #1630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 6, 2025
Merged

Conversation

coliff
Copy link
Member

@coliff coliff commented Jun 6, 2025

TODO:

  • Add docs

This creates a new config (if one doesn't already exist)
@coliff coliff requested a review from thedaviddias as a code owner June 6, 2025 03:07
@coliff coliff added the cli Relates to HTMLHint's command-line interface label Jun 6, 2025
@github-actions github-actions bot added the test label Jun 6, 2025
gemini-code-assist[bot]

This comment was marked as resolved.

const defaultConfig = JSON.stringify(HTMLHint.defaultRuleset, null, 2)

try {
writeFileSync(configPath, defaultConfig, 'utf-8')

Check failure

Code scanning / CodeQL

Potential file system race condition High

The file may have changed since it
was checked
.
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (95e6a13) to head (35421cd).
Report is 55 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main     #1630      +/-   ##
===========================================
+ Coverage   96.99%   100.00%   +3.00%     
===========================================
  Files           2         1       -1     
  Lines        1628         1    -1627     
  Branches      335         0     -335     
===========================================
- Hits         1579         1    -1578     
+ Misses         49         0      -49     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c13ef9...35421cd. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

coliff added 2 commits June 6, 2025 12:19
…t practices

Updated behavior:
Exit code 0 (success):
✅ Config file created successfully
✅ Config file already exists (no action needed, but not an error)
Exit code 1 (failure):
❌ File creation failed due to write permissions, disk space, etc.
Why this is better:
Follows CLI conventions: Failed operations should exit with non-zero codes
Better for scripting: Scripts can check $? or $LASTEXITCODE to handle errors
More user-friendly: Existing file is treated as success, not failure
Proper error handling: Real write errors are properly reported
Updated tests:
✅ All tests pass
✅ Tests verify correct exit codes for each scenario
✅ Tests handle platform differences (Windows vs Unix)
This change makes the --init command much more robust and follows standard CLI best practices.
@coliff coliff merged commit 5a7e6e2 into main Jun 6, 2025
16 of 17 checks passed
@coliff coliff deleted the dev/coliff/add-htmlhint-init branch June 6, 2025 03:29
@coliff coliff added this to the v.1.5.0 milestone Jun 6, 2025
@coliff coliff mentioned this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Relates to HTMLHint's command-line interface test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant