Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
no-extra-parens produces invalid autofix with an `in` expression in a for-loop initializer #11706
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
Please show your full configuration:
rules: 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); ;);
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.
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'.