How to remove eslint plugin eslint-plugin-jsx-a11y?
Asked Answered
G

3

9

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 ?

Gervase answered 1/4, 2019 at 6:23 Comment(4)
go to '/path-to/node_modules' and check "eslint-plugin" is there are not?? in "package.json" alsoo. This link might help. #13067032Gownsman
eslint-disable plugin you can find here. npmjs.com/package/eslint-plugin-disableGownsman
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!!Np
Sure I will try this, Thanks !!Gervase
A
6

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
    },
}
Adriannaadrianne answered 2/12, 2021 at 18:50 Comment(1)
awesome, good to find thisHyetography
U
7

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)

Ustulation answered 1/4, 2019 at 8:46 Comment(0)
A
6

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
    },
}
Adriannaadrianne answered 2/12, 2021 at 18:50 Comment(1)
awesome, good to find thisHyetography
A
-4

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.

Ambulatory answered 1/4, 2019 at 8:45 Comment(2)
I think this is not really the solution that he is looking for (At least is not the scope of the question).Ustulation
How does this address the question? OP is trying to remove the eslint-plugin-jsx-a11y.Vino

© 2022 - 2024 — McMap. All rights reserved.