Skip to content

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

Conversation

lumirlumir
Copy link
Member

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?

@lumirlumir lumirlumir requested a review from a team as a code owner June 8, 2025 09:43
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jun 8, 2025
@eslint-github-bot eslint-github-bot bot added the bug ESLint is working incorrectly label Jun 8, 2025
Copy link

netlify bot commented Jun 8, 2025

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 25fd19b
🔍 Latest deploy log https://app.netlify.com/projects/docs-eslint/deploys/684fe6dc790255000893a22c
😎 Deploy Preview https://deploy-preview-19831--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mdjermanovic mdjermanovic changed the title fix: handle negative column index in getIndexFromLoc and add tests feat: throw error when column is negative in getIndexFromLoc Jun 9, 2025
@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Jun 9, 2025
@mdjermanovic
Copy link
Member

I think this change is fine for a semver-minor release. @eslint/eslint-tsc thoughts?

@mdjermanovic mdjermanovic added the tsc waiting Issues that require feedback from a TSC member label Jun 9, 2025
@lumirlumir lumirlumir moved this from Needs Triage to Feedback Needed in Triage Jun 10, 2025
@nzakas
Copy link
Member

nzakas commented Jun 10, 2025

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.

@lumirlumir lumirlumir marked this pull request as draft June 12, 2025 05:08
@fasttime
Copy link
Member

I think this change is fine for a semver-minor release.

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.

@fasttime fasttime removed the tsc waiting Issues that require feedback from a TSC member label Jun 12, 2025
@lumirlumir lumirlumir added the accepted There is consensus among the team that this change meets the criteria for inclusion label Jun 16, 2025
@lumirlumir
Copy link
Member Author

Thanks for the suggestions. I’ve added new commits and marked this PR as accepted.

@lumirlumir lumirlumir moved this from Feedback Needed to Implementing in Triage Jun 16, 2025
@lumirlumir lumirlumir marked this pull request as ready for review June 16, 2025 09:43
Copy link
Member

@mdjermanovic mdjermanovic left a 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.

@nzakas nzakas moved this from Implementing to Second Review Needed in Triage Jun 16, 2025
@nzakas
Copy link
Member

nzakas commented Jun 16, 2025

@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.

Copy link
Member

@fasttime fasttime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@fasttime fasttime merged commit b8a7e7a into main Jun 18, 2025
30 checks passed
@fasttime fasttime deleted the fix-handle-negative-column-index-in-getindexfromloc-and-add-tests branch June 18, 2025 09:35
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly feature This change adds a new feature to ESLint
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

4 participants