Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove eslint plugin eslint-plugin-jsx-a11y?

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 ?

like image 588
user1441238 Avatar asked Apr 01 '19 06:04

user1441238


People also ask

How do I disable ESLint plugin?

To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in: /* eslint-disable */ console.

How do I remove ESLint?

How do I get rid of ESLint? Basically, just delete . eslintrc and any other eslint config files(if any) from the project. Also, check your package.

What is ESLint plugin?

ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs. In many ways, it is similar to JSLint and JSHint with a few exceptions: ESLint uses Espree for JavaScript parsing.


2 Answers

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)

like image 186
Alberto Perez Avatar answered Sep 18 '22 08:09

Alberto Perez


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
    },
}
like image 24
WebBrother Avatar answered Sep 18 '22 08:09

WebBrother