@krivega/eslint-config 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/react.ts ADDED
@@ -0,0 +1,509 @@
1
+ import type { Linter } from 'eslint';
2
+ import jsxA11y from 'eslint-plugin-jsx-a11y';
3
+ import react from 'eslint-plugin-react';
4
+ import reactHooks from 'eslint-plugin-react-hooks';
5
+ import config from './index';
6
+
7
+ const reactConfig: Linter.Config[] = [
8
+ ...config,
9
+ {
10
+ settings: {
11
+ react: {
12
+ version: 'detect',
13
+ },
14
+ },
15
+ plugins: { 'react-hooks': reactHooks, 'jsx-a11y': jsxA11y, react: react },
16
+ rules: {
17
+ '@stylistic/jsx-closing-bracket-location': ['error'],
18
+ '@stylistic/jsx-closing-tag-location': ['error'],
19
+ '@stylistic/jsx-curly-brace-presence': [
20
+ 'error',
21
+ {
22
+ propElementValues: 'always',
23
+ },
24
+ ],
25
+ '@stylistic/jsx-curly-newline': ['error'],
26
+ '@stylistic/jsx-curly-spacing': ['error', 'never'],
27
+ '@stylistic/jsx-equals-spacing': ['error'],
28
+ '@stylistic/jsx-first-prop-new-line': ['error'],
29
+ '@stylistic/jsx-function-call-newline': ['error', 'multiline'],
30
+ '@stylistic/jsx-indent-props': ['error', 2],
31
+ '@stylistic/jsx-max-props-per-line': [
32
+ 'error',
33
+ {
34
+ maximum: 1,
35
+ when: 'multiline',
36
+ },
37
+ ],
38
+ '@stylistic/jsx-quotes': ['error'],
39
+ '@stylistic/jsx-tag-spacing': [
40
+ 'error',
41
+ {
42
+ afterOpening: 'never',
43
+ beforeClosing: 'never',
44
+ beforeSelfClosing: 'always',
45
+ closingSlash: 'never',
46
+ },
47
+ ],
48
+ '@stylistic/jsx-wrap-multilines': [
49
+ 'error',
50
+ {
51
+ arrow: 'parens-new-line',
52
+ assignment: 'parens-new-line',
53
+ condition: 'parens-new-line',
54
+ declaration: 'parens-new-line',
55
+ logical: 'parens-new-line',
56
+ // prop: 'parens-new-line',
57
+ propertyValue: 'parens-new-line',
58
+ return: 'parens-new-line',
59
+ },
60
+ ],
61
+ 'jsx-a11y/alt-text': [
62
+ 'error',
63
+ {
64
+ area: [],
65
+ elements: ['img', 'object', 'area', 'input[type="image"]'],
66
+ img: [],
67
+ 'input[type="image"]': [],
68
+ object: [],
69
+ },
70
+ ],
71
+ 'jsx-a11y/anchor-has-content': [
72
+ 'error',
73
+ {
74
+ components: [],
75
+ },
76
+ ],
77
+ 'jsx-a11y/anchor-is-valid': [
78
+ 'error',
79
+ {
80
+ aspects: ['noHref', 'invalidHref', 'preferButton'],
81
+ components: ['Link'],
82
+ specialLink: ['to'],
83
+ },
84
+ ],
85
+ 'jsx-a11y/aria-activedescendant-has-tabindex': ['error'],
86
+ 'jsx-a11y/aria-props': ['error'],
87
+ 'jsx-a11y/aria-proptypes': ['error'],
88
+ 'jsx-a11y/aria-role': [
89
+ 'error',
90
+ {
91
+ ignoreNonDOM: false,
92
+ },
93
+ ],
94
+ 'jsx-a11y/aria-unsupported-elements': ['error'],
95
+ 'jsx-a11y/click-events-have-key-events': ['error'],
96
+ 'jsx-a11y/control-has-associated-label': [
97
+ 'error',
98
+ {
99
+ controlComponents: [],
100
+ depth: 5,
101
+ ignoreElements: ['audio', 'canvas', 'embed', 'input', 'textarea', 'tr', 'video'],
102
+ ignoreRoles: [
103
+ 'grid',
104
+ 'listbox',
105
+ 'menu',
106
+ 'menubar',
107
+ 'radiogroup',
108
+ 'row',
109
+ 'tablist',
110
+ 'toolbar',
111
+ 'tree',
112
+ 'treegrid',
113
+ ],
114
+ labelAttributes: ['label'],
115
+ },
116
+ ],
117
+ 'jsx-a11y/heading-has-content': [
118
+ 'error',
119
+ {
120
+ components: [''],
121
+ },
122
+ ],
123
+ 'jsx-a11y/html-has-lang': ['error'],
124
+ 'jsx-a11y/iframe-has-title': ['error'],
125
+ 'jsx-a11y/img-redundant-alt': ['error'],
126
+ 'jsx-a11y/interactive-supports-focus': ['error'],
127
+ 'jsx-a11y/label-has-associated-control': [
128
+ 'error',
129
+ {
130
+ assert: 'both',
131
+ controlComponents: [],
132
+ depth: 25,
133
+ labelAttributes: [],
134
+ labelComponents: [],
135
+ },
136
+ ],
137
+ 'jsx-a11y/lang': ['error'],
138
+ 'jsx-a11y/media-has-caption': [
139
+ 'error',
140
+ {
141
+ audio: [],
142
+ track: [],
143
+ video: [],
144
+ },
145
+ ],
146
+ 'jsx-a11y/mouse-events-have-key-events': ['error'],
147
+ 'jsx-a11y/no-access-key': ['error'],
148
+ 'jsx-a11y/no-autofocus': [
149
+ 'error',
150
+ {
151
+ ignoreNonDOM: true,
152
+ },
153
+ ],
154
+ 'jsx-a11y/no-distracting-elements': [
155
+ 'error',
156
+ {
157
+ elements: ['marquee', 'blink'],
158
+ },
159
+ ],
160
+ 'jsx-a11y/no-interactive-element-to-noninteractive-role': [
161
+ 'error',
162
+ {
163
+ tr: ['none', 'presentation'],
164
+ },
165
+ ],
166
+ 'jsx-a11y/no-noninteractive-element-interactions': [
167
+ 'error',
168
+ {
169
+ handlers: ['onClick', 'onMouseDown', 'onMouseUp', 'onKeyPress', 'onKeyDown', 'onKeyUp'],
170
+ },
171
+ ],
172
+ 'jsx-a11y/no-noninteractive-element-to-interactive-role': [
173
+ 'error',
174
+ {
175
+ li: ['menuitem', 'option', 'row', 'tab', 'treeitem'],
176
+ ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
177
+ table: ['grid'],
178
+ td: ['gridcell'],
179
+ ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
180
+ },
181
+ ],
182
+ 'jsx-a11y/no-noninteractive-tabindex': [
183
+ 'error',
184
+ {
185
+ roles: ['tabpanel'],
186
+ tags: [],
187
+ },
188
+ ],
189
+ 'jsx-a11y/no-redundant-roles': ['error'],
190
+ 'jsx-a11y/no-static-element-interactions': [
191
+ 'error',
192
+ {
193
+ handlers: ['onClick', 'onMouseDown', 'onMouseUp', 'onKeyPress', 'onKeyDown', 'onKeyUp'],
194
+ },
195
+ ],
196
+ 'jsx-a11y/role-has-required-aria-props': ['error'],
197
+ 'jsx-a11y/role-supports-aria-props': ['error'],
198
+ 'jsx-a11y/scope': ['error'],
199
+ 'jsx-a11y/tabindex-no-positive': ['error'],
200
+ 'jsx-quotes': ['error', 'prefer-double'],
201
+ 'react-hooks/exhaustive-deps': [
202
+ 'error',
203
+ {
204
+ enableDangerousAutofixThisMayCauseInfiniteLoops: false,
205
+ },
206
+ ],
207
+ 'react-hooks/rules-of-hooks': ['error'],
208
+ 'react/button-has-type': [
209
+ 2,
210
+ {
211
+ button: true,
212
+ reset: false,
213
+ submit: true,
214
+ },
215
+ ],
216
+ 'react/checked-requires-onchange-or-readonly': [2],
217
+ 'react/default-props-match-prop-types': [
218
+ 2,
219
+ {
220
+ allowRequiredDefaults: false,
221
+ },
222
+ ],
223
+ 'react/destructuring-assignment': [2, 'always'],
224
+ 'react/display-name': [
225
+ 2,
226
+ {
227
+ ignoreTranspilerName: false,
228
+ },
229
+ ],
230
+ 'react/forbid-component-props': [
231
+ 2,
232
+ {
233
+ forbid: [],
234
+ },
235
+ ],
236
+ 'react/forbid-dom-props': [
237
+ 2,
238
+ {
239
+ forbid: [],
240
+ },
241
+ ],
242
+ 'react/forbid-elements': [
243
+ 2,
244
+ {
245
+ forbid: [],
246
+ },
247
+ ],
248
+ 'react/forbid-foreign-prop-types': [
249
+ 2,
250
+ {
251
+ allowInPropTypes: true,
252
+ },
253
+ ],
254
+ 'react/forward-ref-uses-ref': [2],
255
+ 'react/hook-use-state': [2],
256
+ 'react/iframe-missing-sandbox': [2],
257
+ 'react/jsx-boolean-value': [
258
+ 2,
259
+ 'never',
260
+ {
261
+ always: [],
262
+ },
263
+ ],
264
+ 'react/jsx-closing-bracket-location': [2, 'line-aligned'],
265
+ 'react/jsx-closing-tag-location': [2],
266
+ 'react/jsx-curly-brace-presence': [
267
+ 2,
268
+ {
269
+ children: 'never',
270
+ props: 'never',
271
+ },
272
+ ],
273
+ 'react/jsx-curly-newline': [
274
+ 2,
275
+ {
276
+ multiline: 'consistent',
277
+ singleline: 'consistent',
278
+ },
279
+ ],
280
+ 'react/jsx-curly-spacing': [
281
+ 2,
282
+ 'never',
283
+ {
284
+ allowMultiline: true,
285
+ },
286
+ ],
287
+ 'react/jsx-equals-spacing': [2, 'never'],
288
+ 'react/jsx-filename-extension': [
289
+ 2,
290
+ {
291
+ extensions: ['.jsx', '.tsx'],
292
+ },
293
+ ],
294
+ 'react/jsx-first-prop-new-line': [2, 'multiline-multiprop'],
295
+ 'react/jsx-fragments': [2, 'syntax'],
296
+ 'react/jsx-handler-names': [
297
+ 2,
298
+ {
299
+ eventHandlerPrefix: 'handle',
300
+ eventHandlerPropPrefix: 'on',
301
+ },
302
+ ],
303
+ 'react/jsx-indent': [2, 2],
304
+ 'react/jsx-indent-props': [2, 2],
305
+ 'react/jsx-max-depth': [2],
306
+ 'react/jsx-max-props-per-line': [
307
+ 2,
308
+ {
309
+ maximum: 1,
310
+ when: 'multiline',
311
+ },
312
+ ],
313
+ 'react/jsx-newline': [2],
314
+ 'react/jsx-no-comment-textnodes': [2],
315
+ 'react/jsx-no-duplicate-props': [
316
+ 2,
317
+ {
318
+ ignoreCase: true,
319
+ },
320
+ ],
321
+ 'react/jsx-no-leaked-render': [2],
322
+ 'react/jsx-no-target-blank': [
323
+ 2,
324
+ {
325
+ enforceDynamicLinks: 'always',
326
+ forms: false,
327
+ links: true,
328
+ },
329
+ ],
330
+ 'react/jsx-no-undef': [2],
331
+ 'react/jsx-no-useless-fragment': ['error'],
332
+ 'react/jsx-pascal-case': [
333
+ 2,
334
+ {
335
+ allowAllCaps: true,
336
+ ignore: [],
337
+ },
338
+ ],
339
+ 'react/jsx-props-no-multi-spaces': [2],
340
+ 'react/jsx-props-no-spread-multi': [2],
341
+ 'react/jsx-props-no-spreading': [
342
+ 'error',
343
+ {
344
+ custom: 'enforce',
345
+ exceptions: [],
346
+ explicitSpread: 'ignore',
347
+ html: 'enforce',
348
+ },
349
+ ],
350
+ 'react/jsx-tag-spacing': [
351
+ 2,
352
+ {
353
+ afterOpening: 'never',
354
+ beforeClosing: 'never',
355
+ beforeSelfClosing: 'always',
356
+ closingSlash: 'never',
357
+ },
358
+ ],
359
+ 'react/jsx-uses-vars': [2],
360
+ 'react/no-access-state-in-setstate': [2],
361
+ 'react/no-adjacent-inline-elements': [2],
362
+ 'react/no-array-index-key': [2],
363
+ 'react/no-arrow-function-lifecycle': [2],
364
+ 'react/no-children-prop': [2],
365
+ 'react/no-danger': [2],
366
+ 'react/no-danger-with-children': [2],
367
+ 'react/no-deprecated': [2],
368
+ 'react/no-did-mount-set-state': [2],
369
+ 'react/no-did-update-set-state': [2],
370
+ 'react/no-direct-mutation-state': [2],
371
+ 'react/no-find-dom-node': [2],
372
+ 'react/no-invalid-html-attribute': [2],
373
+ 'react/no-is-mounted': [2],
374
+ 'react/no-multi-comp': [2],
375
+ 'react/no-namespace': [2],
376
+ 'react/no-object-type-as-default-prop': [2],
377
+ 'react/no-redundant-should-component-update': [2],
378
+ 'react/no-render-return-value': [2],
379
+ 'react/no-string-refs': [2],
380
+ 'react/no-this-in-sfc': [2],
381
+ 'react/no-typos': [2],
382
+ 'react/no-unescaped-entities': [2],
383
+ 'react/no-unknown-property': [2],
384
+ 'react/no-unsafe': [2],
385
+ 'react/no-unused-class-component-methods': [2],
386
+ 'react/no-unused-prop-types': [
387
+ 2,
388
+ {
389
+ customValidators: [],
390
+ skipShapeProps: true,
391
+ },
392
+ ],
393
+ 'react/no-unused-state': [2],
394
+ 'react/no-will-update-set-state': [2],
395
+ 'react/prefer-es6-class': [2, 'always'],
396
+ 'react/prefer-exact-props': [2],
397
+ 'react/require-optimization': [
398
+ 2,
399
+ {
400
+ allowDecorators: [],
401
+ },
402
+ ],
403
+ 'react/require-render-return': [2],
404
+ 'react/self-closing-comp': [2],
405
+ 'react/sort-comp': [
406
+ 2,
407
+ {
408
+ groups: {
409
+ lifecycle: [
410
+ 'displayName',
411
+ 'propTypes',
412
+ 'contextTypes',
413
+ 'childContextTypes',
414
+ 'mixins',
415
+ 'statics',
416
+ 'defaultProps',
417
+ 'constructor',
418
+ 'getDefaultProps',
419
+ 'getInitialState',
420
+ 'state',
421
+ 'getChildContext',
422
+ 'getDerivedStateFromProps',
423
+ 'componentWillMount',
424
+ 'UNSAFE_componentWillMount',
425
+ 'componentDidMount',
426
+ 'componentWillReceiveProps',
427
+ 'UNSAFE_componentWillReceiveProps',
428
+ 'shouldComponentUpdate',
429
+ 'componentWillUpdate',
430
+ 'UNSAFE_componentWillUpdate',
431
+ 'getSnapshotBeforeUpdate',
432
+ 'componentDidUpdate',
433
+ 'componentDidCatch',
434
+ 'componentWillUnmount',
435
+ ],
436
+ rendering: ['/^render.+$/', 'render'],
437
+ },
438
+ order: [
439
+ 'static-variables',
440
+ 'static-methods',
441
+ 'instance-variables',
442
+ 'lifecycle',
443
+ '/^handle.+$/',
444
+ '/^on.+$/',
445
+ 'getters',
446
+ 'setters',
447
+ '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
448
+ 'instance-methods',
449
+ 'everything-else',
450
+ 'rendering',
451
+ ],
452
+ },
453
+ ],
454
+ 'react/sort-default-props': [2],
455
+ 'react/sort-prop-types': [
456
+ 2,
457
+ {
458
+ callbacksLast: false,
459
+ ignoreCase: true,
460
+ requiredFirst: false,
461
+ sortShapeProp: true,
462
+ },
463
+ ],
464
+ 'react/static-property-placement': [2, 'property assignment'],
465
+ 'react/style-prop-object': [2],
466
+ 'react/void-dom-elements-no-children': [2],
467
+
468
+ 'react/boolean-prop-naming': [
469
+ 'error',
470
+ {
471
+ validateNested: true,
472
+ },
473
+ ],
474
+ 'react/no-unstable-nested-components': 'error',
475
+ 'react/jsx-key': 'error',
476
+ 'react/jsx-no-bind': [
477
+ 'error',
478
+ {
479
+ ignoreRefs: false,
480
+ allowArrowFunctions: true,
481
+ allowFunctions: true,
482
+ allowBind: false,
483
+ ignoreDOMComponents: false,
484
+ },
485
+ ],
486
+ 'react/jsx-sort-props': [
487
+ 'error',
488
+ {
489
+ callbacksLast: true,
490
+ shorthandFirst: true,
491
+ noSortAlphabetically: false,
492
+ reservedFirst: false,
493
+ },
494
+ ],
495
+ 'react/function-component-definition': [
496
+ 'error',
497
+ {
498
+ namedComponents: 'arrow-function',
499
+ unnamedComponents: 'arrow-function',
500
+ },
501
+ ],
502
+ 'react/jsx-no-constructed-context-values': 'error',
503
+ 'react/jsx-no-script-url': 'error',
504
+ 'arrow-body-style': ['error', 'always'],
505
+ },
506
+ },
507
+ ];
508
+
509
+ export default reactConfig;