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 produces invalid autofix with an `in` expression in a for-loop initializer #11706

not-an-aardvark opened this issue May 10, 2019 · 2 comments


Copy link

commented May 10, 2019

Tell us about your environment

  • ESLint Version: master
  • Node Version: 12.1.0
  • npm Version: 6.9.0

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


Please show your full configuration:

  no-extra-parens: error

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

for (let a = (b in c); ;);
eslint --fix

What did you expect to happen?

I expected ESLint to not produce an error because removing the parentheses would cause a syntax error.

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

ESLint produced the following invalid autofix:

for (let a = b in c; ;);

This is interpreted as an initializer in a for-in loop, which is a syntax error in most cases (and is not the intended semantics of the code).


This issue was detected by running the fuzzer locally.

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

Yes, but not sure when I'll have time.


This comment has been minimized.

Copy link

commented Jun 12, 2019

Similar bugs, but with parentheses around parent nodes:

for (let a = (b && c in d); ;);

for (let a = (b in c && d); ;);

for (let a = (b => b in c); ;);

for (let a = (b => c => b in c); ;);

Question: Disable just autofix or the whole warning? These seem to be necessary parentheses, not 'extra'.


This comment has been minimized.

Copy link
Member Author

commented Jun 13, 2019

I suppose the whole warning should be disabled in this case -- as you said, the parentheses are necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.