8

I have eslint (of Airbnb coding style) setup for my React project, which has dependency of "eslint-plugin-jsx-a11y", which I do not want for my current project.

My question how to remove this specific plugin "eslint-plugin-jsx-a11y".

When I uninstall "eslint-plugin-jsx-a11y" it gives error following error:

"Failed to load plugin jsx-a11y: Cannot find module 'eslint-plugin-jsx-a11y'"

Is there any way to solve above issue ?

user1441238
  • 165
  • 1
  • 2
  • 10
  • go to '/path-to/node_modules' and check "eslint-plugin" is there are not?? in "package.json" alsoo. This link might help. https://stackoverflow.com/questions/13066532/how-to-uninstall-npm-modules-in-node-js – Pallamolla Sai Apr 01 '19 at 06:36
  • 2
    eslint-disable plugin you can find here. https://www.npmjs.com/package/eslint-plugin-disable – Pallamolla Sai Apr 01 '19 at 06:40
  • 1
    First install package `eslint-config-airbnb-base` which will give you the base eslint airbnb package and then install `eslint-plugin-react`. This way you don't have to install `eslint-plugin-jsx-a11y`. Hope that helps!! – tarzen chugh Apr 01 '19 at 06:42
  • Sure I will try this, Thanks !! – user1441238 Apr 01 '19 at 07:57

3 Answers3

6

First of all, you will need to remove the references to the plugin (eslint-plugin-jsx-a11y) on your .eslintrc (That's why when you uninstall it you eslint config is giving you an error):

  1. Search and delete in extends (if you have it) plugin:jsx-a11y/recommended.
  2. Search and delete in plugins: jsx-a11y.
  3. Then in rules delete every rule that involes jsx-a11y (Eg: "jsx-a11y/rule-name": 2).
  4. Finally you can delete it from the project: npm uninstall eslint-plugin-jsx-a11y --save-dev.

PS: If you have any disable statement for eslint-plugin-jsx-a11y, remember to delete it (they won't be necessary anymore)

Camilo
  • 6,504
  • 4
  • 39
  • 60
Alberto Perez
  • 2,561
  • 1
  • 14
  • 21
5

The answer of Alberto Perez is valid if you include jsx-a11y plugin explicitly. But if you extend another plugin that contains jsx-a11y his approach doesn't work.

If so you can use this:

1st solution

https://github.com/mradionov/eslint-plugin-disable

At the moment it doesn't support eslint@8. See the issue.

2nd solution

https://github.com/airbnb/javascript/issues/2032#issuecomment-568934232

const a11yOff = Object.keys(require('eslint-plugin-jsx-a11y').rules)
    .reduce((acc, rule) => { acc[`jsx-a11y/${rule}`] = 'off'; return acc }, {})

module.exports = {
    rules: {
        ...a11yOff,
        // your rules
    },
}
WebBrother
  • 1,447
  • 20
  • 31
-3

Try to install the latest version of react-scripts

If this doesn't work, try updating all the way to the latest one 1.0.10, updated the react and react-dom in my package.json, deleted the package-lock.json and re-installed node_modules.

Panayiotis Georgiou
  • 1,135
  • 3
  • 19
  • 36