arrow-body-style autofix with 'in' in a for-loop init
See original GitHub issueTell us about your environment
- ESLint Version: 5.16.0 (same behaviour with 6.0.0-rc.0)
- Node Version: 10.16.0
- npm Version: 6.9.0
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
Configuration
module.exports = {
parserOptions: {
ecmaVersion: 6,
},
rules: {
"arrow-body-style": "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 => { return b in c; }; ;);
eslint index.js --fix
What did you expect to happen?
Not a SyntaxError in the fixed code.
What actually happened? Please include the actual, raw output from ESLint.
for (let a = b => b in c; ;);
The fix changed semantics and produced an error:
SyntaxError: for-in loop variable declaration may not have an initializer.
This is similar to #11706
Are you willing to submit a pull request to fix this bug?
Yes, when PR #11848 is finished, since it might be a similar fix.
Note
The fixed code is SyntaxError in Node/Chrome and Firefox (with a bit different message).
However, it’s a valid ForStatement for acorn, babel-eslint and other parsers (e.g. not esprima).
Check: AST Explorer
Reported acorn #838
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
@anikethsaha I’m not working on it at the moment, feel free to take this!
@mdjermanovic are you working on this? if not I would like to take this