-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
103 lines (102 loc) · 3.77 KB
/
eslint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
import pluginReact from 'eslint-plugin-react';
export default tseslint.config(
pluginReact.configs.flat.recommended,
{ ignores: ['dist'] },
{
settings: {
react: {
version: 'detect',
},
},
rules: {
'react/boolean-prop-naming': ['error', { validateNested: true }],
'react/checked-requires-onchange-or-readonly': 'error',
'react/destructuring-assignment': ['error', 'always'],
'react/forbid-dom-props': 'error',
'react/forbid-elements': 'error',
'react/forbid-foreign-prop-types': 'error',
'react/forbid-prop-types': 'error',
'react/hook-use-state': 'error',
'react/iframe-missing-sandbox': 'error',
'react/jsx-child-element-spacing': 'error',
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }],
'react/jsx-fragments': ['error', 'syntax'],
'react/jsx-max-depth': ['error', { max: 4 }],
'react/jsx-no-bind': ['error', { allowArrowFunctions: true }],
'react/jsx-no-constructed-context-values': 'error',
'react/jsx-no-leaked-render': ['error', { validStrategies: ['coerce', 'ternary'] }],
'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }],
'react/jsx-no-useless-fragment': 'error',
'react/jsx-one-expression-per-line': ['error', { allow: 'single-child' }],
'react/jsx-props-no-multi-spaces': 'error',
'react/jsx-wrap-multilines': [
'error',
{
declaration: 'parens-new-line',
assignment: 'parens-new-line',
return: 'parens-new-line',
arrow: 'parens-new-line',
condition: 'parens-new-line',
logical: 'parens-new-line',
prop: 'parens-new-line',
},
],
'react/no-adjacent-inline-elements': 'error',
'react/no-arrow-function-lifecycle': 'error',
'react/no-invalid-html-attribute': 'error',
'react/no-multi-comp': ['error', { ignoreStateless: true }],
'react/no-object-type-as-default-prop': 'error',
'react/no-unstable-nested-components': ['error', { allowAsProps: true }],
'react/no-unused-class-component-methods': 'error',
'react/prefer-exact-props': 'error',
'react/sort-comp': [
'error',
{
order: [
'static-variables',
'static-methods',
'instance-variables',
'lifecycle',
'getters',
'setters',
'instance-methods',
'everything-else',
'rendering',
],
groups: {
rendering: ['^render.+$', 'render'],
},
},
],
'react/sort-default-props': ['error', { ignoreCase: true }],
'react/sort-prop-types': ['error', { callbacksLast: true, requiredFirst: true, ignoreCase: true }],
'react/state-in-constructor': ['error', 'always'],
'react/static-property-placement': ['error', 'property assignment'],
'react/react-in-jsx-scope': 'off',
'react/display-name': 'off',
},
},
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
},
},
);