Search code examples
javascriptreactjsecmascript-6eslinteslint-config-airbnb

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 ?


Solution

  • 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
        },
    }