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

@cypress/eslint-plugin-dev not compatible with ESLint v8 and later #29344

Closed
MikeMcC399 opened this issue Apr 17, 2024 · 4 comments · Fixed by #29346
Closed

@cypress/eslint-plugin-dev not compatible with ESLint v8 and later #29344

MikeMcC399 opened this issue Apr 17, 2024 · 4 comments · Fixed by #29346

Comments

@MikeMcC399
Copy link
Contributor

Current behavior

Attempting to lint using @cypress/eslint-plugin-dev with ESLint v8 fails with:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Failed to load plugin '@cypress/dev' declared in '.eslintrc.json': Package subpath './lib/rules/arrow-body-style' is not defined by "exports"

The ESLint Migrate to v8.0.0 describes the following in the section The /lib entrypoint has been removed:

Beginning in v8.0.0, ESLint is strictly defining its public API. Previously, you could reach into individual files such as require("eslint/lib/rules/semi") and this is no longer allowed. There are a limited number of existing APIs that are now available through the /use-at-your-own-risk entrypoint for backwards compatibility, but these APIs are not formally supported and may break or disappear at any point in time.

The following code shows that @cypress/eslint-plugin-dev is using require in the way that is described as no longer allowed in ESLint 8.x.

const arrowBodyStyle = require('eslint/lib/rules/arrow-body-style')

Desired behavior

Add the restriction to the npm/eslint-plugin-dev/README.md that ESLint 7.x is the highest version supported by @cypress/eslint-plugin-dev.

Test code to reproduce

On Ubuntu 22.04.4 LTS with Node.js 20.12.2, execute the following:

mkdir eslint-plugin-dev-test
cd eslint-plugin-dev-test
git init
npm init -y
npm install eslint@8 @cypress/eslint-plugin-dev eslint-plugin-json-format @typescript-eslint/parser@6 @typescript-eslint/eslint-plugin@6 eslint-plugin-mocha -D

Add the file .eslintrc.json with the following contents to the root of the above project:

{
  "plugins": [
    "@cypress/dev"
  ],
  "extends": [
    "plugin:@cypress/dev/general"
  ]
}
touch index.js
npx eslint .

Note the error message:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Failed to load plugin '@cypress/dev' declared in '.eslintrc.json': Package subpath './lib/rules/arrow-body-style' is not defined by "exports"

Cypress Version

@cypress/eslint-plugin-dev v5.3.3

Node version

v20.12.2 LTS

Operating System

Ubuntu 22.04.4 LTS

Debug Logs

$ npx eslint .

Oops! Something went wrong! :(

ESLint: 8.57.0

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Failed to load plugin '@cypress/dev' declared in '.eslintrc.json': Package subpath './lib/rules/arrow-body-style' is not defined by "exports" in /home/mike/github/eslint-plugin-dev-test/node_modules/eslint/package.json
Referenced from: /home/mike/github/eslint-plugin-dev-test/.eslintrc.json
    at exportsNotFound (node:internal/modules/esm/resolve:304:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:651:9)
    at resolveExports (node:internal/modules/cjs/loader:590:36)
    at Module._findPath (node:internal/modules/cjs/loader:667:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1129:27)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/home/mike/github/eslint-plugin-dev-test/node_modules/@cypress/eslint-plugin-dev/lib/custom-rules/arrow-body-multiline-braces.js:2:24)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)

Other

No response

@MikeMcC399
Copy link
Contributor Author

I can submit a documentation PR for this if desired.

@jennifer-shehane
Copy link
Member

It'd be nicer to update it, but a documentation note seems sufficient for today.

@MikeMcC399
Copy link
Contributor Author

@jennifer-shehane

It'd be nicer to update it, but a documentation note seems sufficient for today.

I don't see a quick fix for this, so before anybody else trips up over the compatibility issue like I did, I thought it was a good idea to document it. I see that @AtofStryker is fixing some issues in https://github.com/cypress-io/cypress/tree/update-eslint-plugin-dev but that doesn't solve the compatibility issue with ESLint 8.x.

@MikeMcC399
Copy link
Contributor Author

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 a pull request may close this issue.

2 participants