eslint: Bug: (TypeError: Failed to load plugin '@typescript-eslint' declared in '.eslintrc.json': Class extends value undefined is not a constructor or null)

Environment

Node version: v14.18.0 npm version: 6.14.15 yarn version: 1.22.10 Local ESLint version: 8.0.0 Global ESLint version: - Operating System: Windows 11

What parser are you using?

@typescript-eslint/parser

What did you do?

Configuration

.eslintrc.json

{
    "root": true,
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": 6,
        "sourceType": "module"
    },
    "plugins": ["@typescript-eslint"],
    "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
    "rules": {
        "@typescript-eslint/naming-convention": "warn",
        "@typescript-eslint/semi": "warn",
        "curly": "warn",
        "eqeqeq": "warn",
        "no-throw-literal": "warn",
        "semi": "off"
    }
}

.eslintignore

dist
node_modules

package.json

...
"scripts": {
        "lint": "eslint ./src/** --ext .ts",
        "prettier": "prettier --write ./",
    },
"devDependencies": {
        "@types/glob": "^7.1.3",
        "@types/mocha": "^8.0.4",
        "@types/node": "^12.11.7",
        "@types/vscode": "^1.54.0",
        "@typescript-eslint/eslint-plugin": "^4.33.0",
        "@typescript-eslint/parser": "^4.33.0",
        "eslint": "^8.0.0",
        "glob": "^7.1.6",
        "husky": "^7.0.2",
        "mocha": "^8.2.1",
        "prettier": "^2.4.1",
        "ts-loader": "^8.0.14",
        "typescript": "^4.4.3",
        "webpack": "^5.19.0",
        "webpack-cli": "^4.4.0"
    },

command launched

yarn
yarn lint

What did you expect to happen?

I expect eslint to lint my files.

What actually happened?

yarn
yarn install v1.22.10
[1/5] Validating package.json...
warning snippets-viewer@1.10.0: The engine "vscode" appears to be invalid.
[2/5] Resolving packages...
[3/5] Fetching packages...
info fsevents@2.3.2: The platform "win32" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > @typescript-eslint/eslint-plugin@4.33.0" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
warning " > @typescript-eslint/parser@4.33.0" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
[5/5] Building fresh packages...
$ husky install
husky - Git hooks installed
Done in 2.33s.

yarn run v1.22.10
warning snippets-viewer@1.10.0: The engine "vscode" appears to be invalid.
$ eslint ./src/** --ext .ts

Oops! Something went wrong! :(

ESLint: 8.0.0

TypeError: Failed to load plugin '@typescript-eslint' declared in '.eslintrc.json': Class extends value undefined is not a constructor or null
Referenced from: E:\dev\vscode-snippets-editor\.eslintrc.json
    at Object.<anonymous> (E:\dev\vscode-snippets-editor\node_modules\@typescript-eslint\experimental-utils\dist\ts-eslint\CLIEngine.js:12:34)
    at Module._compile (E:\dev\vscode-snippets-editor\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (E:\dev\vscode-snippets-editor\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (E:\dev\vscode-snippets-editor\node_modules\@typescript-eslint\experimental-utils\dist\ts-eslint\index.js:14:14)
    at Module._compile (E:\dev\vscode-snippets-editor\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 32
  • Comments: 21 (6 by maintainers)

Commits related to this issue

Most upvoted comments

eslint v8 will be supported in ts-eslint v5. please follow the issue: https://github.com/typescript-eslint/typescript-eslint/issues/3738

It seems to be working with eslint 7.32.0.

As noted, this is an issue with typescript-eslint. We will leave this issue open for visibility.

You can try the release candidate of the new version:

npm install typescript-eslint@rc-v5

update: ts-eslint v5.0.0 has been released. 🎉

I am seeing this same issue with react testing library as a plugin after upgrading to v8.

Failed to load plugin 'testing-library' declared in 'package.json#overrides[0]': Class extends value undefined is not a constructor or null

anyone else seeing this too?

"eslintConfig": {
    "parser": "babel-eslint",
    "env": {
      "browser": true,
      "node": true,
      "jest": true
    },
    "plugins": [
      "testing-library",
      "jest-dom"
    ],
    ....

Got the same issue with the 8.0.1 version

I am seeing this same issue with react testing library as a plugin after upgrading to v8.

Failed to load plugin 'testing-library' declared in 'package.json#overrides[0]': Class extends value undefined is not a constructor or null

anyone else seeing this too?

"eslintConfig": {
    "parser": "babel-eslint",
    "env": {
      "browser": true,
      "node": true,
      "jest": true
    },
    "plugins": [
      "testing-library",
      "jest-dom"
    ],
    ....

It seems that ESLint-Plugin-Testing-Library is not fully ready for ESLint 8 yet.

Nonetheless you’re able to install and try the latest alpha of ESLint-Plugin-Testing-Library to get your linter running. Try: npm i eslint-plugin-testing-library@5.0.0-alpha.10

This worked at least on my machine 😃

@KrakenTyio @rudivanbiljon, what’s the output running npm ls @typescript-eslint/parser @typescript-eslint/eslint-plugin?

if it’s all v5, please file an issue in ts-eslint repo.

Confirming this issue on node version 14.15.1. Works on 16.5.0 no problem.

Had the same issue on node version 13.6.0, Works fine on 16.3.0

thanks @nzakas working fine with @rc-v5