Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure eslint-plugin-jsx-a11y in eslint.config.js #965

Closed
rakleed opened this issue Nov 12, 2023 · 5 comments
Closed

How to configure eslint-plugin-jsx-a11y in eslint.config.js #965

rakleed opened this issue Nov 12, 2023 · 5 comments

Comments

@rakleed
Copy link

rakleed commented Nov 12, 2023

From the next version 9, ESLint will deprecate the current eslintrc format, and by default will use the new flat config format (eslint.config.js). Already from version 8.2.23 you can fully use the flat config format. But your README (which is used as a description for the NPM package) doesn’t say anything about how to configure it correctly. Although the README eslint-plugin-react contains this information. Please add this information to the documentation.

@ljharb
Copy link
Member

ljharb commented Nov 12, 2023

That's because this plugin doesn't support flat config yet, so it's correct to not be in the documentation. See #891.

@ljharb ljharb closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2023
@vmerino
Copy link

vmerino commented Feb 27, 2024

I also spent some time looking through PR issues that mention "flat config" to finally find this one. I think it might be valuable to add a note to the readme that says it's currently not supported but coming soon?

@ljharb
Copy link
Member

ljharb commented Feb 27, 2024

@vmerino then i'd get no end to issues asking "when" :-p

@gregjacobs
Copy link

@ljharb So I was able to make the plugin work with the following config object in the flat config with v6.8.0 (for anyone else finding this thread):

import jsxA11y from 'eslint-plugin-jsx-a11y';

// ...

{
    plugins: {
        'jsx-a11y': {
            rules: jsxA11y.rules,
        },
    },
    rules: jsxA11y.configs.recommended.rules,
},

It may also need the languageOptions config for jsx but probably works in mine because I already have eslint-plugin-react in there.

If you don't want to make any changes to the code itself, could just put the above snippet in the readme?

@ljharb
Copy link
Member

ljharb commented Mar 19, 2024

@gregjacobs if you can confirm that all of the rules actually work that way, then I'd be happy to accept a PR with a flat entrypoint that does that (including relevant docs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants