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
eslint --fix with dot-location breaks code #11868
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
/*eslint dot-location: ["error", "object"]*/ var foo = ( cond1 == true && cond2func() ).toString();
What did you expect to happen?
No change to file
What actually happened? Please include the actual, raw output from ESLint.
/*eslint dot-location: ["error", "object"]*/ var foo = ( cond1 == true && cond2func(). )toString();
As you can see, this code doesn't even parse.
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