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
Fix: --quiet no longer fixes warnings (fixes #8675) #8858
Conversation
LGTM |
@platinumazure, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jrajav, @not-an-aardvark and @mysticatea to be potential reviewers. |
Hmm... Possible improvement might be to expose the fix predicate as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Hmm... Possible improvement might be to expose the fix predicate as
CLIEngine.fixErrorsOnlyPredicate
or similar so CLIEngine users can easily emulate--quiet
on the CLI.
Meh, I think the fix predicate is fairly trivial, so I would mildly prefer not including that since it's simple for API users to create it on their own.
lib/cli.js
Outdated
* autofixed), false otherwise. | ||
*/ | ||
function quietFixPredicate(lintResult) { | ||
return Boolean(lintResult && lintResult.severity === 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't this be return lintResult.severity === 2
? Is lintResult
ever null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably should never be null. Normally I favor defensive coding to be safe; but since this could be a tight path (running this function on every lint message), I am happy to shave off those cycles. I'll update tonight (US).
Adding "do not merge" so I can make a suggested change. |
LGTM |
@not-an-aardvark Updated per your suggestion, thanks! |
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
See #8675.
What changes did you make? (Give an overview)
When
--quiet
is specified by user, lib/cli.js will pass a fix predicate function to CLIEngine so that only errors are fixed. That way, warnings (which aren't even reported in--quiet
mode and about which they might know nothing) are not fixed and users are thus no longer surprised by extra changes being made to ESLint.Is there anything you'd like reviewers to focus on?
Nothing in particular.