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

npm run lint: couldn't find the plugin "eslint-plugin-jest". #67

Closed
daniel-j-h opened this issue Dec 31, 2021 · 7 comments
Closed

npm run lint: couldn't find the plugin "eslint-plugin-jest". #67

daniel-j-h opened this issue Dec 31, 2021 · 7 comments

Comments

@daniel-j-h
Copy link
Contributor

Hey folks, it looks like we provide a npm run lint script, but running it in a freshly created template project does not work by default.

Here are the steps to reproduce is:

  1. Create a new project from this template
  2. Run npm run lint

See the outputs below.

/app # preact create typescript test
/app/test # npm run lint

> test@0.0.0 lint
> eslint 'src/**/*.{js,jsx,ts,tsx}'


Oops! Something went wrong! :(

ESLint: 6.8.0.

ESLint couldn't find the plugin "eslint-plugin-jest".

(The package "eslint-plugin-jest" was not found when loaded as a Node module from the directory "/app/test".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-jest@latest --save-dev

The plugin "eslint-plugin-jest" was referenced from the config file in "package.json » eslint-config-preact".

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.
@rschristian
Copy link
Member

See: preactjs/eslint-config-preact#19

It's a long standing issue in ESLint itself, nothing we can do.

@daniel-j-h
Copy link
Contributor Author

Gotcha! 🙇 But this means the default npm run lint script does not work.

I tried installing the package manually - as the error message recommends - but even this fails (see below). Is there a way forward or a workaround in the meantime? The linked eslint issue is from 2015 and I'm not sure if / when it will get resolved.

/app # npm install --save-dev eslint-plugin-jest
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: eslint-plugin-jest@25.3.4
npm ERR! Found: @typescript-eslint/eslint-plugin@2.34.0
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR!   dev @typescript-eslint/eslint-plugin@"^2.25.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional @typescript-eslint/eslint-plugin@"^4.0.0 || ^5.0.0" from eslint-plugin-jest@25.3.4
npm ERR! node_modules/eslint-plugin-jest
npm ERR!   dev eslint-plugin-jest@"*" from the root project
npm ERR!   eslint-plugin-jest@"^25.2.4" from eslint-config-preact@1.3.0
npm ERR!   node_modules/eslint-config-preact
npm ERR!     dev eslint-config-preact@"^1.1.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @typescript-eslint/eslint-plugin@5.8.1
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR!   peerOptional @typescript-eslint/eslint-plugin@"^4.0.0 || ^5.0.0" from eslint-plugin-jest@25.3.4
npm ERR!   node_modules/eslint-plugin-jest
npm ERR!     dev eslint-plugin-jest@"*" from the root project
npm ERR!     eslint-plugin-jest@"^25.2.4" from eslint-config-preact@1.3.0
npm ERR!     node_modules/eslint-config-preact
npm ERR!       dev eslint-config-preact@"^1.1.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-01-02T18_43_28_290Z-debug.log

@rschristian
Copy link
Member

But this means the default npm run lint script does not work.

That's not true across the board; I have no idea what the resolution issue is (besides that there is one), but I can run the lint script on a new project without any issue, and others can too. I'm running npm v6.14.15 and yarn v1.22.17 for what its worth.

That error message looks to be just dealing with the wonky peer dep system that npm v7 brought with it. Have you tried installing with legacy peer deps, and trying again?

Is there a way forward or a workaround in the meantime?

Remove the Preact eslint config I suppose.

package.json

"eslintConfig": {
    "parser": "@typescript-eslint/parser",
    "extends": [
-     "preact",
      "plugin:@typescript-eslint/recommended"
    ],
    "ignorePatterns": [
      "build/"
    ]
  },
npm uninstall eslint-config-preact

@daniel-j-h
Copy link
Contributor Author

But this means the default npm run lint script does not work.

That's not true across the board; I have no idea what the resolution issue is (besides that there is one), but I can run the lint script on a new project without any issue, and others can too. I'm running npm v6.14.15 and yarn v1.22.17 for what its worth.

Gotcha! 🙇 I'm running Node LTS 16 in a

FROM node:16-alpine

self-contained and reproducible docker image; in there it is an issue. It sounds like it depends on the npm/yarn version then?

Here are the npm and node versions the node 16 image is coming with

/app # npm --version
8.1.0
/app # node --version
v16.13.0

That error message looks to be just dealing with the wonky peer dep system that npm v7 brought with it. Have you tried installing with legacy peer deps, and trying again?

If I install with legacy peer deps, then I get the following error when running the lint script.

/app # npm run lint

> test@0.0.0 lint
> eslint 'src/**/*.{js,jsx,ts,tsx}'


Oops! Something went wrong! :(

ESLint: 6.8.0.

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "/app".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in "package.json » eslint-config-preact".

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.

Not sure why it's complaining about a react hooks package now; this is punching way above my head and I can't really debug it 😅

@kentr
Copy link

kentr commented Jan 15, 2022

@rschristian

It's a long standing issue in ESLint itself, nothing we can do.

Upgrading to eslint@8.6.0 and then removing & reinstalling eslint-config-preact fixes this for me on a project from the default template.

So perhaps upping eslint in the template dependencies will resolve it.

@rschristian
Copy link
Member

I don't believe it's related to ESLint version, unfortunately.

I've had the problem correct itself after a wipe of node_modules/ and reinstall.

Not against bumping ESLint, as I think the preact config is now compatible, but I don't think it will solve any issues sadly.

@obasille
Copy link
Contributor

obasille commented Jul 18, 2022

I have the same issue on a brand new project created with preact typescript template.

Running npm install eslint-plugin-jest@25.7 --legacy-peer-deps --save-dev saved the day.

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

No branches or pull requests

4 participants