ihordiachenko / eslint-plugin-chai-friendly

Makes eslint friendly towards Chai.js 'expect' and 'should' statements.
MIT License
53 stars 10 forks source link

feat: add eslint api v9 compatibility #33

Closed MikeMcC399 closed 4 months ago

MikeMcC399 commented 5 months ago

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()](https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#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 commented 4 months ago

@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 commented 4 months ago

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

ihordiachenko commented 4 months ago

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

MikeMcC399 commented 4 months ago

@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 commented 4 months ago

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

MikeMcC399 commented 4 months ago

@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! 👍🏻