Skip to content

Commit 9e63d73

Browse files
author
Spencer
committed
move react/jsx-a11y rules into shared react preset (#49244)
* move react/jsx-a11y rules into shared react preset * autofix react/jsx-closing-tag-location * autofix react/no-unknown-property * manually fix react/no-unescaped-entities * maually fix react/jsx-pascal-case * manually fix react/prefer-stateless-function * disable known violations in specific plugins/areas * remove code override # Conflicts: # x-pack/legacy/plugins/upgrade_assistant/public/components/tabs/checkup/deprecations/reindex/flyout/warnings_step.tsx
1 parent a23a6dd commit 9e63d73

File tree

61 files changed

+630
-502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+630
-502
lines changed

.eslintrc.js

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,207 @@ module.exports = {
5555
extends: ['@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended'],
5656

5757
overrides: [
58+
/**
59+
* Temporarily disable some react rules for specific plugins, remove in separate PRs
60+
*/
61+
{
62+
files: ['packages/kbn-ui-framework/**/*.{js,ts,tsx}'],
63+
rules: {
64+
'jsx-a11y/no-onchange': 'off',
65+
},
66+
},
67+
{
68+
files: ['src/core/public/application/**/*.{js,ts,tsx}'],
69+
rules: {
70+
'react/no-danger': 'off',
71+
},
72+
},
73+
{
74+
files: ['src/legacy/core_plugins/console/**/*.{js,ts,tsx}'],
75+
rules: {
76+
'react-hooks/exhaustive-deps': 'off',
77+
},
78+
},
79+
{
80+
files: ['src/legacy/core_plugins/data/**/*.{js,ts,tsx}'],
81+
rules: {
82+
'react-hooks/exhaustive-deps': 'off',
83+
},
84+
},
85+
{
86+
files: ['src/legacy/core_plugins/expressions/**/*.{js,ts,tsx}'],
87+
rules: {
88+
'react-hooks/exhaustive-deps': 'off',
89+
},
90+
},
91+
{
92+
files: ['src/legacy/core_plugins/kbn_vislib_vis_types/**/*.{js,ts,tsx}'],
93+
rules: {
94+
'react-hooks/exhaustive-deps': 'off',
95+
},
96+
},
97+
{
98+
files: ['src/legacy/core_plugins/kibana/**/*.{js,ts,tsx}'],
99+
rules: {
100+
'react-hooks/rules-of-hooks': 'off',
101+
'react-hooks/exhaustive-deps': 'off',
102+
},
103+
},
104+
{
105+
files: ['src/legacy/core_plugins/tile_map/**/*.{js,ts,tsx}'],
106+
rules: {
107+
'react-hooks/exhaustive-deps': 'off',
108+
},
109+
},
110+
{
111+
files: ['src/legacy/core_plugins/vis_type_markdown/**/*.{js,ts,tsx}'],
112+
rules: {
113+
'react-hooks/exhaustive-deps': 'off',
114+
},
115+
},
116+
{
117+
files: ['src/legacy/core_plugins/vis_type_metric/**/*.{js,ts,tsx}'],
118+
rules: {
119+
'jsx-a11y/click-events-have-key-events': 'off',
120+
},
121+
},
122+
{
123+
files: ['src/legacy/core_plugins/vis_type_table/**/*.{js,ts,tsx}'],
124+
rules: {
125+
'react-hooks/exhaustive-deps': 'off',
126+
},
127+
},
128+
{
129+
files: ['src/legacy/core_plugins/vis_type_vega/**/*.{js,ts,tsx}'],
130+
rules: {
131+
'react-hooks/exhaustive-deps': 'off',
132+
},
133+
},
134+
{
135+
files: ['src/legacy/ui/public/vis/**/*.{js,ts,tsx}'],
136+
rules: {
137+
'react-hooks/exhaustive-deps': 'off',
138+
},
139+
},
140+
{
141+
files: ['src/plugins/es_ui_shared/**/*.{js,ts,tsx}'],
142+
rules: {
143+
'react-hooks/exhaustive-deps': 'off',
144+
},
145+
},
146+
{
147+
files: ['src/plugins/eui_utils/**/*.{js,ts,tsx}'],
148+
rules: {
149+
'react-hooks/exhaustive-deps': 'off',
150+
},
151+
},
152+
{
153+
files: ['src/plugins/kibana_react/**/*.{js,ts,tsx}'],
154+
rules: {
155+
'react-hooks/rules-of-hooks': 'off',
156+
'react-hooks/exhaustive-deps': 'off',
157+
},
158+
},
159+
{
160+
files: ['src/plugins/kibana_utils/**/*.{js,ts,tsx}'],
161+
rules: {
162+
'react-hooks/exhaustive-deps': 'off',
163+
},
164+
},
165+
{
166+
files: ['x-pack/legacy/plugins/canvas/**/*.{js,ts,tsx}'],
167+
rules: {
168+
'react-hooks/exhaustive-deps': 'off',
169+
'jsx-a11y/click-events-have-key-events': 'off',
170+
},
171+
},
172+
{
173+
files: ['x-pack/legacy/plugins/cross_cluster_replication/**/*.{js,ts,tsx}'],
174+
rules: {
175+
'jsx-a11y/click-events-have-key-events': 'off',
176+
},
177+
},
178+
{
179+
files: ['x-pack/legacy/plugins/graph/**/*.{js,ts,tsx}'],
180+
rules: {
181+
'react-hooks/exhaustive-deps': 'off',
182+
},
183+
},
184+
{
185+
files: ['x-pack/legacy/plugins/index_management/**/*.{js,ts,tsx}'],
186+
rules: {
187+
'react-hooks/exhaustive-deps': 'off',
188+
'react-hooks/rules-of-hooks': 'off',
189+
},
190+
},
191+
{
192+
files: ['x-pack/legacy/plugins/infra/**/*.{js,ts,tsx}'],
193+
rules: {
194+
'react-hooks/exhaustive-deps': 'off',
195+
'react-hooks/rules-of-hooks': 'off',
196+
},
197+
},
198+
{
199+
files: ['x-pack/legacy/plugins/lens/**/*.{js,ts,tsx}'],
200+
rules: {
201+
'react-hooks/exhaustive-deps': 'off',
202+
'react-hooks/rules-of-hooks': 'off',
203+
},
204+
},
205+
{
206+
files: ['x-pack/legacy/plugins/ml/**/*.{js,ts,tsx}'],
207+
rules: {
208+
'react-hooks/exhaustive-deps': 'off',
209+
'react-hooks/rules-of-hooks': 'off',
210+
'jsx-a11y/click-events-have-key-events': 'off',
211+
},
212+
},
213+
{
214+
files: ['x-pack/legacy/plugins/monitoring/**/*.{js,ts,tsx}'],
215+
rules: {
216+
'jsx-a11y/click-events-have-key-events': 'off',
217+
},
218+
},
219+
{
220+
files: ['x-pack/legacy/plugins/siem/**/*.{js,ts,tsx}'],
221+
rules: {
222+
'react-hooks/exhaustive-deps': 'off',
223+
'react-hooks/rules-of-hooks': 'off',
224+
},
225+
},
226+
{
227+
files: ['x-pack/legacy/plugins/snapshot_restore/**/*.{js,ts,tsx}'],
228+
rules: {
229+
'react-hooks/exhaustive-deps': 'off',
230+
},
231+
},
232+
{
233+
files: ['x-pack/legacy/plugins/spaces/**/*.{js,ts,tsx}'],
234+
rules: {
235+
'react-hooks/exhaustive-deps': 'off',
236+
},
237+
},
238+
{
239+
files: ['x-pack/legacy/plugins/transform/**/*.{js,ts,tsx}'],
240+
rules: {
241+
'react-hooks/exhaustive-deps': 'off',
242+
},
243+
},
244+
{
245+
files: ['x-pack/legacy/plugins/uptime/**/*.{js,ts,tsx}'],
246+
rules: {
247+
'react-hooks/exhaustive-deps': 'off',
248+
'react-hooks/rules-of-hooks': 'off',
249+
},
250+
},
251+
{
252+
files: ['x-pack/legacy/plugins/watcher/**/*.{js,ts,tsx}'],
253+
rules: {
254+
'react-hooks/rules-of-hooks': 'off',
255+
'react-hooks/exhaustive-deps': 'off',
256+
},
257+
},
258+
58259
/**
59260
* Prettier
60261
*/

packages/eslint-config-kibana/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
'./javascript.js',
44
'./typescript.js',
55
'./jest.js',
6+
'./react.js',
67
],
78
plugins: ['@kbn/eslint-plugin-eslint'],
89

packages/eslint-config-kibana/javascript.js

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
const semver = require('semver');
2-
const { readdirSync } = require('fs');
3-
const PKG = require('../../package.json');
41
const RESTRICTED_GLOBALS = require('./restricted_globals');
52
const RESTRICTED_MODULES = { paths: ['gulp-util'] };
63

@@ -16,18 +13,12 @@ module.exports = {
1613
plugins: [
1714
'mocha',
1815
'babel',
19-
'react',
20-
'react-hooks',
2116
'import',
2217
'no-unsanitized',
2318
'prefer-object-spread',
24-
'jsx-a11y',
2519
],
2620

2721
settings: {
28-
react: {
29-
version: semver.valid(semver.coerce(PKG.dependencies.react)),
30-
},
3122
'import/resolver': {
3223
'@kbn/eslint-import-resolver-kibana': {
3324
forceNode: true,
@@ -121,64 +112,6 @@ module.exports = {
121112
'object-curly-spacing': 'off', // overridden with babel/object-curly-spacing
122113
'babel/object-curly-spacing': [ 'error', 'always' ],
123114

124-
'jsx-quotes': ['error', 'prefer-double'],
125-
'react/jsx-uses-react': 'error',
126-
'react/react-in-jsx-scope': 'error',
127-
'react/jsx-uses-vars': 'error',
128-
'react/jsx-no-undef': 'error',
129-
'react/jsx-pascal-case': 'error',
130-
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
131-
'react/jsx-closing-tag-location': 'error',
132-
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
133-
'react/jsx-indent-props': ['error', 2],
134-
'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }],
135-
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
136-
'react/no-danger': 'error',
137-
'react/self-closing-comp': 'error',
138-
'react/jsx-wrap-multilines': ['error', {
139-
declaration: true,
140-
assignment: true,
141-
return: true,
142-
arrow: true,
143-
}],
144-
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
145-
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
146-
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies
147-
'jsx-a11y/accessible-emoji': 'error',
148-
'jsx-a11y/alt-text': 'error',
149-
'jsx-a11y/anchor-has-content': 'error',
150-
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
151-
'jsx-a11y/aria-props': 'error',
152-
'jsx-a11y/aria-proptypes': 'error',
153-
'jsx-a11y/aria-role': 'error',
154-
'jsx-a11y/aria-unsupported-elements': 'error',
155-
'jsx-a11y/heading-has-content': 'error',
156-
'jsx-a11y/html-has-lang': 'error',
157-
'jsx-a11y/iframe-has-title': 'error',
158-
'jsx-a11y/interactive-supports-focus': 'error',
159-
'jsx-a11y/media-has-caption': 'error',
160-
'jsx-a11y/mouse-events-have-key-events': 'error',
161-
'jsx-a11y/no-access-key': 'error',
162-
'jsx-a11y/no-distracting-elements': 'error',
163-
'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error',
164-
'jsx-a11y/no-noninteractive-element-interactions': 'error',
165-
'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error',
166-
'jsx-a11y/no-redundant-roles': 'error',
167-
'jsx-a11y/role-has-required-aria-props': 'error',
168-
'jsx-a11y/role-supports-aria-props': 'error',
169-
'jsx-a11y/scope': 'error',
170-
'jsx-a11y/tabindex-no-positive': 'error',
171-
'jsx-a11y/label-has-associated-control': 'error',
172-
'react/jsx-equals-spacing': ['error', 'never'],
173-
'react/jsx-indent': ['error', 2],
174-
'react/no-will-update-set-state': 'error',
175-
'react/no-is-mounted': 'error',
176-
'react/no-multi-comp': ['error', { ignoreStateless: true }],
177-
'react/no-unknown-property': 'error',
178-
'react/prefer-es6-class': ['error', 'always'],
179-
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
180-
'react/no-unescaped-entities': 'error',
181-
182115
'mocha/handle-done-callback': 'error',
183116
'mocha/no-exclusive-tests': 'error',
184117

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
const semver = require('semver')
2+
const PKG = require('../../package.json')
3+
4+
module.exports = {
5+
plugins: [
6+
'react',
7+
'react-hooks',
8+
'jsx-a11y',
9+
],
10+
11+
parserOptions: {
12+
ecmaFeatures: {
13+
jsx: true
14+
}
15+
},
16+
17+
settings: {
18+
react: {
19+
version: semver.valid(semver.coerce(PKG.dependencies.react)),
20+
},
21+
},
22+
23+
rules: {
24+
'jsx-quotes': ['error', 'prefer-double'],
25+
'react/jsx-uses-react': 'error',
26+
'react/react-in-jsx-scope': 'error',
27+
'react/jsx-uses-vars': 'error',
28+
'react/jsx-no-undef': 'error',
29+
'react/jsx-pascal-case': 'error',
30+
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
31+
'react/jsx-closing-tag-location': 'error',
32+
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
33+
'react/jsx-indent-props': ['error', 2],
34+
'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }],
35+
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
36+
'react/no-danger': 'error',
37+
'react/self-closing-comp': 'error',
38+
'react/jsx-wrap-multilines': ['error', {
39+
declaration: true,
40+
assignment: true,
41+
return: true,
42+
arrow: true,
43+
}],
44+
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
45+
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
46+
'react-hooks/exhaustive-deps': 'error', // Checks effect dependencies
47+
'jsx-a11y/accessible-emoji': 'error',
48+
'jsx-a11y/alt-text': 'error',
49+
'jsx-a11y/anchor-has-content': 'error',
50+
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
51+
'jsx-a11y/aria-props': 'error',
52+
'jsx-a11y/aria-proptypes': 'error',
53+
'jsx-a11y/aria-role': 'error',
54+
'jsx-a11y/aria-unsupported-elements': 'error',
55+
'jsx-a11y/click-events-have-key-events': 'error',
56+
'jsx-a11y/heading-has-content': 'error',
57+
'jsx-a11y/html-has-lang': 'error',
58+
'jsx-a11y/iframe-has-title': 'error',
59+
'jsx-a11y/interactive-supports-focus': 'error',
60+
'jsx-a11y/label-has-associated-control': 'error',
61+
'jsx-a11y/media-has-caption': 'error',
62+
'jsx-a11y/mouse-events-have-key-events': 'error',
63+
'jsx-a11y/no-access-key': 'error',
64+
'jsx-a11y/no-distracting-elements': 'error',
65+
'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error',
66+
'jsx-a11y/no-noninteractive-element-interactions': 'error',
67+
'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error',
68+
'jsx-a11y/no-onchange': 'error',
69+
'jsx-a11y/no-redundant-roles': 'error',
70+
'jsx-a11y/role-has-required-aria-props': 'error',
71+
'jsx-a11y/role-supports-aria-props': 'error',
72+
'jsx-a11y/scope': 'error',
73+
'jsx-a11y/tabindex-no-positive': 'error',
74+
'react/jsx-equals-spacing': ['error', 'never'],
75+
'react/jsx-indent': ['error', 2],
76+
'react/no-will-update-set-state': 'error',
77+
'react/no-is-mounted': 'error',
78+
'react/no-multi-comp': ['error', { ignoreStateless: true }],
79+
'react/no-unknown-property': 'error',
80+
'react/prefer-es6-class': ['error', 'always'],
81+
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
82+
'react/no-unescaped-entities': 'error',
83+
},
84+
}

0 commit comments

Comments
 (0)