-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
arrow-body-style autofix with "in" in a for-loop init #11849
Comments
in
in a for-loop init
Thank you for your report. I confirmed it. I prefer that the rule fixes that code along with wrapping by parentheses. In the spec,
Therefore, |
By the way, |
Where should the fix put parentheses, there are several options. For example, if the code that should be fixed is: for (let a = (b, c, d) => { return b && c in d; }; ;); parens could be put around the whole function: for (let a = ((b, c, d) => b && c in d); ;); or around the body: for (let a = (b, c, d) => (b && c in d); ;); or around the "in" node": for (let a = (b, c, d) => b && (c in d); ;); Depending on the precedence, there could be more expressions inside the parens around the "in" node. |
I checked how the fix works for cases like The added parentheses are always around the whole body, so that option would be the consistent one: for (let a = (b, c, d) => (b && c in d); ;); |
Unfortunately, it looks like there wasn"t enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
I"ll fix this. |
Unfortunately, it looks like there wasn"t enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
@mdjermanovic are you working on this? if not I would like to take this |
@anikethsaha I"m not working on it at the moment, feel free to take this! |
* Fix: add parens when in operator (fixes #11849) * Chore: some more tests * Chore: update jsdoc comments Co-authored-by: YeonJuan <[email protected]> * Update: add paren only for ForStatement * Update: fixed adding extra parens * Update: minified traversing using visitor query * Chore: isInOp to false while existing * Update: fixed the logic * Update: logic * Update: checking inside of for loop * Chore: updated is for in check Co-authored-by: YeonJuan <[email protected]>
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
default
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.
What did you expect to happen?
Not a SyntaxError in the fixed code.
What actually happened? Please include the actual, raw output from ESLint.
The fix changed semantics and produced an error:
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
The text was updated successfully, but these errors were encountered: