preactjs / eslint-config-preact

Unopinionated baseline ESLint config for Preact and Preact CLI codebases.
https://npm.im/eslint-config-preact
MIT License
95 stars 16 forks source link

Failed to load plugin 'jest' #5

Closed muuvmuuv closed 4 years ago

muuvmuuv commented 4 years ago

I have installed the config in the root of my project and in a sub-directory I have an eslint config, which looks like that:

{
  "root": true,
  "extends": [
    "../.eslintrc.json",
    "preact",
    "plugin:jsx-a11y/recommended"
  ],
  "settings": {
    "react": {
      "createClass": "createElement",
      "pragma": "h"
    }
  },
  "rules": {
    "react/prop-types": "off"
  }
}

Now when I do eslint -c docs/.eslintrc.json --cache docs. I get this error:

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 "/Users/marvinheilemann/Development/CookieConsent".)
rschristian commented 4 years ago

Firstly, check your node_modules directory, and see if eslint-plugin-jest is in there.

If not, try deleting your package-lock.json file as well as the node_modules directory, and then reinstall. Sometimes NPM just won't install all dependencies of dependencies, and this is the fix.

muuvmuuv commented 4 years ago

It is not there, because I'm not using jest or any test framework. Why do I need to install something I do not need? Or why does the eslint-config does not install it as a peerDep, seems like it is not working without it.

rschristian commented 4 years ago

So I think you're confused. This config has eslint-plugin-jest as a dependency. Even if you're not using Jest, or any other testing framework, this package will install that one. You don't need to install anything else yourself.

Or why does the eslint-config does not install it as a peerDep, seems like it is not working without it.

So that's not at all what peer dependencies are for.

A common issue (and is something I've seen myself) is that NPM doesn't install according to the lock file, and it gets confused. The fix for this is what I mentioned above. Delete the lock file, delete your modules folder, and reinstall.

This package should install eslint-plugin-jest itself. If it doesn't, that's an issue with NPM.

muuvmuuv commented 4 years ago

Oh, yes, sorry I misunderstood your suggestion! Now it seems to work (still the babel issue but this is another issue). Thank you!

REENA1101 commented 9 months ago

My Error is: "[eslint] Failed to load plugin 'jest' declared in 'package.json » eslint-config-react-app/jest': Cannot find module 'eslint/package.json'"

quite a similar one, the only difference is that it says "Cannot find module 'eslint/package.json' instead of "eslint-plugin-jest What should I do?