-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Add suggestions for no-unsafe-negation #12591
Closed
mdjermanovic opened this issue
Nov 22, 2019
· 1 comment
· Fixed by basics/vector#127, thinkwee/thinkwee.github.io#39, alxtford/numconv#46, WoTTsecurity/api#773 or WealthWizardsEngineering/instance-terminator#10
Closed
Add suggestions for no-unsafe-negation #12591
mdjermanovic opened this issue
Nov 22, 2019
· 1 comment
· Fixed by basics/vector#127, thinkwee/thinkwee.github.io#39, alxtford/numconv#46, WoTTsecurity/api#773 or WealthWizardsEngineering/instance-terminator#10
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
enhancement
This change enhances an existing feature of ESLint
rule
Relates to ESLint's core rules
Comments
mdjermanovic
added
enhancement
This change enhances an existing feature of ESLint
rule
Relates to ESLint's core rules
evaluating
The team will evaluate this issue to decide whether it meets the criteria for inclusion
labels
Nov 22, 2019
Yes! This is a great example/test case for the Suggestions feature. Let's do this! |
ilyavolodin
added
accepted
There is consensus among the team that this change meets the criteria for inclusion
and removed
evaluating
The team will evaluate this issue to decide whether it meets the criteria for inclusion
labels
Nov 23, 2019
Closed
mdjermanovic
added a commit
that referenced
this issue
Nov 27, 2019
This was referenced Jan 12, 2020
This was referenced Mar 11, 2020
This was referenced Mar 26, 2020
eslint-deprecated
bot
added
the
archived due to age
This issue has been archived; please open a new issue for any further discussion
label
Jun 19, 2020
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
enhancement
This change enhances an existing feature of ESLint
rule
Relates to ESLint's core rules
It might be useful to have some Suggestions in the core rules, as a working example for rule plugins and a ready test for editor integrations? This rule looks to me like a place where suggestions make sense and should be simple enough to implement for the start.
What rule do you want to change?
no-unsafe-negation
Does this change cause the rule to produce more or fewer warnings?
same
How will the change be implemented? (New option, new default behavior, etc.)?
new default behavior
Please provide some example code that this change will affect:
What does the rule currently do for this code?
Just an error without the autofix. The fixer was recently removed in #12157 because it was changing behavior.
What will the rule do after it's changed?
An error with two suggestions.
The first suggestion would be to negate the whole relational expression. This changes behavior, but probably from a bug to the intended one (that's how the removed fixer was working):
The second suggestion would be to make the existing intended behavior explicit, by wrapping the negation in parentheses, which is a documented exception allowed by this rule and does not produce an error after the fix:
Does this make sense?
Are you willing to submit a pull request to implement this change?
Yes.
The text was updated successfully, but these errors were encountered: