@innovixx/eslint-config 4.0.0 → 5.0.0-alpha.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.
@@ -315,7 +315,18 @@ const bestPracticesRules = {
315
315
  'no-void': 'error',
316
316
 
317
317
  // disallow usage of configurable warning terms in comments: e.g. todo
318
- 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
318
+ 'no-warning-comments': [
319
+ 'error',
320
+ {
321
+ terms: [
322
+ 'DONOTCOMMIT',
323
+ 'DO_NOT_COMMIT',
324
+ 'DO-NOT-COMMIT',
325
+ 'DO NOT COMMIT',
326
+ ],
327
+ location: 'anywhere',
328
+ },
329
+ ],
319
330
 
320
331
  // disallow use of the with statement
321
332
  'no-with': 'error',
@@ -24,7 +24,19 @@ export const graphqlConfig = [
24
24
  },
25
25
 
26
26
  rules: {
27
- 'eol-last': 'warn',
27
+ 'eol-last': 'error',
28
+ 'no-warning-comments': [
29
+ 'error',
30
+ {
31
+ terms: [
32
+ 'DONOTCOMMIT',
33
+ 'DO_NOT_COMMIT',
34
+ 'DO-NOT-COMMIT',
35
+ 'DO NOT COMMIT',
36
+ ],
37
+ location: 'anywhere',
38
+ },
39
+ ],
28
40
  },
29
41
  },
30
42
  {
@@ -1,6 +1,6 @@
1
1
  import eslintReact from '@eslint-react/eslint-plugin';
2
2
  import stylistic from '@stylistic/eslint-plugin';
3
- import jsxA11y from 'eslint-plugin-jsx-a11y';
3
+ import jsxA11yX from 'eslint-plugin-jsx-a11y-x';
4
4
  import reactHooks from 'eslint-plugin-react-hooks';
5
5
  import globals from 'globals';
6
6
  import reactRules from './rules/react.mjs';
@@ -25,7 +25,7 @@ export const index = {
25
25
  plugins: {
26
26
  '@eslint-react': eslintReact,
27
27
  '@stylistic': stylistic,
28
- 'jsx-a11y': jsxA11y,
28
+ 'jsx-a11y-x': jsxA11yX,
29
29
  'react-hooks': reactHooks,
30
30
  ...customReactConfig.plugins,
31
31
  },
@@ -1,233 +1,28 @@
1
- /** @type {import('eslint').Linter.Config} */
1
+ import jsxA11yX from 'eslint-plugin-jsx-a11y-x';
2
2
 
3
+ /** @type {import('eslint').Linter.Config} */
3
4
  const reactA11yRules = {
4
5
  rules: {
5
- // Enforce that anchors have content
6
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
7
- 'jsx-a11y/anchor-has-content': ['error', { components: [] }],
8
-
9
- // Require ARIA roles to be valid and non-abstract
10
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
11
- 'jsx-a11y/aria-role': ['error', { ignoreNonDom: false }],
6
+ ...jsxA11yX.configs.strict.rules,
12
7
 
13
- // Enforce all aria-* props are valid.
14
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
15
- 'jsx-a11y/aria-props': 'error',
8
+ 'jsx-a11y-x/anchor-ambiguous-text': 'error',
9
+ 'jsx-a11y-x/control-has-associated-label': 'error',
10
+ 'jsx-a11y-x/no-aria-hidden-on-focusable': 'error',
11
+ 'jsx-a11y-x/prefer-tag-over-role': 'error',
16
12
 
17
- // Enforce ARIA state and property values are valid.
18
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
19
- 'jsx-a11y/aria-proptypes': 'error',
20
-
21
- // Enforce that elements that do not support ARIA roles, states, and
22
- // properties do not have those attributes.
23
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
24
- 'jsx-a11y/aria-unsupported-elements': 'error',
25
-
26
- // Enforce that all elements that require alternative text have meaningful information
27
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
28
- 'jsx-a11y/alt-text': ['error', {
29
- elements: ['img', 'object', 'area', 'input[type="image"]'],
30
- img: [],
31
- object: [],
32
- area: [],
33
- 'input[type="image"]': [],
34
- }],
35
-
36
- // Prevent img alt text from containing redundant words like "image", "picture", or "photo"
37
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
38
- 'jsx-a11y/img-redundant-alt': 'error',
39
-
40
- // require that JSX labels use "htmlFor"
41
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
42
- // deprecated: replaced by `label-has-associated-control` rule
43
- 'jsx-a11y/label-has-for': ['off', {
44
- components: [],
45
- required: {
46
- every: ['nesting', 'id'],
47
- },
48
- allowChildren: false,
49
- }],
50
-
51
- // Enforce that a label tag has a text label and an associated control.
52
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md
53
- 'jsx-a11y/label-has-associated-control': ['error', {
54
- labelComponents: [],
55
- labelAttributes: [],
56
- controlComponents: [],
13
+ 'jsx-a11y-x/label-has-associated-control': ['error', {
57
14
  assert: 'both',
58
15
  depth: 25,
59
16
  }],
60
17
 
61
- // Enforce that a control (an interactive element) has a text label.
62
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md
63
- 'jsx-a11y/control-has-associated-label': ['error', {
64
- labelAttributes: ['label'],
65
- controlComponents: [],
66
- ignoreElements: [
67
- 'audio',
68
- 'canvas',
69
- 'embed',
70
- 'input',
71
- 'textarea',
72
- 'tr',
73
- 'video',
74
- ],
75
- ignoreRoles: [
76
- 'grid',
77
- 'listbox',
78
- 'menu',
79
- 'menubar',
80
- 'radiogroup',
81
- 'row',
82
- 'tablist',
83
- 'toolbar',
84
- 'tree',
85
- 'treegrid',
86
- ],
87
- depth: 5,
88
- }],
89
-
90
- // require that mouseover/out come with focus/blur, for keyboard-only users
91
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
92
- 'jsx-a11y/mouse-events-have-key-events': 'error',
93
-
94
- // Prevent use of `accessKey`
95
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
96
- 'jsx-a11y/no-access-key': 'error',
97
-
98
- // require onBlur instead of onChange
99
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
100
- 'jsx-a11y/no-onchange': 'off',
101
-
102
- // Elements with an interactive role and interaction handlers must be focusable
103
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md
104
- 'jsx-a11y/interactive-supports-focus': 'error',
105
-
106
- // Enforce that elements with ARIA roles must have all required attributes
107
- // for that role.
108
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
109
- 'jsx-a11y/role-has-required-aria-props': 'error',
110
-
111
- // Enforce that elements with explicit or implicit roles defined contain
112
- // only aria-* properties supported by that role.
113
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
114
- 'jsx-a11y/role-supports-aria-props': 'error',
115
-
116
- // Enforce tabIndex value is not greater than zero.
117
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
118
- 'jsx-a11y/tabindex-no-positive': 'error',
119
-
120
- // ensure <hX> tags have content and are not aria-hidden
121
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
122
- 'jsx-a11y/heading-has-content': ['error', { components: [''] }],
123
-
124
- // require HTML elements to have a "lang" prop
125
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
126
- 'jsx-a11y/html-has-lang': 'error',
127
-
128
- // require HTML element's lang prop to be valid
129
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
130
- 'jsx-a11y/lang': 'error',
131
-
132
- // prevent distracting elements, like <marquee> and <blink>
133
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md
134
- 'jsx-a11y/no-distracting-elements': ['error', {
135
- elements: ['marquee', 'blink'],
136
- }],
137
-
138
- // only allow <th> to have the "scope" attr
139
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
140
- 'jsx-a11y/scope': 'error',
141
-
142
- // require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress
143
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
144
- 'jsx-a11y/click-events-have-key-events': 'error',
145
-
146
- // Enforce that DOM elements without semantic behavior not have interaction handlers
147
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
148
- 'jsx-a11y/no-static-element-interactions': ['error', {
149
- handlers: [
150
- 'onClick',
151
- 'onMouseDown',
152
- 'onMouseUp',
153
- 'onKeyPress',
154
- 'onKeyDown',
155
- 'onKeyUp',
156
- ],
157
- }],
158
-
159
- // A non-interactive element does not support event handlers (mouse and key handlers)
160
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md
161
- 'jsx-a11y/no-noninteractive-element-interactions': ['error', {
162
- handlers: [
163
- 'onClick',
164
- 'onMouseDown',
165
- 'onMouseUp',
166
- 'onKeyPress',
167
- 'onKeyDown',
168
- 'onKeyUp',
169
- ],
170
- }],
171
-
172
- // ensure emoji are accessible
173
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md
174
- 'jsx-a11y/accessible-emoji': 'error',
175
-
176
- // elements with aria-activedescendant must be tabbable
177
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md
178
- 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
179
-
180
- // ensure iframe elements have a unique title
181
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md
182
- 'jsx-a11y/iframe-has-title': 'error',
183
-
184
- // prohibit autoFocus prop
185
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md
186
- 'jsx-a11y/no-autofocus': ['error', { ignoreNonDOM: true }],
187
-
188
- // ensure HTML elements do not specify redundant ARIA roles
189
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md
190
- 'jsx-a11y/no-redundant-roles': 'error',
191
-
192
- // media elements must have captions
193
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md
194
- 'jsx-a11y/media-has-caption': ['error', {
195
- audio: [],
196
- video: [],
197
- track: [],
198
- }],
199
-
200
- // WAI-ARIA roles should not be used to convert an interactive element to non-interactive
201
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md
202
- 'jsx-a11y/no-interactive-element-to-noninteractive-role': ['error', {
203
- tr: ['none', 'presentation'],
204
- }],
205
-
206
- // WAI-ARIA roles should not be used to convert a non-interactive element to interactive
207
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md
208
- 'jsx-a11y/no-noninteractive-element-to-interactive-role': ['error', {
209
- ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
210
- ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
211
- li: ['menuitem', 'option', 'row', 'tab', 'treeitem'],
212
- table: ['grid'],
213
- td: ['gridcell'],
214
- }],
215
-
216
- // Tab key navigation should be limited to elements on the page that can be interacted with.
217
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md
218
- 'jsx-a11y/no-noninteractive-tabindex': ['error', {
219
- tags: [],
220
- roles: ['tabpanel'],
221
- }],
222
-
223
- // ensure <a> tags are valid
224
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md
225
- 'jsx-a11y/anchor-is-valid': ['error', {
18
+ 'jsx-a11y-x/anchor-is-valid': ['error', {
226
19
  components: ['Link'],
227
20
  specialLink: ['to'],
228
21
  aspects: ['noHref', 'invalidHref', 'preferButton'],
229
22
  }],
23
+
24
+ 'jsx-a11y-x/no-noninteractive-element-interactions': 'error',
230
25
  },
231
26
  };
232
27
 
233
- export default reactA11yRules;
28
+ export default reactA11yRules;
package/config/index.mjs CHANGED
@@ -20,13 +20,6 @@ const baseRules = {
20
20
  'no-useless-escape': 'warn',
21
21
  };
22
22
 
23
- const reactA11yRules = {
24
- 'jsx-a11y/anchor-is-valid': 'warn',
25
- 'jsx-a11y/control-has-associated-label': 'warn',
26
- 'jsx-a11y/no-static-element-interactions': 'warn',
27
- 'jsx-a11y/label-has-associated-control': 'warn',
28
- };
29
-
30
23
  const typeScriptRules = {
31
24
  '@typescript-eslint/no-use-before-define': 'off',
32
25
 
@@ -121,7 +114,6 @@ export const rootEslintConfig = [
121
114
  rules: {
122
115
  ...baseRules,
123
116
  ...typeScriptRules,
124
- ...reactA11yRules,
125
117
  },
126
118
  },
127
119
  ),
@@ -1,3 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
- export const ComponentTest: React.FC = () => <p>Component Test</p>;
3
+ export const ComponentTest: React.FC = () => (
4
+ <div>
5
+ <a href="/documentation">Read the documentation</a>
6
+ </div>
7
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovixx/eslint-config",
3
- "version": "4.0.0",
3
+ "version": "5.0.0-alpha.0",
4
4
  "main": "config/index.mjs",
5
5
  "repository": "git@github.com:innovixx/eslint-config.git",
6
6
  "description": "Opinionated ESLint config for JavaScript developers",
@@ -27,7 +27,7 @@
27
27
  "eslint-plugin-import": "^2.32.0",
28
28
  "eslint-plugin-jest": "^29.17.0",
29
29
  "eslint-plugin-jest-dom": "^5.10.1",
30
- "eslint-plugin-jsx-a11y": "^6.10.2",
30
+ "eslint-plugin-jsx-a11y-x": "^0.2.0",
31
31
  "eslint-plugin-n": "^18.5.0",
32
32
  "eslint-plugin-react-hooks": "^7.1.1",
33
33
  "eslint-plugin-sort-export-all": "^2.1.0",