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
Fix: no-sequences is reporting incorrect locations #12241
Conversation
I would guess historical reasons more than anything else. We didn't always support reporting of end locations, so some of these rules' logic could simply have been written before we supported that. I think we should always require ranges of length 1 or higher personally, but that would be a core breaking change. For this case specifically, I would be in support of highlighting the comma (with start/end), or the whole sequence. |
It's changed now to report |
It's a historical reason. After I added that feature, I had planned to update core rules (#3307 (comment)), but I had failed to make time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
What is the purpose of this pull request? (put an "X" next to item)
[X] Bug fix
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.
Demo link
What did you expect to happen?
3 errors with correct locations of the comma operator.
What actually happened? Please include the actual, raw output from ESLint.
It's reporting the location of the first closing paren after the first expression in the sequence.
What changes did you make? (Give an overview)
Find the first comma token instead of just first token (which could be a closing paren token).
Additionally, the rule will now report comma operator's
loc
instead of justloc.start
.Is there anything you'd like reviewers to focus on?
I have a question. This rule, and most of the rules that report single-char tokens are reporting locations as
token.loc.start
instead of the fulltoken.loc
(which has the start and the end).Why is that? This has a strange effects in editors, e.g. Demo does not highlight anything (at least in my browser), VSCode usually highlights the first character before the token (if it isn't an empty space) instead of the token character.