question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removes parentheses in expressions with mixed operators

See original GitHub issue

Before:

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:open
  • Created 7 years ago
  • Reactions:187
  • Comments:201 (72 by maintainers)

github_iconTop GitHub Comments

148reactions
przhkvcommented, Jun 21, 2017
1 + 2 * 3 % 6 + 1

take your time

106reactions
alanimgurcommented, Jan 15, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found