-
Notifications
You must be signed in to change notification settings - Fork 8
/
.eslintrc.js
249 lines (248 loc) · 8.57 KB
/
.eslintrc.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
const error = "error";
const warn = process.argv.includes("--report-unused-disable-directives")
? "error"
: "warn";
module.exports = {
plugins: ["@typescript-eslint", "react-hooks", "simple-import-sort"],
reportUnusedDisableDirectives: true,
env: {
es2020: true,
node: true,
},
rules: {
"arrow-body-style": warn,
"default-case-last": warn,
"for-direction": error,
"no-caller": error,
"no-case-declarations": error,
"no-compare-neg-zero": error,
"no-constant-binary-expression": error,
"no-constant-condition": error,
"no-debugger": warn,
"no-dupe-else-if": error,
"no-duplicate-case": error,
"no-empty-character-class": warn,
"no-empty-pattern": warn,
"no-empty": warn,
"no-eval": error,
"no-invalid-regexp": error,
"no-labels": error,
"no-misleading-character-class": error,
"no-nonoctal-decimal-escape": error,
"no-octal-escape": error,
"no-param-reassign": error,
"no-promise-executor-return": error,
"no-prototype-builtins": error,
"no-regex-spaces": error,
"no-restricted-syntax": [
error,
{
selector: "SequenceExpression",
message:
"The comma operator is confusing and a common mistake. Don’t use it!",
},
{
selector: `CallExpression[callee.property.name="then"] > :nth-child(2)`,
message:
"Use .then(onSuccess).catch(onError) instead of .then(onSuccess, onError)",
},
],
"no-self-compare": error,
"no-sparse-arrays": error,
"no-template-curly-in-string": error,
"no-unmodified-loop-condition": error,
"no-unneeded-ternary": warn,
"no-unsafe-finally": error,
"no-useless-backreference": error,
"no-useless-catch": error,
"no-useless-computed-key": warn,
"no-useless-concat": warn,
"no-useless-constructor": warn,
"no-useless-escape": error,
"no-useless-rename": warn,
"no-var": error,
"object-shorthand": warn,
"prefer-arrow-callback": warn,
"prefer-const": warn,
"prefer-destructuring": [warn, { object: true, array: false }],
"prefer-exponentiation-operator": warn,
"prefer-numeric-literals": warn,
"prefer-object-spread": warn,
"prefer-promise-reject-errors": error,
"prefer-regex-literals": warn,
"prefer-rest-params": warn,
"prefer-spread": warn,
"prefer-template": warn,
"simple-import-sort/exports": warn,
"simple-import-sort/imports": warn,
"use-isnan": error,
curly: warn,
eqeqeq: warn,
yoda: warn,
"react-hooks/exhaustive-deps": error,
"react-hooks/rules-of-hooks": error,
},
overrides: [
{
files: ["*.{ts,tsx}"],
parser: "@typescript-eslint/parser",
parserOptions: {
sourceType: "module",
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
rules: {
"@typescript-eslint/adjacent-overload-signatures": warn,
"@typescript-eslint/array-type": [warn, { default: "generic" }],
"@typescript-eslint/await-thenable": error,
"@typescript-eslint/ban-ts-comment": error,
"@typescript-eslint/ban-types": error,
"@typescript-eslint/consistent-generic-constructors": warn,
"@typescript-eslint/consistent-type-assertions": [
error,
{
assertionStyle: "as",
objectLiteralTypeAssertions: "never",
},
],
"@typescript-eslint/consistent-type-definitions": [warn, "type"],
"@typescript-eslint/default-param-last": warn,
"@typescript-eslint/dot-notation": warn,
"@typescript-eslint/explicit-function-return-type": [
warn,
{ allowExpressions: true },
],
"@typescript-eslint/lines-between-class-members": warn,
"@typescript-eslint/method-signature-style": warn,
"@typescript-eslint/no-array-constructor": warn,
"@typescript-eslint/no-base-to-string": error,
"@typescript-eslint/no-confusing-void-expression": error,
"@typescript-eslint/no-dupe-class-members": error,
"@typescript-eslint/no-empty-function": warn,
"@typescript-eslint/no-empty-interface": warn,
"@typescript-eslint/no-explicit-any": warn,
"@typescript-eslint/no-floating-promises": error,
"@typescript-eslint/no-for-in-array": warn,
"@typescript-eslint/no-implied-eval": error,
"@typescript-eslint/no-inferrable-types": [
warn,
{ ignoreParameters: true },
],
"@typescript-eslint/no-invalid-this": error,
"@typescript-eslint/no-invalid-void-type": error,
"@typescript-eslint/no-loop-func": error,
"@typescript-eslint/no-loss-of-precision": error,
"@typescript-eslint/no-misused-promises": error,
"@typescript-eslint/no-namespace": error,
"@typescript-eslint/no-non-null-assertion": error,
"@typescript-eslint/no-redundant-type-constituents": error,
"@typescript-eslint/no-require-imports": error,
"@typescript-eslint/no-shadow": error,
"@typescript-eslint/no-this-alias": warn,
"@typescript-eslint/no-throw-literal": error,
"@typescript-eslint/no-unnecessary-boolean-literal-compare": warn,
"@typescript-eslint/no-unnecessary-type-arguments": warn,
"@typescript-eslint/no-unnecessary-type-assertion": warn,
"@typescript-eslint/no-unnecessary-type-constraint": error,
"@typescript-eslint/no-unsafe-argument": error,
"@typescript-eslint/no-unsafe-assignment": error,
"@typescript-eslint/no-unsafe-call": error,
"@typescript-eslint/no-unsafe-declaration-merging": error,
"@typescript-eslint/no-unsafe-member-access": error,
"@typescript-eslint/no-unsafe-return": error,
"@typescript-eslint/no-unused-expressions": error,
"@typescript-eslint/no-unused-vars": [
error,
{ args: "all", argsIgnorePattern: "^_", caughtErrors: "all" },
],
"@typescript-eslint/no-useless-empty-export": warn,
"@typescript-eslint/no-var-requires": error,
"@typescript-eslint/prefer-as-const": warn,
"@typescript-eslint/prefer-for-of": warn,
"@typescript-eslint/prefer-function-type": warn,
"@typescript-eslint/prefer-includes": warn,
"@typescript-eslint/prefer-nullish-coalescing": warn,
"@typescript-eslint/prefer-optional-chain": warn,
"@typescript-eslint/prefer-reduce-type-parameter": warn,
"@typescript-eslint/prefer-regexp-exec": warn,
"@typescript-eslint/prefer-string-starts-ends-with": warn,
"@typescript-eslint/promise-function-async": [
error,
{ checkArrowFunctions: false },
],
"@typescript-eslint/require-await": error,
"@typescript-eslint/restrict-plus-operands": error,
"@typescript-eslint/restrict-template-expressions": error,
"@typescript-eslint/return-await": error,
"@typescript-eslint/sort-type-union-intersection-members": warn,
"@typescript-eslint/strict-boolean-expressions": [
error,
{
allowString: false,
allowNumber: false,
allowNullableObject: false,
},
],
"@typescript-eslint/switch-exhaustiveness-check": error,
"@typescript-eslint/triple-slash-reference": warn,
"@typescript-eslint/unbound-method": error,
"@typescript-eslint/unified-signatures": warn,
},
},
{
files: ["src/*/**/*.{ts,tsx}"],
env: {
es2020: true,
node: false,
},
rules: {
"no-console": warn,
},
},
{
files: ["*.js"],
rules: {
"no-undef": error,
"no-unused-vars": error,
},
},
{
files: ["*.es5.js"],
parserOptions: { ecmaVersion: 5 },
env: {
es6: false,
node: false,
browser: true,
},
rules: {
"no-var": "off",
"object-shorthand": "off",
"prefer-arrow-callback": "off",
"prefer-const": "off",
"prefer-destructuring": "off",
"prefer-exponentiation-operator": "off",
"prefer-numeric-literals": "off",
"prefer-object-spread": "off",
"prefer-promise-reject-errors": "off",
"prefer-regex-literals": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"prefer-template": "off",
},
},
{
files: ["html/**/*.js"],
env: {
es2020: true,
node: false,
browser: true,
},
},
{
files: ["rollup.config.js"],
parserOptions: {
sourceType: "module",
},
},
],
};