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

ESLint couldn't determine the plugin "import" uniquely #16

Open
rtritto opened this issue Dec 14, 2021 · 4 comments
Open

ESLint couldn't determine the plugin "import" uniquely #16

rtritto opened this issue Dec 14, 2021 · 4 comments

Comments

@rtritto
Copy link
Contributor

rtritto commented Dec 14, 2021

This issue, using yarn version >= 3.2.0-rc.7, is related to a conflict with 2 different ESLint config of eslint-plugin-import:

  • eslint-config-next
  • @ijsto/eslint-config » eslint-config-airbnb » eslint-config-airbnb-base

Steps to reproduce

  1. yarn init -y
  2. yarn set version canary (currently install yarn v3.2.0-rc.9)
  3. yarn add @ijsto/eslint-config eslint eslint-config-next next react react-dom
  4. Create .eslintrc.yml file :
extends:
  - '@ijsto'
  - next
  1. Create an empty index.js file
  2. Run 1 or both commands below
  • yarn eslint index.js --> output:
Oops! Something went wrong! :(

ESLint: 8.4.1

ESLint couldn't determine the plugin "import" uniquely.

- C:\test-eslint\.yarn\__virtual__\eslint-plugin-import-virtual-2a929f9851\0\cache\eslint-plugin-import-npm-2.25.3-f5faefaae3-8bdf4b1faf.zip\node_modules\eslint-plugin-import\lib\index.js (loaded in ".eslintrc.yml » eslint-config-next")
- C:\test-eslint\.yarn\__virtual__\eslint-plugin-import-virtual-c11863593e\0\cache\eslint-plugin-import-npm-2.25.3-f5faefaae3-8bdf4b1faf.zip\node_modules\eslint-plugin-import\lib\index.js (loaded in ".eslintrc.yml » @ijsto/eslint-config » eslint-config-airbnb » C:\test-eslint\.yarn\__virtual__\eslint-config-airbnb-base-virtual-daa201a79f\0\cache\eslint-config-airbnb-base-npm-15.0.0-802837dd26-38626bad2c.zip\node_modules\eslint-config-airbnb-base\index.js » C:\test-eslint\.yarn\__virtual__\eslint-config-airbnb-base-virtual-daa201a79f\0\cache\eslint-config-airbnb-base-npm-15.0.0-802837dd26-38626bad2c.zip\node_modules\eslint-config-airbnb-base\rules\imports.js")

Please remove the "plugins" setting from either config or remove either plugin installation.

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team
  • yarn next lint index.js --> output:
Error: Plugin "import" was conflicted between ".eslintrc.yml » eslint-config-next" and ".eslintrc.yml » @ijsto/eslint-config » eslint-config-airbnb » C:\test-eslint\.yarn\__virtual__\eslint-config-airbnb-base-virtual-daa201a79f\0\cache\eslint-config-airbnb-base-npm-15.0.0-802837dd26-38626bad2c.zip\node_modules\eslint-config-airbnb-base\index.js » C:\test-eslint\.yarn\__virtual__\eslint-config-airbnb-base-virtual-daa201a79f\0\cache\eslint-config-airbnb-base-npm-15.0.0-802837dd26-38626bad2c.zip\node_modules\eslint-config-airbnb-base\rules\imports.js"
@rtritto
Copy link
Contributor Author

rtritto commented Jan 2, 2022

Conflict is generated because eslint-plugin-import is a dependency in:

  • @ijsto/eslint-config (needed by peerDependencies of eslint-config-airbnb)
  • eslint-config-next

Probably, a possible solution in @ijsto/eslint-config is to add eslint-config-next and to remove eslint-config-airbnb.

FYI

  • Next.js ESLint:

    ... Next.js will automatically install eslint and eslint-config-next as development dependencies in your application ...

@ScottAgirs
Copy link
Contributor

@rtritto interesting, thank you for providing these details! I wonder how would this work outside of a Next.js project.

@rtritto
Copy link
Contributor Author

rtritto commented Jan 3, 2022

Some duplicated dependencies in eslint-config-next to remove in @ijsto/eslint-config (they should conflict after removing eslint-plugin-import):

  • eslint-plugin-jsx-a11y
  • eslint-plugin-react
  • eslint-plugin-react-hooks

Another interesting feature, gained with eslint-config-next, is the import resolver of TypeScript (eslint-import-resolver-typescript).

@rtritto
Copy link
Contributor Author

rtritto commented Jan 3, 2022

By this way, @ijsto/eslint-config must install all peerDependencies of eslint-config-next:

  • next and (maybe) typescript from eslint-config-next
  • react and react-dom from next

FYI

  • Recommended Plugin Ruleset:

    If you already have ESLint configured in your application and any of the following conditions are true:
    You have one or more of the following plugins already installed (either separately or through a different config such as airbnb or react-app): react, react-hooks, jsx-a11y, import ...
    Then we recommend either removing these settings if you prefer how these properties have been configured within eslint-config-next or extending directly from the Next.js ESLint plugin instead: ...

  • ESLint config:

    If you would like to use eslint-config-next along with other ESLint configurations, refer to the Additional Configurations section to learn how to do so without causing any conflicts.


Or, maybe, install and use only eslint-plugin-next instead of eslint-config-next; source:

  • ESLint Plugin:

    Next.js provides an ESLint plugin, eslint-plugin-next...
    If you already have ESLint configured in your application, we recommend extending from this plugin directly instead of including eslint-config-next unless a few conditions are met. Refer to the Recommended Plugin Ruleset to learn more.

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

2 participants