nextjs doesn't support eslint-config-airbnb
See original GitHub issueCurrent Behavior
I try to integrate eslint-config-airbnb
into my workspace but without success. It works with a standalone Nextjs app, without NX.
Expected Behavior
I want to extend my eslint’s config with the airbnb
eslint plugin.
Steps to Reproduce
npx create-nx-workspace
- choose
nextjs
template npm i -D eslint-config-airbnb
- drop
"extends": ["airbnb"],
into/.eslintrc.json
- navigate to any
.tsx
file - see the following error:
Failure Logs
Error: Plugin "jsx-a11y" was conflicted between ".eslintrc.json » eslint-config-next/core-web-vitals » /home/boris/projects/acme/node_modules/eslint-config-next/index.js" and ".eslintrc.json » ../../.eslintrc.json » eslint-config-airbnb » /home/boris/projects/acme/node_modules/eslint-config-airbnb/rules/react-a11y.js".
Error: Plugin "jsx-a11y" was conflicted between ".eslintrc.json » eslint-config-next/core-web-vitals » /home/boris/projects/acme/node_modules/eslint-config-next/index.js" and ".eslintrc.json » ../../.eslintrc.json » eslint-config-airbnb » /home/boris/projects/acme/node_modules/eslint-config-airbnb/rules/react-a11y.js".
at mergePlugins (/home/boris/projects/acme/node_modules/@eslint/eslintrc/lib/config-array/config-array.js:201:19)
at createConfig (/home/boris/projects/acme/node_modules/@eslint/eslintrc/lib/config-array/config-array.js:304:9)
at ConfigArray.extractConfig (/home/boris/projects/acme/node_modules/@eslint/eslintrc/lib/config-array/config-array.js:480:33)
at CLIEngine.isPathIgnored (/home/boris/projects/acme/node_modules/eslint/lib/cli-engine/cli-engine.js:982:18)
at ESLint.isPathIgnored (/home/boris/projects/acme/node_modules/eslint/lib/eslint/eslint.js:679:26)
at ESLint8Plugin.<anonymous> (/home/boris/.local/share/JetBrains/Toolbox/apps/WebStorm/ch-0/213.5744.224/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint8-plugin.js:155:57)
at step (/home/boris/.local/share/JetBrains/Toolbox/apps/WebStorm/ch-0/213.5744.224/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint8-plugin.js:44:23)
at Object.next (/home/boris/.local/share/JetBrains/Toolbox/apps/WebStorm/ch-0/213.5744.224/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint8-plugin.js:25:53)
at /home/boris/.local/share/JetBrains/Toolbox/apps/WebStorm/ch-0/213.5744.224/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint8-plugin.js:19:71
at new Promise (<anonymous>)
Environment
Node : 14.17.3
OS : linux x64
npm : 6.14.13
nx : 13.3.6
@nrwl/angular : undefined
@nrwl/cli : 13.3.6
@nrwl/cypress : 13.3.6
@nrwl/devkit : 13.3.6
@nrwl/eslint-plugin-nx : 13.3.6
@nrwl/express : undefined
@nrwl/jest : 13.3.6
@nrwl/linter : 13.3.6
@nrwl/nest : undefined
@nrwl/next : 13.3.6
@nrwl/node : undefined
@nrwl/nx-cloud : undefined
@nrwl/react : 13.3.6
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/tao : 13.3.6
@nrwl/web : 13.3.6
@nrwl/workspace : 13.3.6
@nrwl/storybook : 13.3.6
@nrwl/gatsby : undefined
typescript : 4.4.4
rxjs : 6.6.7
---------------------------------------
Community plugins:
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Next.js 12 Migration and Eslint configuration with Prettier ...
I have a small .prettierrc.js file, but the rules are not being applied. ie: printwidth: 80 · FIXED: Also getting this error Error:...
Read more >React & Next.js - ESLint Setup | Medium - Melih Yumak
If you are using Next.js or React and want to setup ESlint to lint your project you can follow this tutorial. That is...
Read more >Basic Features: ESLint - Next.js
If you don't already have ESLint configured in your application, you will be guided through the installation and configuration process.
Read more >Troubleshooting a Next.js app with ESLint - LogRocket Blog
Setting up ESLint with Next.js. Inside your Next.js app, add a new script called lint — its value should be next lint :...
Read more >33 Setting up ESLint for NextJs | React & Next.js - YouTube
Chapter 33: Learn how to setup eslint in nextjs headless WordPress | WPGraphQLeslint- config for nextjs, next js eslint prettier, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
From now, adding
"airbnb/hooks"
gives me the following error:thanks for opening the issue!
looks like the difference in the
jsx-a11y
plugin comes from the fact that npm installs two different versions ofeslint-plugin-jsx-a11y
at the same time. one is innode_modules
, and one innode_modules/eslint-config-next/node_modules
.@nrwl/react
depends oneslint-plugin-jsx-a11y@^6.4.1
eslint-config-next
depends oneslint-plugin-jsx-a11y@^6.5.1
looks like there’s a similar problem with
eslint-plugin-react
-7.23.1
vs7.27.0
steps on the Nx side:
eslint-plugin-jsx-a11y
andeslint-plugin-react
that Nx depends on to match those ofeslint-config-next
what you can do right now to fix this yourself:
eslint-plugin-jsx-a11y@^6.5.1
andeslint-plugin-react@^7.27.0
in your projectnpm dedupe
based on what i see locally myself - that should solve the problem.
note that once we’ll release a fix that matches the versions of those plugins - you might need to run
npm dedupe
if the problem persists. Sometimes, once npm gets into a weird state like that - it’s hard to correct it, sadly…