aladdin-add / eslint-plugin

autofix some errors reported by eslint rules.
107 stars 10 forks source link

bug report: eslint-plugin-no-autofix requires eslint-plugin-graphql #83

Closed DerZyklop closed 2 years ago

DerZyklop commented 2 years ago

It seems like your package relies on eslint-plugin-graphql.

When i tried to use it in my project i got this:

Error: Failed to load plugin 'no-autofix' declared in '.eslintrc.json#overrides[1]': Cannot find module 'graphql'
Require stack:
- ~/my-project/node_modules/eslint-plugin-graphql/lib/index.js
- ~/my-project/node_modules/eslint-plugin-no-autofix/lib/rules.js
- ~/my-project/node_modules/eslint-plugin-no-autofix/lib/configs/all.js
- ~/my-project/node_modules/eslint-plugin-no-autofix/lib/index.js
- ~/my-project/node_modules/@eslint/eslintrc/lib/config-array-factory.js
- ~/my-project/node_modules/@eslint/eslintrc/lib/index.js
- ~/my-project/node_modules/eslint/lib/cli-engine/cli-engine.js
- ~/my-project/node_modules/eslint/lib/eslint/eslint.js
- ~/my-project/node_modules/eslint/lib/eslint/index.js
- ~/my-project/node_modules/eslint/lib/cli.js
- ~/my-project/node_modules/eslint/bin/eslint.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (~/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (~/my-project/node_modules/eslint-plugin-graphql/lib/index.js:16:16)
    at Module._compile (~/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)

Installing it via npm i eslint-plugin-graphql -D fixed it for me.

eslint-plugin-graphql is not listed in your package.json.

aladdin-add commented 2 years ago

the plugin was trying to load all installed eslint plugins (including eslint-plugin-graphql). looks like you have installed eslint-plugin-graphql, it requires graphql, but not installed.

DerZyklop commented 2 years ago

Thanks for the quick reply!

looks like you have installed eslint-plugin-graphql

When I installed eslint-plugin-no-autofix I did not have eslint-plugin-graphql installed myself. But here is what I found… I had @shopify/eslint-plugin installed which requires eslint-plugin-graphqlhere:

https://github.com/Shopify/web-configs/blob/main/packages/eslint-plugin/package.json#L45

So when I run npm install, eslint-plugin-graphql already gets added to …/node_modules/

Shouldn’t eslint-plugin-no-autofix then be able to load it correctly?

aladdin-add commented 2 years ago

yes, it should be. but eslint-plugin-graphql has a peerDeps graphql.

if you are using npm >=7, peerDeps will be installed automatically, But if not(e.g. yarn/pnpm), you will have to list graphql in your deps.

aladdin-add commented 2 years ago

closing, as it's not an issue in the plugin.