Skip to content

fix: handle null type loc in getIndexFromLoc method #19862

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lumirlumir
Copy link
Member

@lumirlumir lumirlumir commented Jun 16, 2025

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 added handling logic for null-type loc to the getIndexFromLoc method.

Currently, passing null to getIndexFromLoc results in an unrelated error because accessing loc.line throws when loc is null.

So, I’ve updated the error message to more precisely indicate that an incorrect type was passed to the getIndexFromLoc method.

  • Before:

image

  • After:

image

Is there anything you'd like reviewers to focus on?

@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jun 16, 2025
@eslint-github-bot eslint-github-bot bot added the bug ESLint is working incorrectly label Jun 16, 2025
Copy link

netlify bot commented Jun 16, 2025

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit bc245ec
🔍 Latest deploy log https://app.netlify.com/projects/docs-eslint/deploys/6851338810b2210008cb394a

@lumirlumir lumirlumir changed the title fix: handle null loc in getIndexFromLoc method fix: handle null type loc in getIndexFromLoc method Jun 16, 2025
@lumirlumir lumirlumir marked this pull request as ready for review June 17, 2025 09:28
@lumirlumir lumirlumir requested a review from a team as a code owner June 17, 2025 09:28
Comment on lines 797 to +798
if (
loc === null ||
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a separate error for this? The error message says what it expects but doesn't mention that loc is null. Something like, "Unexpected null argument."

@lumirlumir lumirlumir marked this pull request as draft June 18, 2025 13:45
@nzakas nzakas moved this from Needs Triage to Implementing in Triage Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ESLint is working incorrectly
Projects
Status: Implementing
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy