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

feat: add eslint api v9 compatibility #33

Merged
merged 1 commit into from
May 19, 2024

Conversation

MikeMcC399
Copy link
Contributor

Issue

Running the following in this repo (currently based on eslint@8.56.0):

npm ci
npm test

results in the deprecation warning:

(node:29800) DeprecationWarning: "no-unused-expressions" rule is using context.getAncestors(), which is deprecated and will be removed in ESLint v9. Please use sourceCode.getAncestors() instead.

Change

Use the information in the blog post Preparing your custom rules for ESLint v9.0.0 from Sep 26, 2023 from the section context.getAncestors() to update the rule lib/rules/no-unused-expressions.js so that it is compatible with ESLint v9 and with earlier ESLint versions.

Verification

Deprecation

Confirm that deprecation is resolved by executing:

npm ci
npm test

Verify that no deprecation warning is output and that all tests pass (81 passing).

Backwards compatibility

Install an earlier version of ESLint (8.0.0), before the replacement method SourceCode#getAncestors(node) was added, and confirm that tests continue to pass (81 passing).

npm install eslint@8.0.0
npm test

@MikeMcC399 MikeMcC399 marked this pull request as ready for review May 13, 2024 11:44
@MikeMcC399
Copy link
Contributor Author

@ihordiachenko

Can I ask you to review this PR please?

Workarounds are possible, however it would be nice to get this PR merged, even though it solves only one part of migration to ESLint v9 support.

@ihordiachenko
Copy link
Owner

Hi @MikeMcC399, thanks for your PR. I will look into it this Sunday

@ihordiachenko
Copy link
Owner

Lgtm. Will release it alongside #31 asap to fully address the ESLint v9 compatibility

@ihordiachenko ihordiachenko merged commit 4a33848 into ihordiachenko:master May 19, 2024
@MikeMcC399
Copy link
Contributor Author

@ihordiachenko

Lgtm. Will release it alongside #31 asap to fully address the ESLint v9 compatibility

https://eslint.org/blog/2022/08/new-config-system-part-2/#backwards-compatibility-utility
https://www.npmjs.com/package/@eslint/eslintrc

@ihordiachenko
Copy link
Owner

@MikeMcC399 I am working on the flat config compatibility already. Should be ready today

@MikeMcC399 MikeMcC399 deleted the fix/eslint-9-api branch May 20, 2024 09:21
@MikeMcC399
Copy link
Contributor Author

@ihordiachenko

I am working on the flat config compatibility already. Should be ready today

Excellent! I want to include it in the ESLint v9 examples for cypress-io/eslint-plugin-cypress, so it will be very helpful to have your planned update! 👍🏻

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.

context.getAncestors is not a function with eslint 9.0.0
2 participants