Skip to content
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

Merged
merged 2 commits into from Jul 4, 2017

Conversation

platinumazure
Copy link
Member

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.

@eslintbot
Copy link

LGTM

@mention-bot
Copy link

@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.

@platinumazure platinumazure self-assigned this Jul 1, 2017
@platinumazure platinumazure added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly cli Relates to ESLint's command-line interface labels Jul 1, 2017
@platinumazure
Copy link
Member Author

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.

Copy link
Member

@not-an-aardvark not-an-aardvark left a 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);
Copy link
Member

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?

Copy link
Member Author

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).

@platinumazure platinumazure added the do not merge This pull request should not be merged yet label Jul 3, 2017
@platinumazure
Copy link
Member Author

Adding "do not merge" so I can make a suggested change.

@eslintbot
Copy link

LGTM

@platinumazure platinumazure removed the do not merge This pull request should not be merged yet label Jul 4, 2017
@platinumazure
Copy link
Member Author

@not-an-aardvark Updated per your suggestion, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly cli Relates to ESLint's command-line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants