Removes parentheses in expressions with mixed operators
See original GitHub issueBefore:
const foo = (a && b) || c || d;
After:
const foo = a && b || c || d;
The same goes for arithmetic and bitwise operators.
Relevant ESLint rule: http://eslint.org/docs/rules/no-mixed-operators.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:187
- Comments:201 (72 by maintainers)
Top Results From Across the Web
prevent Prettier of removing parentheses - Stack Overflow
I'm using prettier in VSCode on a react native project and it removes parentheses in mixed operators or when declaring a var with...
Read more >no-mixed-operators - ESLint - Pluggable JavaScript Linter
Enclosing complex expressions by parentheses clarifies the developer's intention, which makes the code more readable. This rule warns when different operators ...
Read more >Remove brackets from an algebraic string containing + and
Simplify a given algebraic string of characters, '+', '-' operators and parentheses. Output the simplified string without parentheses.
Read more >Parentheses in Math Rules & Examples | What Do ... - Study.com
Parentheses are used in conjunction with the concept of the order of operations and indicate that whatever is between the parenthesis must be ......
Read more >Expressions - cppreference.com
Any expression in parentheses is also classified as a primary expression: this guarantees that the parentheses have higher precedence than any ...
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
Top Related Hashnode Post
No results found
take your time
I agree. It should be opinionated about enforcing clear logic between operators. For example, it’s just not clear, unless you remember your math classes from HS, that division happens before addition:
const result = 100 / 10 + 10; // 20
const result = 100 / (10 + 10); // 5
const result = (100 / 10) + 10; // 20
It currently enforces unclear operations, when the strong opinion should be to enforce clarity.