fix(lint): fail lint:fix when unfixable errors remain#29690
fix(lint): fail lint:fix when unfixable errors remain#29690danyalahmed1995 wants to merge 1 commit into
Conversation
|
Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs). |
|
System file check failed because I changed the lint/fix.js 🫠 |
| const { files = dataFolders, only } = argv; | ||
|
|
||
| await main(files, { only }); | ||
| process.exit((await lint(files)) ? 1 : 0); |
There was a problem hiding this comment.
This is an interesting workaround that I hadn't thought about, but unfortunately it would significantly increase the time it takes to run fix:lint.
I will bring this up in tomorrow's BCD meeting.
There was a problem hiding this comment.
Yes you are right, I kept this intentionally small to match the current behavior gap, but I can see how re-running the full lint pass after lint:fix could be too expensive for regular use.
I will look for a better solution and get back to you.
There was a problem hiding this comment.
There are couple of options we can take a look at
- Keep this as-is, but accept the extra lint pass on the same target files.
- Add a strict mode such as
--fail-on-unfixed, so normallint:fixstays fast while pre-commit/CI can fail when unfixable errors remain. - Move the follow-up
lintcall only into the pre-commit path, since that is where the issue was observed. - Run only a narrower post-fix validation for unfixable checks like the
standard_track/spec_urlcase. - Do a larger linter/fixer unification so fixable and unfixable diagnostics come from one shared pass.
Let me know what you think.
Summary
Fixes
npm run lint:fixso it exits with a failure when unfixable lint errors remain after the fixer runs.Previously,
lint:fixcould successfully apply available fixes and exit0, even when a follow-upnpm run lintwould still fail on the same target files. This made the command report success for cases it could not fully fix.The fix reuses the normal lint pass after running the existing fixers and exits non-zero when lint errors remain.
Fixes #29615.
Validation
npm run lint:fix -- http/headers/X-Frame-Options.jsonnpm run lint -- http/headers/X-Frame-Options.jsonspec_urlcase from Fixer does not report "Marked as standard_track, but missing required spec_url" #29615 and confirmedlint:fixnow exits with failure when the remaining lint error is unfixable.npm run formatnpm run lintNODE_ENVshell syntax.