Rule `no-extra-parens` shouldn't error on logical operators wrapped in parens in a ternary condition
See original GitHub issue~/dev
❯ eslint --version
v2.9.0
~/dev
❯ echo "(foo || bar) ? 'error' : 'warning'" | eslint --stdin --rule='no-extra-parens:2'
<text>
1:1 error Gratuitous parentheses around expression no-extra-parens
✖ 1 problem (1 error, 0 warnings)
The ternary (foo || bar) ? 'error' : 'warning'
without the parens is ambiguous for people not knowing the precedence rules, which applies to a lot of devs. I would have expected the rule not to fail on this.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
no-extra-parens - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Add option to the `no-nested-ternary` rule that allows parens ...
Looking at the no-extra-parens documentation, I see that the "all" option has exceptions baked into it, for IIFEs and the wrap-regex rule.
Read more >Rules - JavaScript Standard Style
Wrap conditional assignments with additional parentheses. This makes it clear that the expression is intentionally an assignment ( = ) rather than a...
Read more >C static code analysis: The ternary operator should not be used
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in ... Switch statement conditions should not have essentially boolean type.
Read more >Conditional branching: if, '?' - The Modern JavaScript Tutorial
statement evaluates the expression in its parentheses and converts the result to a boolean. Let's recall the conversion rules from the chapter ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bdougherty Would you like to make a new issue with your proposal? You’d have a lot more visibility than you do here!
@eslint/eslint-team Other thoughts on this? This hasn’t seen much activity, but also didn’t get much discussion.