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.

Request: `no-extra-parens` option to ignore `&&`/`||`

See original GitHub issue

Although the rules for precedence of && and || are clear, using parentheses to visually group these is often very helpful to ensure programmer intentions. ie: a || (b && c) even though a || b && c is the same.

Most of the time, I don’t want extra parens - but around selection operators, I very much do. Can we add an option to this rule so it ignores &&/|| operators? (for stylistic reasons only)

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:35 (28 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Apr 6, 2016

@ilyavolodin you can just revert the revert locally rather than doing another PR

0reactions
obedm503commented, Nov 27, 2017

is there a way for eslint to also ignore extra parens in the conditional of a ternary expression, so that

// valid
const a = (b || c) ? 5 : 20;
const r = (n * 2) ? a : b;
// invalid
const a = b || c ? 5 : 20;
const r = n * 2 ? a : b;

is valid. but it should kick in when there are no binary operators

// valid
const a = b ? 5 : 20;
// invalid
const a = (b) ? 5 : 20;

if already possible, can someone point me to the correct configuration

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
no-extra-parens | typescript-eslint
This rule extends the base eslint/no-extra-parens rule. ... Note: you must disable the base rule as it can report incorrect errors "no-extra-parens": "off",...
Read more >
Need fix for EsLint error: Gratuitous parentheses around ...
Need fix for EsLint error: Gratuitous parentheses around expression-no-extra-parens · 1. Then remove the parentheses to conform to the rule? · 1.
Read more >
Available rules - eslint-plugin-vue
Rule ID Description vue/multi‑word‑component‑names require component names to be always multi‑word... vue/no‑arrow‑functions‑in‑watch disallow using arrow functions to define watcher... vue/no‑computed‑properties‑in‑data disallow accessing computed properties in data...
Read more >
List of available rules - ESLint - Pluggable JavaScript linter
The --fix option on the command line automatically fixes problems (currently mostly ... no-extra-parens ... require calls to isNaN() when checking for NaN....
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found