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 compatibility issue with ESLint v9 #137

Merged
merged 2 commits into from
Aug 22, 2024
Merged

Conversation

SegaraRai
Copy link
Contributor

The context.getScope() function, removed in ESLint v9, was used in src/rules/no-child-traversal-in-connectedcallback.ts, causing an error when the rule was executed in ESLint v9.
This PR migrates the relevant part to the new context.sourceCode.getScope(node) and migrates other deprecated APIs such as getSourceCode() to the new API added in ESLint v8.40.0.

@43081j
Copy link
Owner

43081j commented Aug 21, 2024

not sure how nicely typescript will play if you do this, but we could keep compatibility by doing this:

const sourceCode = context.sourceCode ?? context.getSourceCode();

what do you think?

this is also what eslint's docs suggest

@SegaraRai
Copy link
Contributor Author

SegaraRai commented Aug 22, 2024

I have confirmed that SourceCode#getScope(node) , which was added in ESLint v8.37.0, is already used in util/ast.ts.
Thus, this PR only affects users who are using ESLint v8.37 through v8.39.
Since ESLint v8.40.0 has been released more than a year ago, I no longer expect many such users and prefer to keep the codebase simple instead.
Perhaps it should be mentioned in the release notes.

@43081j
Copy link
Owner

43081j commented Aug 22, 2024

is the same true for sourceCode?

i.e. was it available the same amount of time

if so, you're right, we're probably fine

@SegaraRai
Copy link
Contributor Author

SegaraRai commented Aug 22, 2024

Yeah, sourceCode was added in v8.40.0, which was released more than a year ago.
(SourceCode#getScope(node) was introduced in v8.37.0, so only users using v8.37.0 to v8.39.0 are affected.)

@43081j 43081j merged commit 31b1a49 into 43081j:master Aug 22, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants