Skip to content
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: indent rule looking for a node out of range #15564

Closed
wants to merge 1 commit into from
Closed

fix: indent rule looking for a node out of range #15564

wants to merge 1 commit into from

Conversation

fguitton
Copy link

@fguitton fguitton commented Feb 1, 2022

Hello,

This PR focuses on the correction of a recurring bug triggering :

Cannot read property 'loc' of undefined

Fixes #14538
Fixes #13957
Fixes #13956
Fixes #11023

Many more ...

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[X] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Added check on the length of the node.declarations array.

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

@eslint-github-bot eslint-github-bot bot added triage An ESLint team member will look at this issue soon bug ESLint is working incorrectly labels Feb 1, 2022
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 1, 2022

CLA Signed

The committers are authorized under a signed CLA.

@fguitton fguitton marked this pull request as ready for review February 1, 2022 15:46
@mdjermanovic mdjermanovic added 3rd party plugin This is an issue related to a 3rd party plugin, config, or parser evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Feb 2, 2022
@mdjermanovic
Copy link
Member

Hi @fguitton, thanks for the PR!

As described in the issues you linked, the cause of this problem is that @typescript-eslint/parser allows invalid syntax. The problem will be fixed in @typescript-eslint/parser (typescript-eslint/typescript-eslint#1852).

I'm not in favor of updating rules to account for invalid syntax, because the root cause will eventually be fixed in the parser.

This particular problem in the indent rule doesn't seem critical to me since there's an easy workaround described in #14538 (comment).

@eslint/eslint-tsc thoughts?

@mdjermanovic mdjermanovic added this to Feedback Needed in Triage Feb 2, 2022
@btmills
Copy link
Member

btmills commented Feb 3, 2022

I tend to agree. The core AST traversal and especially rules themselves rely on the parser to have already caught any invalid syntax.

@nzakas
Copy link
Member

nzakas commented Feb 4, 2022

Agreed

@nzakas nzakas closed this Feb 4, 2022
Triage automation moved this from Feedback Needed to Complete Feb 4, 2022
@fguitton fguitton deleted the fix/indent_loc_throw branch February 4, 2022 10:26
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Aug 4, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Aug 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd party plugin This is an issue related to a 3rd party plugin, config, or parser archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
Archived in project
Triage
Complete
4 participants