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
eslint --fix with dot-location breaks code #11868
eslint --fix with dot-location breaks code #11868
Comments
This is also an issue on 5.15.3 |
Hi @nightpool, thanks for the issue. My guess is we're not adequately taking the parentheses into account. The ESTree spec defines the object node as ending just after I would bet a similar bug exists if the property is surrounded by parentheses and the lint rule is configured to attach the dot to the property. It may place the dot "before the property node" rather than "before the next token after the dot". If I'm correct, whoever works on a fix for this should make sure they don't accidentally pick up a comment token in the updated fixer logic. |
I'd like to work on this, of course if the issue is going to be accepted (guess it will, because fix produces syntax error).
This part of the fix works exactly as you described, and should be corrected to work exactly as you said.
It takes the first token before the property, then safely checks if it is really a dot punctuator, and gives up if it isn't. So there would be no reports and no fixes. Regardless of the options, the node is completely ignored if the first non-comment token before the property node is not the dot. This is actually very helpful at the moment, given the fact that the code never checks the Apart from the |
I've reproduced the issue on the ESLint demo, so I'm marking this as accepted. Thanks @nightpool for the bug report! |
ESLint playground link
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?
No change to file
What actually happened? Please include the actual, raw output from ESLint.
As you can see, this code doesn't even parse.
eslint --fix
should never break correctness and certainly shouldn't ever output something that fails to parse.The text was updated successfully, but these errors were encountered: