@qlik/eslint-config 0.8.2 → 1.0.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.
- package/README.md +137 -80
- package/package.json +33 -39
- package/src/configs/cjs.js +45 -0
- package/src/configs/esm.js +43 -0
- package/src/configs/jest.js +24 -0
- package/src/configs/playwright.js +19 -0
- package/src/configs/react.js +75 -0
- package/src/configs/recommended.js +64 -0
- package/src/configs/rules/eslint-core.js +970 -0
- package/src/configs/rules/import-x.js +159 -0
- package/src/configs/rules/index.js +17 -0
- package/src/configs/rules/node.js +10 -0
- package/src/configs/rules/react-a11y.js +232 -0
- package/src/configs/rules/react-hooks.js +16 -0
- package/src/configs/rules/react.js +479 -0
- package/src/configs/rules/svelte.js +11 -0
- package/src/configs/rules/testing-library.js +74 -0
- package/src/configs/rules/typescript.js +228 -0
- package/src/configs/svelte.js +48 -0
- package/src/configs/vitest.js +36 -0
- package/src/index.d.ts +24 -0
- package/src/index.js +29 -0
- package/src/types/index.ts +52 -0
- package/src/utils/compose.js +62 -0
- package/src/utils/config.js +22 -0
- package/src/utils/merge.js +28 -0
- package/configs/airbnb-base-mod.js +0 -77
- package/configs/airbnb-mod.js +0 -17
- package/configs/airbnb-ts-base-mod.js +0 -37
- package/configs/airbnb-ts-mod.js +0 -17
- package/configs/env.js +0 -11
- package/esm.js +0 -6
- package/index.js +0 -10
- package/jest.js +0 -25
- package/node.js +0 -10
- package/overrides/react.js +0 -27
- package/overrides/sveltejs.js +0 -25
- package/overrides/sveltets.js +0 -32
- package/overrides/ts.js +0 -23
- package/playwright.js +0 -12
- package/react-svelte.js +0 -6
- package/react.js +0 -3
- package/svelte-js.js +0 -6
- package/svelte.js +0 -6
- package/vitest.js +0 -13
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
|
|
5
|
+
*
|
|
6
|
+
* eslint-plugin-import-x package https://github.com/un-ts/eslint-plugin-import-x/blob/master/README.md
|
|
7
|
+
*/
|
|
8
|
+
const rules = {
|
|
9
|
+
// modify rules from eslint-plugin-import-x here
|
|
10
|
+
/* -------------------------------------------------------------------------- */
|
|
11
|
+
/* Static analysis: */
|
|
12
|
+
/* -------------------------------------------------------------------------- */
|
|
13
|
+
// ensure imports point to files/modules that can be resolved
|
|
14
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
|
|
15
|
+
"import-x/no-unresolved": ["error", { commonjs: true, caseSensitive: true }],
|
|
16
|
+
// ensure named imports coupled with named exports
|
|
17
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/named.md#when-not-to-use-it
|
|
18
|
+
"import-x/named": "error",
|
|
19
|
+
/* -------------------------------------------------------------------------- */
|
|
20
|
+
/* Helpful warnings: */
|
|
21
|
+
/* -------------------------------------------------------------------------- */
|
|
22
|
+
// disallow invalid exports, e.g. multiple defaults
|
|
23
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/export.md
|
|
24
|
+
"import-x/export": "error",
|
|
25
|
+
// do not allow a default import name to match a named export
|
|
26
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default.md
|
|
27
|
+
"import-x/no-named-as-default": "error",
|
|
28
|
+
// warn on accessing default export property names that are also named exports
|
|
29
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default-member.md
|
|
30
|
+
"import-x/no-named-as-default-member": "error",
|
|
31
|
+
// disallow use of jsdoc-marked-deprecated imports
|
|
32
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-deprecated.md
|
|
33
|
+
"import-x/no-deprecated": "warn",
|
|
34
|
+
|
|
35
|
+
// Can depend on bundler setup, and other things. Disabling for now.
|
|
36
|
+
// Forbid the use of extraneous packages
|
|
37
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-extraneous-dependencies.md
|
|
38
|
+
// paths are treated both as absolute paths, and relative to process.cwd()
|
|
39
|
+
"import-x/no-extraneous-dependencies": [
|
|
40
|
+
"off",
|
|
41
|
+
{
|
|
42
|
+
devDependencies: [
|
|
43
|
+
"**/test*/**",
|
|
44
|
+
"**/mocks/**",
|
|
45
|
+
"**/mock/**",
|
|
46
|
+
"test/**", // tape, common npm pattern
|
|
47
|
+
"tests/**", // also common npm pattern
|
|
48
|
+
"spec/**", // mocha, rspec-like pattern
|
|
49
|
+
"**/__tests__/**", // jest pattern
|
|
50
|
+
"**/__mocks__/**", // jest pattern
|
|
51
|
+
"test.{js,jsx,ts,tsx}", // repos with a single test file
|
|
52
|
+
"test-*.{js,jsx,ts,tsx}", // repos with multiple top-level test files
|
|
53
|
+
"**/*{.,_}{test,spec}.{js,jsx,ts,tsx}", // tests where the extension or filename suffix denotes that it is a test
|
|
54
|
+
"**/jest.config.{cjs,mjs,js,ts}", // jest config
|
|
55
|
+
"**/jest.setup.{cjs,mjs,js,ts}", // jest setup
|
|
56
|
+
"**/vitest.config.{cjs,mjs,js,ts}", // vitest config
|
|
57
|
+
"**/vue.config.{cjs,mjs,js,ts}", // vue-cli config
|
|
58
|
+
"**/svelte.config.{cjs,mjs,js,ts}", // svelte config
|
|
59
|
+
"**/tsup.config.{cjs,mjs,js,ts}", // tsup config
|
|
60
|
+
"**/playwright.config.{cjs,mjs,js,ts}", // playwright config
|
|
61
|
+
"**/webpack.config.{cjs,mjs,js,ts}", // webpack config
|
|
62
|
+
"**/webpack.mod.{cjs,mjs,js,ts}", // webpack config
|
|
63
|
+
"**/rollup.config.{cjs,mjs,js,ts}", // rollup config
|
|
64
|
+
"**/rollup.config.*cjs,mjs,.{js,ts}", // rollup config
|
|
65
|
+
"**/protractor.conf.{cjs,mjs,js,ts}", // protractor config
|
|
66
|
+
"**/protractor.conf.*.{cjs,mjs,js,ts}", // protractor config
|
|
67
|
+
"**/.eslintrc.{cjs,mjs,js,ts}", // eslint config
|
|
68
|
+
"**/eslint.config.{cjs,mjs,js,ts}", // eslint config
|
|
69
|
+
"**/.prettierrc.{cjs,mjs,js,ts}", // prettier config
|
|
70
|
+
"**/.prettierrc", // prettier config
|
|
71
|
+
],
|
|
72
|
+
optionalDependencies: false,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
// Forbid mutable exports
|
|
76
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-mutable-exports.md
|
|
77
|
+
"import-x/no-mutable-exports": "error",
|
|
78
|
+
/* -------------------------------------------------------------------------- */
|
|
79
|
+
/* Module systems: */
|
|
80
|
+
/* -------------------------------------------------------------------------- */
|
|
81
|
+
// disallow AMD require/define
|
|
82
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-amd.md
|
|
83
|
+
"import-x/no-amd": "error",
|
|
84
|
+
// No Node.js builtin modules
|
|
85
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-nodejs-modules.md
|
|
86
|
+
// TODO: enable?
|
|
87
|
+
"import-x/no-nodejs-modules": "off",
|
|
88
|
+
/* -------------------------------------------------------------------------- */
|
|
89
|
+
/* Style guide: */
|
|
90
|
+
/* -------------------------------------------------------------------------- */
|
|
91
|
+
// disallow duplicate imports
|
|
92
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-duplicates.md
|
|
93
|
+
"import-x/no-duplicates": "error",
|
|
94
|
+
// Ensure consistent use of file extension within the import path
|
|
95
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md
|
|
96
|
+
"import-x/extensions": [
|
|
97
|
+
"error",
|
|
98
|
+
"ignorePackages",
|
|
99
|
+
{
|
|
100
|
+
js: "never",
|
|
101
|
+
mjs: "never",
|
|
102
|
+
jsx: "never",
|
|
103
|
+
ts: "never",
|
|
104
|
+
mts: "never",
|
|
105
|
+
tsx: "never",
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
// Require a newline after the last import-x/require in a group
|
|
109
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/newline-after-import.md
|
|
110
|
+
"import-x/newline-after-import": "error",
|
|
111
|
+
// Require modules with a single export to use a default export
|
|
112
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/prefer-default-export.md
|
|
113
|
+
"import-x/prefer-default-export": "off",
|
|
114
|
+
// Forbid import of modules using absolute paths
|
|
115
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-absolute-path.md
|
|
116
|
+
"import-x/no-absolute-path": "error",
|
|
117
|
+
// Forbid require() calls with expressions
|
|
118
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-dynamic-require.md
|
|
119
|
+
"import-x/no-dynamic-require": "error",
|
|
120
|
+
// Forbid Webpack loader syntax in imports
|
|
121
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-webpack-loader-syntax.md
|
|
122
|
+
"import-x/no-webpack-loader-syntax": "error",
|
|
123
|
+
// Prevent importing the default as if it were named
|
|
124
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-default.md
|
|
125
|
+
"import-x/no-named-default": "error",
|
|
126
|
+
// Forbid a module from importing itself
|
|
127
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-self-import.md
|
|
128
|
+
"import-x/no-self-import": "error",
|
|
129
|
+
// Forbid cyclical dependencies between modules
|
|
130
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-cycle.md
|
|
131
|
+
"import-x/no-cycle": ["error", { maxDepth: "∞" }],
|
|
132
|
+
// Ensures that there are no useless path segments
|
|
133
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-useless-path-segments.md
|
|
134
|
+
"import-x/no-useless-path-segments": ["error", { commonjs: true }],
|
|
135
|
+
// Reports modules without any exports, or with unused exports
|
|
136
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unused-modules.md
|
|
137
|
+
"import-x/no-unused-modules": "error",
|
|
138
|
+
// Reports the use of import declarations with CommonJS exports in any module except for the main module.
|
|
139
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-import-module-exports.md
|
|
140
|
+
"import-x/no-import-module-exports": [
|
|
141
|
+
"error",
|
|
142
|
+
{
|
|
143
|
+
exceptions: [],
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
// Use this rule to prevent importing packages through relative paths.
|
|
147
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-packages-exports.md
|
|
148
|
+
"import-x/no-relative-packages": "error",
|
|
149
|
+
// This seems conflicting with @typescript-eslint/no-import-type-side-effects
|
|
150
|
+
// enforce a consistent style for type specifiers (inline or top-level)
|
|
151
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/consistent-type-specifier-style.md
|
|
152
|
+
"import-x/consistent-type-specifier-style": "off",
|
|
153
|
+
// Makes importing runtime (`import type {} from ...`) types annoying
|
|
154
|
+
// Reports the use of empty named import blocks.
|
|
155
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-empty-named-blocks.md
|
|
156
|
+
"import-x/no-empty-named-blocks": "off",
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export default rules;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import eslintCoreRules from "./eslint-core.js";
|
|
2
|
+
import importXRules from "./import-x.js";
|
|
3
|
+
import reactA11yRules from "./react-a11y.js";
|
|
4
|
+
import reactHooksRules from "./react-hooks.js";
|
|
5
|
+
import reactRules from "./react.js";
|
|
6
|
+
import testingLibraryRules from "./testing-library.js";
|
|
7
|
+
import typescriptRules from "./typescript.js";
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
importXRules,
|
|
11
|
+
eslintCoreRules,
|
|
12
|
+
typescriptRules,
|
|
13
|
+
reactRules,
|
|
14
|
+
reactA11yRules,
|
|
15
|
+
reactHooksRules,
|
|
16
|
+
testingLibraryRules,
|
|
17
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
|
|
5
|
+
*/
|
|
6
|
+
const rules = {
|
|
7
|
+
// Enforce that all elements that require alternative text have meaningful information
|
|
8
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
|
|
9
|
+
"jsx-a11y/alt-text": [
|
|
10
|
+
"error",
|
|
11
|
+
{
|
|
12
|
+
elements: ["img", "object", "area", 'input[type="image"]'],
|
|
13
|
+
img: [],
|
|
14
|
+
object: [],
|
|
15
|
+
area: [],
|
|
16
|
+
'input[type="image"]': [],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
|
|
20
|
+
// Enforce that anchors have content
|
|
21
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
|
|
22
|
+
"jsx-a11y/anchor-has-content": ["error", { components: [] }],
|
|
23
|
+
|
|
24
|
+
// ensure <a> tags are valid
|
|
25
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md
|
|
26
|
+
"jsx-a11y/anchor-is-valid": [
|
|
27
|
+
"error",
|
|
28
|
+
{
|
|
29
|
+
components: ["Link"],
|
|
30
|
+
specialLink: ["to"],
|
|
31
|
+
aspects: ["noHref", "invalidHref", "preferButton"],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
|
|
35
|
+
// elements with aria-activedescendant must be tabbable
|
|
36
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md
|
|
37
|
+
"jsx-a11y/aria-activedescendant-has-tabindex": "error",
|
|
38
|
+
|
|
39
|
+
// Enforce all aria-* props are valid.
|
|
40
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
|
|
41
|
+
"jsx-a11y/aria-props": "error",
|
|
42
|
+
|
|
43
|
+
// Enforce ARIA state and property values are valid.
|
|
44
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
|
|
45
|
+
"jsx-a11y/aria-proptypes": "error",
|
|
46
|
+
|
|
47
|
+
// Require ARIA roles to be valid and non-abstract
|
|
48
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
|
|
49
|
+
"jsx-a11y/aria-role": ["error", { ignoreNonDOM: false }],
|
|
50
|
+
|
|
51
|
+
// Enforce that elements that do not support ARIA roles, states, and
|
|
52
|
+
// properties do not have those attributes.
|
|
53
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
|
|
54
|
+
"jsx-a11y/aria-unsupported-elements": "error",
|
|
55
|
+
|
|
56
|
+
// require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress
|
|
57
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
|
|
58
|
+
"jsx-a11y/click-events-have-key-events": "error",
|
|
59
|
+
|
|
60
|
+
// Enforce that a control (an interactive element) has a text label.
|
|
61
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md
|
|
62
|
+
"jsx-a11y/control-has-associated-label": [
|
|
63
|
+
"error",
|
|
64
|
+
{
|
|
65
|
+
labelAttributes: ["label"],
|
|
66
|
+
controlComponents: [],
|
|
67
|
+
ignoreElements: ["audio", "canvas", "embed", "input", "textarea", "tr", "video"],
|
|
68
|
+
ignoreRoles: [
|
|
69
|
+
"grid",
|
|
70
|
+
"listbox",
|
|
71
|
+
"menu",
|
|
72
|
+
"menubar",
|
|
73
|
+
"radiogroup",
|
|
74
|
+
"row",
|
|
75
|
+
"tablist",
|
|
76
|
+
"toolbar",
|
|
77
|
+
"tree",
|
|
78
|
+
"treegrid",
|
|
79
|
+
],
|
|
80
|
+
depth: 5,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
|
|
84
|
+
// ensure <hX> tags have content and are not aria-hidden
|
|
85
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
|
|
86
|
+
"jsx-a11y/heading-has-content": ["error", { components: [""] }],
|
|
87
|
+
|
|
88
|
+
// require HTML elements to have a "lang" prop
|
|
89
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
|
|
90
|
+
"jsx-a11y/html-has-lang": "error",
|
|
91
|
+
|
|
92
|
+
// ensure iframe elements have a unique title
|
|
93
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md
|
|
94
|
+
"jsx-a11y/iframe-has-title": "error",
|
|
95
|
+
|
|
96
|
+
// Prevent img alt text from containing redundant words like "image", "picture", or "photo"
|
|
97
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
|
|
98
|
+
"jsx-a11y/img-redundant-alt": "error",
|
|
99
|
+
|
|
100
|
+
// Elements with an interactive role and interaction handlers must be focusable
|
|
101
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md
|
|
102
|
+
"jsx-a11y/interactive-supports-focus": "error",
|
|
103
|
+
|
|
104
|
+
// Enforce that a label tag has a text label and an associated control.
|
|
105
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md
|
|
106
|
+
"jsx-a11y/label-has-associated-control": [
|
|
107
|
+
"error",
|
|
108
|
+
{
|
|
109
|
+
labelComponents: [],
|
|
110
|
+
labelAttributes: [],
|
|
111
|
+
controlComponents: [],
|
|
112
|
+
assert: "both",
|
|
113
|
+
depth: 25,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
|
|
117
|
+
// require HTML element's lang prop to be valid
|
|
118
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
|
|
119
|
+
"jsx-a11y/lang": "error",
|
|
120
|
+
|
|
121
|
+
// media elements must have captions
|
|
122
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md
|
|
123
|
+
"jsx-a11y/media-has-caption": [
|
|
124
|
+
"error",
|
|
125
|
+
{
|
|
126
|
+
audio: [],
|
|
127
|
+
video: [],
|
|
128
|
+
track: [],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
|
|
132
|
+
// require that mouseover/out come with focus/blur, for keyboard-only users
|
|
133
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
|
|
134
|
+
"jsx-a11y/mouse-events-have-key-events": "error",
|
|
135
|
+
|
|
136
|
+
// Prevent use of `accessKey`
|
|
137
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
|
|
138
|
+
"jsx-a11y/no-access-key": "error",
|
|
139
|
+
|
|
140
|
+
// prohibit autoFocus prop
|
|
141
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md
|
|
142
|
+
"jsx-a11y/no-autofocus": ["error", { ignoreNonDOM: true }],
|
|
143
|
+
|
|
144
|
+
// prevent distracting elements, like <marquee> and <blink>
|
|
145
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md
|
|
146
|
+
"jsx-a11y/no-distracting-elements": [
|
|
147
|
+
"error",
|
|
148
|
+
{
|
|
149
|
+
elements: ["marquee", "blink"],
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
|
|
153
|
+
// WAI-ARIA roles should not be used to convert an interactive element to non-interactive
|
|
154
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md
|
|
155
|
+
"jsx-a11y/no-interactive-element-to-noninteractive-role": [
|
|
156
|
+
"error",
|
|
157
|
+
{
|
|
158
|
+
tr: ["none", "presentation"],
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
|
|
162
|
+
// A non-interactive element does not support event handlers (mouse and key handlers)
|
|
163
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md
|
|
164
|
+
"jsx-a11y/no-noninteractive-element-interactions": [
|
|
165
|
+
"error",
|
|
166
|
+
{
|
|
167
|
+
handlers: ["onClick", "onMouseDown", "onMouseUp", "onKeyPress", "onKeyDown", "onKeyUp"],
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
|
|
171
|
+
// WAI-ARIA roles should not be used to convert a non-interactive element to interactive
|
|
172
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md
|
|
173
|
+
"jsx-a11y/no-noninteractive-element-to-interactive-role": [
|
|
174
|
+
"error",
|
|
175
|
+
{
|
|
176
|
+
ul: ["listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid"],
|
|
177
|
+
ol: ["listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid"],
|
|
178
|
+
li: ["menuitem", "option", "row", "tab", "treeitem"],
|
|
179
|
+
table: ["grid"],
|
|
180
|
+
td: ["gridcell"],
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
|
|
184
|
+
// Tab key navigation should be limited to elements on the page that can be interacted with.
|
|
185
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md
|
|
186
|
+
"jsx-a11y/no-noninteractive-tabindex": [
|
|
187
|
+
"error",
|
|
188
|
+
{
|
|
189
|
+
tags: [],
|
|
190
|
+
roles: ["tabpanel"],
|
|
191
|
+
allowExpressionValues: true,
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
|
|
195
|
+
// ensure HTML elements do not specify redundant ARIA roles
|
|
196
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md
|
|
197
|
+
"jsx-a11y/no-redundant-roles": [
|
|
198
|
+
"error",
|
|
199
|
+
{
|
|
200
|
+
nav: ["navigation"],
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
|
|
204
|
+
// Enforce that DOM elements without semantic behavior not have interaction handlers
|
|
205
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
|
|
206
|
+
"jsx-a11y/no-static-element-interactions": [
|
|
207
|
+
"error",
|
|
208
|
+
{
|
|
209
|
+
handlers: ["onClick", "onMouseDown", "onMouseUp", "onKeyPress", "onKeyDown", "onKeyUp"],
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
|
|
213
|
+
// Enforce that elements with ARIA roles must have all required attributes
|
|
214
|
+
// for that role.
|
|
215
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
|
|
216
|
+
"jsx-a11y/role-has-required-aria-props": "error",
|
|
217
|
+
|
|
218
|
+
// Enforce that elements with explicit or implicit roles defined contain
|
|
219
|
+
// only aria-* properties supported by that role.
|
|
220
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
|
|
221
|
+
"jsx-a11y/role-supports-aria-props": "error",
|
|
222
|
+
|
|
223
|
+
// only allow <th> to have the "scope" attr
|
|
224
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
|
|
225
|
+
"jsx-a11y/scope": "error",
|
|
226
|
+
|
|
227
|
+
// Enforce tabIndex value is not greater than zero.
|
|
228
|
+
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
|
|
229
|
+
"jsx-a11y/tabindex-no-positive": "error",
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export default rules;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
|
|
5
|
+
*/
|
|
6
|
+
const rules = {
|
|
7
|
+
// Enforce Rules of Hooks
|
|
8
|
+
// https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
|
|
9
|
+
"react-hooks/rules-of-hooks": "error",
|
|
10
|
+
|
|
11
|
+
// Verify the list of the dependencies for Hooks like useEffect and similar
|
|
12
|
+
// https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
|
|
13
|
+
"react-hooks/exhaustive-deps": "error",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default rules;
|