You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This change adds support for ESLint's new Flat config system. It maintains backwards compatibility with eslintrc
style configs as well.
To achieve this, we're now dynamically creating four configs: two are the original `recommended` and `strict`, and the other two are the new `flat/recommended` and `flat/strict`. The two `flat` ones are setup with the new config format, while the original two have the same options as before.
Usage
Legacy
```json
{
"extends": ["plugin:jsx-a11y/recommended"]
}
```
Flat
```js
import globals from 'globals';
import js from '@eslint/js';
import jsxA11y from 'eslint-plugin-jsx-a11y';
export default [
js.configs.recommended,
jsxA11y.configs['flat/recommended'],
{
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: globals.browser,
},
ignores: ['dist', 'eslint.config.js'],
rules: {
'no-unused-vars': 'warn',
'jsx-a11y/anchor-ambiguous-text': 'warn',
'jsx-a11y/anchor-is-valid': 'warn',
},
},
];
```
**Note:** If you installed ESLint globally (using the `-g` flag in npm, or the `global` prefix in yarn) then you must also install `eslint-plugin-jsx-a11y` globally.
62
62
63
-
## Usage
63
+
<aid="usage"></a>
64
+
65
+
## Usage - Legacy Config (`.eslintrc`)
64
66
65
67
Add `jsx-a11y` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
66
68
@@ -109,6 +111,94 @@ Add `plugin:jsx-a11y/recommended` or `plugin:jsx-a11y/strict` in `extends`:
109
111
}
110
112
```
111
113
114
+
## Usage - Flat Config (`eslint.config.js`)
115
+
116
+
The default export of `eslint-plugin-jsx-a11y` is a plugin object.
There are two shareable configs, provided by the plugin.
148
+
149
+
-`flat/strict`
150
+
-`flat/recommended`
151
+
152
+
#### CJS
153
+
154
+
```js
155
+
constjsxA11y=require('eslint-plugin-jsx-a11y');
156
+
157
+
exportdefault [
158
+
jsxA11y.configs['flat/recommended'],
159
+
{
160
+
// Your additional configs and overrides
161
+
},
162
+
];
163
+
```
164
+
165
+
#### ESM
166
+
167
+
```js
168
+
importjsxA11yfrom'eslint-plugin-jsx-a11y';
169
+
170
+
exportdefault [
171
+
jsxA11y.configs['flat/recommended'],
172
+
{
173
+
// Your additional configs and overrides
174
+
},
175
+
];
176
+
```
177
+
178
+
**Note**: Our shareable config do configure `files` or [`languageOptions.globals`](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#configuration-objects).
179
+
For most of the cases, you probably want to configure some of these properties yourself.
To enable your custom components to be checked as DOM elements, you can set global settings in your configuration file by mapping each custom component name to a DOM element type.
@@ -124,7 +214,7 @@ For example, if you set the `polymorphicPropName` setting to `as` then this elem
124
214
125
215
will be evaluated as an `h3`. If no `polymorphicPropName` is set, then the component will be evaluated as `Box`.
126
216
127
-
⚠️ Polymorphic components can make code harder to maintain; please use this feature with caution.
217
+
⚠️ Polymorphic components can make code harder to maintain; please use this feature with caution.
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+
Currently, two official plugins are available:
6
+
7
+
-[@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8
+
-[@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
0 commit comments