-
Notifications
You must be signed in to change notification settings - Fork 0
/
react.js
152 lines (149 loc) · 4.57 KB
/
react.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2022,
},
reportUnusedDisableDirectives: true,
overrides: [
{
files: ['*.js'],
// For now, require .js files (like .eslintrc.js) only to be formatted using Prettier.
plugins: ['prettier'],
extends: ['plugin:prettier/recommended'],
rules: {
'prettier/prettier': 'warn',
},
},
{
files: ['*.ts', '*.tsx'],
parserOptions: {
project: './tsconfig.json',
},
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'react-app',
'plugin:react/recommended',
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': 'warn',
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
},
],
'@typescript-eslint/consistent-type-definitions': [
'error',
'interface',
],
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public',
},
],
'@typescript-eslint/member-ordering': [
'warn',
{
classes: ['field', 'constructor', 'method'],
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: ['class', 'interface', 'typeAlias'],
format: ['PascalCase'],
},
],
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'warn',
'accessor-pairs': 'error',
'array-callback-return': 'error',
curly: 'error',
'default-case-last': 'error',
'default-param-last': 'error',
'dot-notation': 'warn',
eqeqeq: ['error', 'always', { null: 'never' }],
'guard-for-in': 'error',
'no-constructor-return': 'error',
'no-else-return': 'error',
'no-extra-bind': 'error',
'no-lone-blocks': 'error',
'no-new-wrappers': 'error',
'no-nested-ternary': 'error',
'no-restricted-globals': [
'error',
{ name: 'parseInt', message: `Use 'Number.parseInt()' instead.` },
{ name: 'parseFloat', message: `Use 'Number.parseFloat()' instead.` },
],
'no-self-compare': 'error',
'no-throw-literal': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'import/first': 'warn',
'import/newline-after-import': 'warn',
'import/no-cycle': 'error',
'import/no-unresolved': ['error'],
'import/order': [
'warn',
{
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
warnOnUnassignedImports: true,
},
],
'no-unreachable-loop': 'error',
radix: 'error',
'require-atomic-updates': 'error',
'sort-imports': [
'warn',
{
ignoreDeclarationSort: true,
},
],
'spaced-comment': ['warn', 'always'],
'valid-typeof': [
'error',
{
requireStringLiterals: true,
},
],
'react/button-has-type': 'error',
'react/destructuring-assignment': ['warn', 'never'],
'react/function-component-definition': [
'error',
{ namedComponents: 'arrow-function' },
],
'react/hook-use-state': 'error',
'react/jsx-boolean-value': 'warn',
'react/jsx-fragments': ['warn', 'element'],
'react/jsx-sort-props': [
'warn',
{
noSortAlphabetically: true,
reservedFirst: true,
shorthandLast: true,
callbacksLast: true,
},
],
'react/no-array-index-key': 'error',
'react/no-unstable-nested-components': 'error',
'react/self-closing-comp': ['warn', { html: false }],
'react/void-dom-elements-no-children': 'error',
},
},
],
};