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: incorrect logic for required parens in no-extra-boolean-cast fixer #13061
Conversation
case "IfStatement": | ||
case "DoWhileStatement": | ||
case "WhileStatement": | ||
case "ForStatement": |
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.
Just double checking, should ForOfStatement and ForInStatement be included here?
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.
No, this switch
is supposed to cover only possible parents for the reported node in this rule (otherwise, this function could grow to the size of no-extra-parens
rule).
It also assumes the node's role in its parent. For example, case "ConditionalExpression"
knows that it is the test
node at this point (precedence check would be different for consequent
or alternate
node).
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.
Gotcha, thanks. Can you add a comment explaining that?
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.
Added to the function's description, thanks for the suggestion!
02a1f6b
to
5944447
Compare
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!
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. Thank you!
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[X] Bug fix
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue.
Online Demo Link (v6.8.0)
What did you expect to happen?
Autofix:
What actually happened? Please include the actual, raw output from ESLint.
Autofix:
What changes did you make? (Give an overview)
Fixed the precedence check for required parens in the
no-extra-boolean-cast
fixer.This would also avoid often unnecessary parens, e.g.:
used to be auto-fixed to:
Is there anything you'd like reviewers to focus on?