eslint-config-airbnb-extended 0.0.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/base/index.ts +21 -0
  3. package/base/recommended.ts +17 -0
  4. package/index.ts +25 -0
  5. package/package.json +33 -45
  6. package/react/index.ts +11 -0
  7. package/react/recommended.ts +6 -0
  8. package/rules/best-practices.ts +462 -0
  9. package/rules/errors.ts +199 -0
  10. package/rules/es6.ts +224 -0
  11. package/rules/imports.ts +308 -0
  12. package/rules/node.ts +49 -0
  13. package/rules/react-a11y.ts +295 -0
  14. package/rules/react-hooks.ts +26 -0
  15. package/rules/react.ts +692 -0
  16. package/rules/strict.ts +9 -0
  17. package/rules/style.ts +632 -0
  18. package/rules/typescript.ts +312 -0
  19. package/rules/variables.ts +76 -0
  20. package/tsconfig.json +22 -0
  21. package/typescript/index.ts +7 -0
  22. package/typescript/recommended.ts +30 -0
  23. package/README.md +0 -1
  24. package/dist/base/index.d.ts +0 -842
  25. package/dist/base/index.js +0 -25
  26. package/dist/base/recommended.d.ts +0 -2
  27. package/dist/base/recommended.js +0 -33
  28. package/dist/index.d.ts +0 -2639
  29. package/dist/index.js +0 -20
  30. package/dist/react/index.d.ts +0 -1799
  31. package/dist/react/index.js +0 -15
  32. package/dist/react/recommended.d.ts +0 -2
  33. package/dist/react/recommended.js +0 -19
  34. package/dist/rules/best-practices.d.ts +0 -177
  35. package/dist/rules/best-practices.js +0 -379
  36. package/dist/rules/errors.d.ts +0 -69
  37. package/dist/rules/errors.js +0 -151
  38. package/dist/rules/es6.d.ts +0 -146
  39. package/dist/rules/es6.js +0 -203
  40. package/dist/rules/imports.d.ts +0 -2
  41. package/dist/rules/imports.js +0 -265
  42. package/dist/rules/node.d.ts +0 -90
  43. package/dist/rules/node.js +0 -50
  44. package/dist/rules/react-a11y.d.ts +0 -117
  45. package/dist/rules/react-a11y.js +0 -255
  46. package/dist/rules/react-hooks.d.ts +0 -19
  47. package/dist/rules/react-hooks.js +0 -57
  48. package/dist/rules/react.d.ts +0 -1664
  49. package/dist/rules/react.js +0 -606
  50. package/dist/rules/strict.d.ts +0 -7
  51. package/dist/rules/strict.js +0 -9
  52. package/dist/rules/style.d.ts +0 -320
  53. package/dist/rules/style.js +0 -530
  54. package/dist/rules/variables.d.ts +0 -35
  55. package/dist/rules/variables.js +0 -73
  56. package/dist/utils/index.d.ts +0 -1
  57. package/dist/utils/index.js +0 -4
@@ -0,0 +1,308 @@
1
+ import globals from 'globals';
2
+
3
+ import type { Linter } from 'eslint';
4
+
5
+ // @ts-expect-error eslint-plugin-import not working in import
6
+ // eslint-disable-next-line @typescript-eslint/no-require-imports,unicorn/prefer-module
7
+ const EsLintPluginImport = require('eslint-plugin-import');
8
+
9
+ export const importConfig = {
10
+ name: 'airbnb/config/imports',
11
+ languageOptions: {
12
+ globals: {
13
+ ...globals.es2015,
14
+ },
15
+ parserOptions: {
16
+ ecmaVersion: 6,
17
+ sourceType: 'module',
18
+ },
19
+ },
20
+ settings: {
21
+ 'import/resolver': {
22
+ node: {
23
+ extensions: ['.js', '.cjs', '.mjs', '.json'],
24
+ },
25
+ },
26
+ 'import/extensions': ['.js', '.cjs', '.mjs', '.jsx'],
27
+ 'import/core-modules': [],
28
+ 'import/ignore': ['node_modules', String.raw`\.(coffee|scss|css|less|hbs|svg|json)$`],
29
+ },
30
+ rules: {
31
+ // Static analysis:
32
+
33
+ // ensure imports point to files/modules that can be resolved
34
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
35
+ 'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
36
+
37
+ // ensure named imports coupled with named exports
38
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
39
+ 'import/named': 'error',
40
+
41
+ // ensure default import coupled with default export
42
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
43
+ 'import/default': 'off',
44
+
45
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/namespace.md
46
+ 'import/namespace': 'off',
47
+
48
+ // Helpful warnings:
49
+
50
+ // disallow invalid exports, e.g. multiple defaults
51
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/export.md
52
+ 'import/export': 'error',
53
+
54
+ // do not allow a default import name to match a named export
55
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
56
+ 'import/no-named-as-default': 'error',
57
+
58
+ // warn on accessing default export property names that are also named exports
59
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
60
+ 'import/no-named-as-default-member': 'error',
61
+
62
+ // disallow use of jsdoc-marked-deprecated imports
63
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
64
+ 'import/no-deprecated': 'off',
65
+
66
+ // Forbid the use of extraneous packages
67
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
68
+ // paths are treated both as absolute paths, and relative to process.cwd()
69
+ 'import/no-extraneous-dependencies': [
70
+ 'error',
71
+ {
72
+ devDependencies: [
73
+ 'test/**', // tape, common npm pattern
74
+ 'tests/**', // also common npm pattern
75
+ 'spec/**', // mocha, rspec-like pattern
76
+ '**/__tests__/**', // jest pattern
77
+ '**/__mocks__/**', // jest pattern
78
+ 'test.{js,jsx}', // repos with a single test file
79
+ 'test-*.{js,jsx}', // repos with multiple top-level test files
80
+ '**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test
81
+ '**/jest.config.js', // jest config
82
+ '**/jest.setup.js', // jest setup
83
+ '**/vue.config.js', // vue-cli config
84
+ '**/webpack.config.js', // webpack config
85
+ '**/webpack.config.*.js', // webpack config
86
+ '**/rollup.config.js', // rollup config
87
+ '**/rollup.config.*.js', // rollup config
88
+ '**/gulpfile.js', // gulp config
89
+ '**/gulpfile.*.js', // gulp config
90
+ '**/Gruntfile{,.js}', // grunt config
91
+ '**/protractor.conf.js', // protractor config
92
+ '**/protractor.conf.*.js', // protractor config
93
+ '**/karma.conf.js', // karma config
94
+ '**/.eslintrc.js', // eslint config
95
+ ],
96
+ optionalDependencies: false,
97
+ },
98
+ ],
99
+
100
+ // Forbid mutable exports
101
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
102
+ 'import/no-mutable-exports': 'error',
103
+
104
+ // Module systems:
105
+
106
+ // disallow require()
107
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
108
+ 'import/no-commonjs': 'off',
109
+
110
+ // disallow AMD require/define
111
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-amd.md
112
+ 'import/no-amd': 'error',
113
+
114
+ // No Node.js builtin modules
115
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
116
+ // TODO: enable?
117
+ 'import/no-nodejs-modules': 'off',
118
+
119
+ // Style guide:
120
+
121
+ // disallow non-import statements appearing before import statements
122
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/first.md
123
+ 'import/first': 'error',
124
+
125
+ // disallow non-import statements appearing before import statements
126
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/imports-first.md
127
+ // deprecated: use `import/first`
128
+ 'import/imports-first': 'off',
129
+
130
+ // disallow duplicate imports
131
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
132
+ 'import/no-duplicates': 'error',
133
+
134
+ // disallow namespace imports
135
+ // TODO: enable?
136
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
137
+ 'import/no-namespace': 'off',
138
+
139
+ // Ensure consistent use of file extension within the import path
140
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/extensions.md
141
+ 'import/extensions': [
142
+ 'error',
143
+ 'ignorePackages',
144
+ {
145
+ js: 'never',
146
+ mjs: 'never',
147
+ jsx: 'never',
148
+ },
149
+ ],
150
+
151
+ // ensure absolute imports are above relative imports and that unassigned imports are ignored
152
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/order.md
153
+ // TODO: enforce a stricter convention in module import order?
154
+ 'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
155
+
156
+ // Require a newline after the last import/require in a group
157
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
158
+ 'import/newline-after-import': 'error',
159
+
160
+ // Require modules with a single export to use a default export
161
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
162
+ 'import/prefer-default-export': 'error',
163
+
164
+ // Restrict which files can be imported in a given folder
165
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
166
+ 'import/no-restricted-paths': 'off',
167
+
168
+ // Forbid modules to have too many dependencies
169
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
170
+ 'import/max-dependencies': ['off', { max: 10 }],
171
+
172
+ // Forbid import of modules using absolute paths
173
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
174
+ 'import/no-absolute-path': 'error',
175
+
176
+ // Forbid require() calls with expressions
177
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
178
+ 'import/no-dynamic-require': 'error',
179
+
180
+ // prevent importing the submodules of other modules
181
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
182
+ 'import/no-internal-modules': [
183
+ 'off',
184
+ {
185
+ allow: [],
186
+ },
187
+ ],
188
+
189
+ // Warn if a module could be mistakenly parsed as a script by a consumer
190
+ // leveraging Unambiguous JavaScript Grammar
191
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
192
+ // this should not be enabled until this proposal has at least been *presented* to TC39.
193
+ // At the moment, it's not a thing.
194
+ 'import/unambiguous': 'off',
195
+
196
+ // Forbid Webpack loader syntax in imports
197
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
198
+ 'import/no-webpack-loader-syntax': 'error',
199
+
200
+ // Prevent unassigned imports
201
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
202
+ // importing for side effects is perfectly acceptable, if you need side effects.
203
+ 'import/no-unassigned-import': 'off',
204
+
205
+ // Prevent importing the default as if it were named
206
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
207
+ 'import/no-named-default': 'error',
208
+
209
+ // Reports if a module's default export is unnamed
210
+ // https://github.com/import-js/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
211
+ 'import/no-anonymous-default-export': [
212
+ 'off',
213
+ {
214
+ allowArray: false,
215
+ allowArrowFunction: false,
216
+ allowAnonymousClass: false,
217
+ allowAnonymousFunction: false,
218
+ allowLiteral: false,
219
+ allowObject: false,
220
+ },
221
+ ],
222
+
223
+ // This rule enforces that all exports are declared at the bottom of the file.
224
+ // https://github.com/import-js/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md
225
+ // TODO: enable?
226
+ 'import/exports-last': 'off',
227
+
228
+ // Reports when named exports are not grouped together in a single export declaration
229
+ // or when multiple assignments to CommonJS module.exports or exports object are present
230
+ // in a single file.
231
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md
232
+ 'import/group-exports': 'off',
233
+
234
+ // forbid default exports. this is a terrible rule, do not use it.
235
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md
236
+ 'import/no-default-export': 'off',
237
+
238
+ // Prohibit named exports. this is a terrible rule, do not use it.
239
+ // https://github.com/import-js/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md
240
+ 'import/no-named-export': 'off',
241
+
242
+ // Forbid a module from importing itself
243
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md
244
+ 'import/no-self-import': 'error',
245
+
246
+ // Forbid cyclical dependencies between modules
247
+ // https://github.com/import-js/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md
248
+ 'import/no-cycle': ['error', { maxDepth: '∞' }],
249
+
250
+ // Ensures that there are no useless path segments
251
+ // https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md
252
+ 'import/no-useless-path-segments': ['error', { commonjs: true }],
253
+
254
+ // dynamic imports require a leading comment with a webpackChunkName
255
+ // https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md
256
+ 'import/dynamic-import-chunkname': [
257
+ 'off',
258
+ {
259
+ importFunctions: [],
260
+ webpackChunknameFormat: '[0-9a-zA-Z-_/.]+',
261
+ },
262
+ ],
263
+
264
+ // Use this rule to prevent imports to folders in relative parent paths.
265
+ // https://github.com/import-js/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md
266
+ 'import/no-relative-parent-imports': 'off',
267
+
268
+ // Reports modules without any exports, or with unused exports
269
+ // https://github.com/import-js/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
270
+ // TODO: enable once it supports CJS
271
+ 'import/no-unused-modules': [
272
+ 'off',
273
+ {
274
+ ignoreExports: [],
275
+ missingExports: true,
276
+ unusedExports: true,
277
+ },
278
+ ],
279
+
280
+ // Reports the use of import declarations with CommonJS exports in any module except for the main module.
281
+ // https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md
282
+ 'import/no-import-module-exports': [
283
+ 'error',
284
+ {
285
+ exceptions: [],
286
+ },
287
+ ],
288
+
289
+ // Use this rule to prevent importing packages through relative paths.
290
+ // https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md
291
+ 'import/no-relative-packages': 'error',
292
+
293
+ // enforce a consistent style for type specifiers (inline or top-level)
294
+ // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/consistent-type-specifier-style.md
295
+ // TODO, semver-major: enable (just in case)
296
+ 'import/consistent-type-specifier-style': ['off', 'prefer-inline'],
297
+
298
+ // Reports the use of empty named import blocks.
299
+ // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/no-empty-named-blocks.md
300
+ // TODO, semver-minor: enable
301
+ 'import/no-empty-named-blocks': 'off',
302
+ },
303
+ } satisfies Linter.Config;
304
+
305
+ export default {
306
+ ...EsLintPluginImport.flatConfigs.recommended,
307
+ ...importConfig,
308
+ } satisfies Linter.Config;
package/rules/node.ts ADDED
@@ -0,0 +1,49 @@
1
+ import globals from 'globals';
2
+
3
+ import type { Linter } from 'eslint';
4
+
5
+ export default {
6
+ name: 'airbnb/config/node',
7
+ languageOptions: {
8
+ globals: {
9
+ ...globals.nodeBuiltin,
10
+ },
11
+ },
12
+ rules: {
13
+ // enforce return after a callback
14
+ 'callback-return': 'off',
15
+
16
+ // require all requires be top-level
17
+ // https://eslint.org/docs/rules/global-require
18
+ 'global-require': 'error',
19
+
20
+ // enforces error handling in callbacks (node environment)
21
+ 'handle-callback-err': 'off',
22
+
23
+ // disallow use of the Buffer() constructor
24
+ // https://eslint.org/docs/rules/no-buffer-constructor
25
+ 'no-buffer-constructor': 'error',
26
+
27
+ // disallow mixing regular variable and require declarations
28
+ 'no-mixed-requires': ['off', false],
29
+
30
+ // disallow use of new operator with the require function
31
+ 'no-new-require': 'error',
32
+
33
+ // disallow string concatenation with __dirname and __filename
34
+ // https://eslint.org/docs/rules/no-path-concat
35
+ 'no-path-concat': 'error',
36
+
37
+ // disallow use of process.env
38
+ 'no-process-env': 'off',
39
+
40
+ // disallow process.exit()
41
+ 'no-process-exit': 'off',
42
+
43
+ // restrict usage of specified node modules
44
+ 'no-restricted-modules': 'off',
45
+
46
+ // disallow use of synchronous methods (off by default)
47
+ 'no-sync': 'off',
48
+ },
49
+ } satisfies Linter.Config;
@@ -0,0 +1,295 @@
1
+ import type { Linter } from 'eslint';
2
+
3
+ // @ts-expect-error eslint-plugin-import not working in import
4
+ // eslint-disable-next-line @typescript-eslint/no-require-imports,unicorn/prefer-module
5
+ const EsLintPluginJSXA11y = require('eslint-plugin-jsx-a11y');
6
+
7
+ export default {
8
+ name: 'airbnb/config/react-a11y',
9
+ plugins: {
10
+ 'jsx-a11y': EsLintPluginJSXA11y,
11
+ },
12
+ languageOptions: {
13
+ parserOptions: {
14
+ ecmaFeatures: {
15
+ jsx: true,
16
+ },
17
+ },
18
+ },
19
+ rules: {
20
+ // ensure emoji are accessible
21
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md
22
+ // disabled; rule is deprecated
23
+ 'jsx-a11y/accessible-emoji': 'off',
24
+
25
+ // Enforce that all elements that require alternative text have meaningful information
26
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
27
+ 'jsx-a11y/alt-text': [
28
+ 'error',
29
+ {
30
+ elements: ['img', 'object', 'area', 'input[type="image"]'],
31
+ img: [],
32
+ object: [],
33
+ area: [],
34
+ 'input[type="image"]': [],
35
+ },
36
+ ],
37
+
38
+ // Enforce that anchors have content
39
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
40
+ 'jsx-a11y/anchor-has-content': ['error', { components: [] }],
41
+
42
+ // ensure <a> tags are valid
43
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md
44
+ 'jsx-a11y/anchor-is-valid': [
45
+ 'error',
46
+ {
47
+ components: ['Link'],
48
+ specialLink: ['to'],
49
+ aspects: ['noHref', 'invalidHref', 'preferButton'],
50
+ },
51
+ ],
52
+
53
+ // elements with aria-activedescendant must be tabbable
54
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md
55
+ 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
56
+
57
+ // Enforce all aria-* props are valid.
58
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
59
+ 'jsx-a11y/aria-props': 'error',
60
+
61
+ // Enforce ARIA state and property values are valid.
62
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
63
+ 'jsx-a11y/aria-proptypes': 'error',
64
+
65
+ // Require ARIA roles to be valid and non-abstract
66
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
67
+ 'jsx-a11y/aria-role': ['error', { ignoreNonDOM: false }],
68
+
69
+ // Enforce that elements that do not support ARIA roles, states, and
70
+ // properties do not have those attributes.
71
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
72
+ 'jsx-a11y/aria-unsupported-elements': 'error',
73
+
74
+ // Ensure the autocomplete attribute is correct and suitable for the form field it is used with
75
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/29c68596b15c4ff0a40daae6d4a2670e36e37d35/docs/rules/autocomplete-valid.md
76
+ 'jsx-a11y/autocomplete-valid': [
77
+ 'off',
78
+ {
79
+ inputComponents: [],
80
+ },
81
+ ],
82
+
83
+ // require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress
84
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
85
+ 'jsx-a11y/click-events-have-key-events': 'error',
86
+
87
+ // Enforce that a control (an interactive element) has a text label.
88
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md
89
+ 'jsx-a11y/control-has-associated-label': [
90
+ 'error',
91
+ {
92
+ labelAttributes: ['label'],
93
+ controlComponents: [],
94
+ ignoreElements: ['audio', 'canvas', 'embed', 'input', 'textarea', 'tr', 'video'],
95
+ ignoreRoles: [
96
+ 'grid',
97
+ 'listbox',
98
+ 'menu',
99
+ 'menubar',
100
+ 'radiogroup',
101
+ 'row',
102
+ 'tablist',
103
+ 'toolbar',
104
+ 'tree',
105
+ 'treegrid',
106
+ ],
107
+ depth: 5,
108
+ },
109
+ ],
110
+
111
+ // ensure <hX> tags have content and are not aria-hidden
112
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
113
+ 'jsx-a11y/heading-has-content': ['error', { components: [''] }],
114
+
115
+ // require HTML elements to have a "lang" prop
116
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
117
+ 'jsx-a11y/html-has-lang': 'error',
118
+
119
+ // ensure iframe elements have a unique title
120
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md
121
+ 'jsx-a11y/iframe-has-title': 'error',
122
+
123
+ // Prevent img alt text from containing redundant words like "image", "picture", or "photo"
124
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
125
+ 'jsx-a11y/img-redundant-alt': 'error',
126
+
127
+ // Elements with an interactive role and interaction handlers must be focusable
128
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md
129
+ 'jsx-a11y/interactive-supports-focus': 'error',
130
+
131
+ // Enforce that a label tag has a text label and an associated control.
132
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md
133
+ 'jsx-a11y/label-has-associated-control': [
134
+ 'error',
135
+ {
136
+ labelComponents: [],
137
+ labelAttributes: [],
138
+ controlComponents: [],
139
+ assert: 'both',
140
+ depth: 25,
141
+ },
142
+ ],
143
+
144
+ // require HTML element's lang prop to be valid
145
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
146
+ 'jsx-a11y/lang': 'error',
147
+
148
+ // media elements must have captions
149
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md
150
+ 'jsx-a11y/media-has-caption': [
151
+ 'error',
152
+ {
153
+ audio: [],
154
+ video: [],
155
+ track: [],
156
+ },
157
+ ],
158
+
159
+ // require that mouseover/out come with focus/blur, for keyboard-only users
160
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
161
+ 'jsx-a11y/mouse-events-have-key-events': 'error',
162
+
163
+ // Prevent use of `accessKey`
164
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
165
+ 'jsx-a11y/no-access-key': 'error',
166
+
167
+ // prohibit autoFocus prop
168
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md
169
+ 'jsx-a11y/no-autofocus': ['error', { ignoreNonDOM: true }],
170
+
171
+ // prevent distracting elements, like <marquee> and <blink>
172
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md
173
+ 'jsx-a11y/no-distracting-elements': [
174
+ 'error',
175
+ {
176
+ elements: ['marquee', 'blink'],
177
+ },
178
+ ],
179
+
180
+ // WAI-ARIA roles should not be used to convert an interactive element to non-interactive
181
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md
182
+ 'jsx-a11y/no-interactive-element-to-noninteractive-role': [
183
+ 'error',
184
+ {
185
+ tr: ['none', 'presentation'],
186
+ },
187
+ ],
188
+
189
+ // A non-interactive element does not support event handlers (mouse and key handlers)
190
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md
191
+ 'jsx-a11y/no-noninteractive-element-interactions': [
192
+ 'error',
193
+ {
194
+ handlers: ['onClick', 'onMouseDown', 'onMouseUp', 'onKeyPress', 'onKeyDown', 'onKeyUp'],
195
+ },
196
+ ],
197
+
198
+ // WAI-ARIA roles should not be used to convert a non-interactive element to interactive
199
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md
200
+ 'jsx-a11y/no-noninteractive-element-to-interactive-role': [
201
+ 'error',
202
+ {
203
+ ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
204
+ ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
205
+ li: ['menuitem', 'option', 'row', 'tab', 'treeitem'],
206
+ table: ['grid'],
207
+ td: ['gridcell'],
208
+ },
209
+ ],
210
+
211
+ // Tab key navigation should be limited to elements on the page that can be interacted with.
212
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md
213
+ 'jsx-a11y/no-noninteractive-tabindex': [
214
+ 'error',
215
+ {
216
+ tags: [],
217
+ roles: ['tabpanel'],
218
+ allowExpressionValues: true,
219
+ },
220
+ ],
221
+
222
+ // require onBlur instead of onChange
223
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
224
+ 'jsx-a11y/no-onchange': 'off',
225
+
226
+ // ensure HTML elements do not specify redundant ARIA roles
227
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md
228
+ 'jsx-a11y/no-redundant-roles': [
229
+ 'error',
230
+ {
231
+ nav: ['navigation'],
232
+ },
233
+ ],
234
+
235
+ // Enforce that DOM elements without semantic behavior not have interaction handlers
236
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
237
+ 'jsx-a11y/no-static-element-interactions': [
238
+ 'error',
239
+ {
240
+ handlers: ['onClick', 'onMouseDown', 'onMouseUp', 'onKeyPress', 'onKeyDown', 'onKeyUp'],
241
+ },
242
+ ],
243
+
244
+ // Enforce that elements with ARIA roles must have all required attributes
245
+ // for that role.
246
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
247
+ 'jsx-a11y/role-has-required-aria-props': 'error',
248
+
249
+ // Enforce that elements with explicit or implicit roles defined contain
250
+ // only aria-* properties supported by that role.
251
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
252
+ 'jsx-a11y/role-supports-aria-props': 'error',
253
+
254
+ // only allow <th> to have the "scope" attr
255
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
256
+ 'jsx-a11y/scope': 'error',
257
+
258
+ // Enforce tabIndex value is not greater than zero.
259
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
260
+ 'jsx-a11y/tabindex-no-positive': 'error',
261
+
262
+ // ----------------------------------------------------
263
+ // Rules that no longer exist in eslint-plugin-jsx-a11y
264
+ // ----------------------------------------------------
265
+
266
+ // require that JSX labels use "htmlFor"
267
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
268
+ // deprecated: replaced by `label-has-associated-control` rule
269
+ 'jsx-a11y/label-has-for': [
270
+ 'off',
271
+ {
272
+ components: [],
273
+ required: {
274
+ every: ['nesting', 'id'],
275
+ },
276
+ allowChildren: false,
277
+ },
278
+ ],
279
+
280
+ // Ensures anchor text is not ambiguous
281
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/anchor-ambiguous-text.md
282
+ // TODO: semver-major, enable
283
+ 'jsx-a11y/anchor-ambiguous-text': 'off',
284
+
285
+ // Enforce that aria-hidden="true" is not set on focusable elements.
286
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/no-aria-hidden-on-focusable.md
287
+ // TODO: semver-major, enable
288
+ 'jsx-a11y/no-aria-hidden-on-focusable': 'off',
289
+
290
+ // Enforces using semantic DOM elements over the ARIA role property.
291
+ // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/prefer-tag-over-role.md
292
+ // TODO: semver-major, enable
293
+ 'jsx-a11y/prefer-tag-over-role': 'off',
294
+ },
295
+ } satisfies Linter.Config;