Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-extra-parens options work inconsistently #12717

Closed
yeonjuan opened this issue Dec 30, 2019 · 1 comment · Fixed by #12843
Closed

no-extra-parens options work inconsistently #12717

yeonjuan opened this issue Dec 30, 2019 · 1 comment · Fixed by #12843
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@yeonjuan
Copy link
Member

yeonjuan commented Dec 30, 2019

Tell us about your environment

  • ESLint Version: v.6.8.0
  • Node Version: v12.13.0
  • npm Version: v6.12.0

What parser (default, Babel-ESLint, etc.) are you using?

default(espree)

Please show your full configuration:

Configuration

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

  • The enforceForArrowConditionals: false option doesn't allow extra parentheses more than one pair. - demo
/* eslint no-extra-parens: ["error", "all", { "enforceForArrowConditionals": false }] */

const b = a => 1 ? 2 : 3;
const e = c => (1 ? 2 : 3);
const f = c => (((1 ? 2 : 3))); // Unnecessary parentheses expression.
const g = c => ((((1 ? 2 : 3)))); // Unnecessary parentheses expression.
  • On the other hand, the other options allow extra parentheses without limit. - demo
/* eslint no-extra-parens: ["error", "all", {
	"conditionalAssign": false,
	"nestedBinaryExpressions": false,
        "ignoreJSX": "all",
        "enforceForSequenceExpressions": false,
        "enforceForNewInMemberExpressions": false
}] */

while ((((foo = bar())))) {}

x = a || (((((b && c)))));

const baz = ((((<div/>))));

(((a, b)));
((a, b));
(a, b);

var foo = (((new Bar()))).baz;
var foo = ((new Bar())).baz;
var foo = (new Bar()).baz;

What did you expect to happen?

I think the options should work consistently.
By the docs, the option enforceForArrowConditionals: false should allow all extra parentheses without limitation in matched cases with the option.

...
"enforceForArrowConditionals": false allows extra parentheses around ternary expressions which are the body of an arrow function
...

What actually happened? Please include the actual, raw output from ESLint.

Are you willing to submit a pull request to fix this bug?

Yes. If this issue is a bug. After #12697 merged.

@yeonjuan yeonjuan added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Dec 30, 2019
@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jan 9, 2020
@kaicataldo
Copy link
Member

This seems like a bug to me. Thanks for reporting this 👍

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Aug 14, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Aug 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants