cypress-io / eslint-plugin-cypress

An ESLint plugin for projects that use Cypress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eslint 8 deprecated rules `context`: planned failure Eslint 9

MikeMcC399 opened this issue ยท comments

Issue

Eslint 8 shows deprecation warnings for planned removal in Eslint 9:

  • "no-unnecessary-waiting" rule is using context.getScope()
  • "no-async-tests" rule is using context.getAncestors()
  • "no-async-before" rule is using context.getAncestors()

(node:3998) DeprecationWarning: "no-unnecessary-waiting" rule is using context.getScope(), which is deprecated and will be removed in ESLint v9. Please use sourceCode.getScope() instead.
(node:3998) DeprecationWarning: "no-async-tests" rule is using context.getAncestors(), which is deprecated and will be removed in ESLint v9. Please use sourceCode.getAncestors() instead.
(node:3970) DeprecationWarning: "no-async-before" rule is using context.getAncestors(), which is deprecated and will be removed in ESLint v9. Please use sourceCode.getAncestors() instead.

Versions

eslint@8.57.0
eslint-plugin-cypress@2.15.2
Ubuntu 22.04.4 LTS
Node.js 20.12.2 LTS

Steps to reproduce

Ubuntu 22.04.4 LTS, Node.js 20.12.2 LTS

git clone https://github.com/cypress-io/eslint-plugin-cypress
cd eslint-plugin-cypress
npm install eslint@8 --legacy-peer-deps
npm test

Logs

$ npm test

> eslint-plugin-cypress@0.0.0-development test
> jest

(node:4074) DeprecationWarning: "no-unnecessary-waiting" rule is using `context.getScope()`, which is deprecated and will be removed in ESLint v9. Please use `sourceCode.getScope()` instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 PASS  tests/lib/rules/no-unnecessary-waiting.js
 PASS  tests/lib/rules/no-force.js
 PASS  tests/lib/rules/assertion-before-screenshot.js
 PASS  tests/lib/rules/no-assigning-return-values.js
 PASS  tests/lib/rules/unsafe-to-chain-command.js
 PASS  tests/lib/rules/require-data-selectors.js
 PASS  tests/lib/rules/no-pause.js
(node:4074) DeprecationWarning: "no-async-tests" rule is using `context.getAncestors()`, which is deprecated and will be removed in ESLint v9. Please use `sourceCode.getAncestors()` instead.
 PASS  tests/lib/rules/no-async-tests.js
(node:4074) DeprecationWarning: "no-async-before" rule is using `context.getAncestors()`, which is deprecated and will be removed in ESLint v9. Please use `sourceCode.getAncestors()` instead.
 PASS  tests/lib/rules/no-async-before.js
 PASS  tests/config.js

Test Suites: 10 passed, 10 total
Tests:       133 passed, 133 total
Snapshots:   0 total
Time:        1.431s, estimated 2s
Ran all test suites.

Related

Edit: updated after merge of PR #151

This issue relates to the blog Preparing your custom rules for ESLint v9.0.0 published on Sep 26, 2023.

The incompatible methods need special handling, see

since their replacements were only added in later ESLint 8.x versions about one year ago.

  • PR #151 has added a new rule no-async-before which uses the deprecated API context.getAncestors():

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

  • This issue is proposed to be fixed by PR #182

๐ŸŽ‰ This issue has been resolved in version 3.0.2 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€