Failed to load plugin 'jest' declared in 'BaseConfig': Cannot find module 'eslint-plugin-jest'
mishabruml opened this issue · 4 comments
Thanks for an awesome project! Having issues with jest eslint plugin:
xo-config.json:
{
"rules": {
"object-curly-spacing": ["error", "always"],
"@typescript-eslint/object-curly-spacing": ["error", "always"]
},
"plugins": ["jest"],
"extends": ["plugin:jest/recommended"]
}
package.json:
{
"name": "ts-node-starter",
"engines": {
"node": "^14.18.0",
"npm": "^6.14.15"
},
"version": "1.0.0",
"description": "typescript node project boilerplate",
"author": "Misha Bruml",
"license": "ISC",
"type": "module",
"scripts": {
"tsc:check": "tsc --noEmit",
"lint": "npm run tsc:check && xo",
"test": "jest"
},
"devDependencies": {
"@types/jest": "^26.0.24",
"@types/node": "^14.17.20",
"eslint-plugin-jest": "^24.5.0",
"jest": "^27.2.4",
"ts-jest": "^27.0.5",
"ts-node": "^9.1.1",
"typescript": "^4.4.3",
"xo": "^0.45.0"
},
"dependencies": {}
}
Is this a problem with the vscode plugin? Running npx xo
works fine, and changing a file to purposefully break a jest rule yields e.g:
test/hello-world/index.test.ts:6:7
✖ 6:7 Unexpected focused test. jest/no-focused-tests
1 error
i resolved this issue by restarting my laptop, rm -rf node_modules && npm i
and restarting VS Code. Not sure which of those was the one that actually was effective 🤷
Hmm I am running into the same issue but on CLI - what I don't really get is that it is crashing in @typescript-eslint
though I don't even use Typescript.
> eyesbound@3.0.0 xo
> xo --fix
TypeError: Failed to load plugin 'jest' declared in 'BaseConfig': Class extends value undefined is not a constructor or null
Referenced from: BaseConfig
at Object.<anonymous> (R:\eyesbound\node_modules\@typescript-eslint\experimental-utils\dist\ts-eslint\CLIEngine.js:12:34)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (R:\eyesbound\node_modules\@typescript-eslint\experimental-utils\dist\ts-eslint\index.js:14:14)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
OK I found the issue - when installing eslint-plugin-jest
I falsely ran:
npm i --save-dev eslint eslint-plugin-jest
this bumped eslint to 8.3.0
and apparently >v.8 is not yet usable with all of the plugins eslint/eslint#15149
Theres also an issue where VS code bugs out and omits the eslint plugin and restarting VS Code for me worked.
@mishabruml