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

[no-unused-vars] uses non-existent deep import from eslint@5 #2890

Closed
3 tasks done
SimenB opened this issue Dec 21, 2020 · 3 comments · Fixed by #2917
Closed
3 tasks done

[no-unused-vars] uses non-existent deep import from eslint@5 #2890

SimenB opened this issue Dec 21, 2020 · 3 comments · Fixed by #2917
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@SimenB
Copy link
Contributor

SimenB commented Dec 21, 2020

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

Make sure to install eslint@5, which is supported according to peer dependency:

"eslint": "^5.0.0 || ^6.0.0 || ^7.0.0"

{
  "rules": {
    "@typescript-eslint/no-unused-vars": ["error"]
  }
}
// empty

Expected Result

The linter should exit successfully

Actual Result

It fails due to this import, which doesn't exist for eslint@5:

import { getNameLocationInGlobalDirectiveComment } from 'eslint/lib/rules/utils/ast-utils';

Additional Info

Details
eslint src/index.ts --debug
  eslint:cli CLI args: [ 'src/index.ts', '--debug' ] +0ms
  eslint:cli Running on files +4ms
  eslint:glob-utils Creating list of files to process. +0ms
  eslint:ignored-paths baseDir = "/Users/simen/repos/eslint-plugin-jest" +0ms
  eslint:ignored-paths addPatternRelativeToCwd:
  eslint:ignored-paths   original = "/node_modules/*"
  eslint:ignored-paths   cooked   = "/node_modules/*" +1ms
  eslint:ignored-paths addPatternRelativeToCwd:
  eslint:ignored-paths   original = "/bower_components/*"
  eslint:ignored-paths   cooked   = "/bower_components/*" +0ms
  eslint:ignored-paths addPatternRelativeToCwd:
  eslint:ignored-paths   original = ".*"
  eslint:ignored-paths   cooked   = ".*" +0ms
  eslint:ignored-paths addPatternRelativeToCwd:
  eslint:ignored-paths   original = "!../"
  eslint:ignored-paths   cooked   = "!../" +0ms
  eslint:ignored-paths Looking for ignore file in /Users/simen/repos/eslint-plugin-jest +0ms
  eslint:ignored-paths Loaded ignore file /Users/simen/repos/eslint-plugin-jest/.eslintignore +1ms
  eslint:ignored-paths Adding /Users/simen/repos/eslint-plugin-jest/.eslintignore +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "coverage/"
  eslint:ignored-paths   cooked   = "coverage/" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "lib/"
  eslint:ignored-paths   cooked   = "lib/" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "!.eslintrc.js"
  eslint:ignored-paths   cooked   = "!.eslintrc.js" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "coverage/"
  eslint:ignored-paths   cooked   = "coverage/" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "lib/"
  eslint:ignored-paths   cooked   = "lib/" +0ms
  eslint:ignored-paths addPatternRelativeToIgnoreFile:
  eslint:ignored-paths   original = "!.eslintrc.js"
  eslint:ignored-paths   cooked   = "!.eslintrc.js" +0ms
  eslint:ignored-paths contains: +2ms
  eslint:ignored-paths   target = "/Users/simen/repos/eslint-plugin-jest/src/index.ts" +0ms
  eslint:ignored-paths   result = false +0ms
  eslint:ignored-paths contains: +0ms
  eslint:ignored-paths   target = "/Users/simen/repos/eslint-plugin-jest/src/index.ts" +0ms
  eslint:ignored-paths   result = false +0ms
  eslint:cli-engine Processing /Users/simen/repos/eslint-plugin-jest/src/index.ts +0ms
  eslint:cli-engine Linting /Users/simen/repos/eslint-plugin-jest/src/index.ts +1ms
  eslint:config Constructing config file hierarchy for /Users/simen/repos/eslint-plugin-jest/src +0ms
  eslint:config Using .eslintrc and package.json files +0ms
  eslint:config Loading /Users/simen/repos/eslint-plugin-jest/.eslintrc.js +1ms
  eslint:config-file Loading JS config file: /Users/simen/repos/eslint-plugin-jest/.eslintrc.js +0ms
  eslint:plugins Loaded plugin eslint-config (eslint-plugin-eslint-config@1.0.4) (from /Users/simen/repos/eslint-plugin-jest/node_modules/eslint-plugin-eslint-config/lib/index.js) +0ms
  eslint:plugins Loaded plugin eslint-plugin (eslint-plugin-eslint-plugin@2.3.0) (from /Users/simen/repos/eslint-plugin-jest/node_modules/eslint-plugin-eslint-plugin/lib/index.js) +8ms
  eslint:plugins Loaded plugin eslint-comments (eslint-plugin-eslint-comments@3.2.0) (from /Users/simen/repos/eslint-plugin-jest/node_modules/eslint-plugin-eslint-comments/index.js) +8ms
  eslint:plugins Loaded plugin node (eslint-plugin-node@11.1.0) (from /Users/simen/repos/eslint-plugin-jest/node_modules/eslint-plugin-node/lib/index.js) +67ms
  eslint:plugins Loaded plugin prettier (eslint-plugin-prettier@3.3.0) (from /Users/simen/repos/eslint-plugin-jest/node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js) +2ms
  eslint:plugins Loaded plugin import (eslint-plugin-import@2.22.1) (from /Users/simen/repos/eslint-plugin-jest/node_modules/eslint-plugin-import/lib/index.js) +78ms
Error: Cannot find module 'eslint/lib/rules/utils/ast-utils'
Require stack:
- /Users/simen/repos/eslint-plugin-jest/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unused-vars.js
- /Users/simen/repos/eslint-plugin-jest/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js
- /Users/simen/repos/eslint-plugin-jest/node_modules/@typescript-eslint/eslint-plugin/dist/index.js
- /Users/simen/repos/eslint-plugin-jest/node_modules/eslint/lib/config/plugins.js
- /Users/simen/repos/eslint-plugin-jest/node_modules/eslint/lib/config.js
- /Users/simen/repos/eslint-plugin-jest/node_modules/eslint/lib/cli-engine.js
- /Users/simen/repos/eslint-plugin-jest/node_modules/eslint/lib/cli.js
- /Users/simen/repos/eslint-plugin-jest/node_modules/eslint/bin/eslint.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/simen/repos/eslint-plugin-jest/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unused-vars.js:24:21)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)

The regression was introduced in #2768.

Versions

package version
@typescript-eslint/eslint-plugin 4.10.0
@typescript-eslint/parser 4.10.0
TypeScript 4.1.3
ESLint 5.16.0
node 14.15.0
@SimenB SimenB added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Dec 21, 2020
@bradzacher
Copy link
Member

See #2837, #2849

ESLint v5 is technically supported according to the ranged, but there's much of the project that won't work as expected with it.
It's 2 years and 2 breaking changes old - and is long since out of support.

If you want to fix this, happy to accept a PR!

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for maintainers to take a look labels Dec 21, 2020
@SimenB
Copy link
Contributor Author

SimenB commented Dec 21, 2020

If you don't support it, it should be removed from the peer dependency range and a new major released. I can copy over the helper, doesn't seem to be too large?

https://github.com/eslint/eslint/blob/145aec1ab9052fbca96a44d04927c595951b1536/lib/rules/utils/ast-utils.js#L1751-L1779

@bradzacher
Copy link
Member

Yeah as mentioned in #2837 - with the next major it'll be explicitly dropped.
It should have been dropped last major.

Testing exhaustively against old versions of ESLint is hard for us given how tightly we integrate with it, so things like this slip through.

Happy for a PR to copy pasta the method across to unblock ESLint v5 if you'd like!

@bradzacher bradzacher added bug Something isn't working and removed awaiting response Issues waiting for a reply from the OP or another party labels Dec 23, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants