-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat: throw error when column is negative in getIndexFromLoc
#19831
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
feat: throw error when column is negative in getIndexFromLoc
#19831
Conversation
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
getIndexFromLoc
and add testsgetIndexFromLoc
I think this change is fine for a semver-minor release. @eslint/eslint-tsc thoughts? |
I think it's fine for semver-minor. Using -1 now would cause a difficult-to-track-down error right now, so throwing a more useful one is definitely preferable. |
I agree. It's possible that this change could break some plugins, but since the current behavior for negative columns in locations was not intended or documented, this can be a fix. |
Thanks for the suggestions. I’ve added new commits and marked this PR as accepted. |
…fromloc-and-add-tests
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, thanks! Leaving it open for a second review.
@mdjermanovic just a reminder: don't forget to move PRs into the "Second Review Needed" column on the Triage board when waiting for a second review. |
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, thanks!
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Hello,
In this PR, I’ve fixed the handling of negative column indices in
getIndexFromLoc
and added corresponding tests.The JavaScript
SourceCode
class is based on 0-indexed columns, so passing a negative column index should throw an error — but currently, it doesn’t.This could lead to unintended side effects or bugs, so I’ve addressed the issue accordingly.
Is there anything you'd like reviewers to focus on?