Invalid parens around ternary expressions
See original GitHub issueTry this code with width 34, 35, 36. At 35 prettier will add one extra bracket.
Input:
const foo = {
bar: props.bar ? props.bar : noop,
baz: props.baz
}
Output:
// At 34: good
const foo = {
bar: (
props.bar ? props.bar : noop
),
baz: props.baz
};
// At 35: bad
const foo = {
bar: props.bar ? props.bar : noop
),
baz: props.baz
};
// At 36: good
const foo = {
bar: props.bar ? props.bar : noop,
baz: props.baz
};
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Should parenthesis always be placed around the ternary ...
Parentheses are not required around ternary (also known as conditional) operators or its sections, because their precedence is so very low in ...
Read more >Prettier removes parentheses around conditional in ternary ...
Adding parens around every ternary condition would cause a lot of churn. Are we sure we want to do that?
Read more >no-extra-parens - ESLint - Pluggable JavaScript Linter
This rule restricts the use of parentheses to only where they are necessary. Rule Details. This rule always ignores extra parentheses around the...
Read more >void operator - JavaScript - MDN Web Docs
This operator allows evaluating expressions that produce a value into places where an expression that evaluates to undefined is desired.
Read more >Ternary conditional operator - Wikipedia
In computer programming, the ternary conditional operator is a ternary operator that is part of the syntax for basic conditional expressions in several ......
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 Free
Top 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
@umidbekkarimov hopefully you don’t find more 😃 If you do, we’ll fix them quickly!
@umidbekkarimov thanks for the great bug report and sorry I got confused! #502 is a fix for it 😃