-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
315 lines (305 loc) · 10.3 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
const stylisticRules = {
'array-bracket-newline': [ 'error', 'consistent', ],
'array-bracket-spacing': [ 'error', 'always', ],
'array-element-newline': [ 'error', 'consistent', ],
'block-spacing': [ 'error', 'always', ],
'brace-style': [ 'error', '1tbs', { allowSingleLine: true, }, ],
'camelcase': [ 'error', { properties: 'always', }, ],
'capitalized-comments': [ 'error', 'always', { ignoreConsecutiveComments: true, }, ],
'comma-dangle': [ 'error', 'always', { functions: 'never', }, ],
'comma-spacing': [ 'error', { before: false, after: true, }, ],
'comma-style': [ 'error', 'last', ],
'computed-property-spacing': [ 'error', 'never', ],
'eol-last': [ 'error', 'always', ],
'func-call-spacing': [ 'error', 'never', ],
'func-names': [ 'error', 'as-needed', ],
'func-style': [ 'error', 'declaration', { allowArrowFunctions: true, }, ],
'function-call-argument-newline': [ 'error', 'consistent', ],
'function-paren-newline': [ 'error', 'consistent', ],
'id-length': [ 'error', { min: 3, properties: 'never', }, ],
'implicit-arrow-linebreak': [ 'error', 'beside', ],
'indent': [ 'error', 2, {
ArrayExpression: 1,
CallExpression: { arguments: 2, },
FunctionDeclaration: { body: 1, parameters: 2, },
FunctionExpression: { body: 1, parameters: 2, },
ignoreComments: true,
ImportDeclaration: 1,
MemberExpression: 1,
ObjectExpression: 1,
outerIIFEBody: 1,
SwitchCase: 1,
VariableDeclarator: 2,
}, ],
'jsx-quotes': [ 'error', 'prefer-single', ],
'key-spacing': [ 'error', {
beforeColon: false,
afterColon: true,
}, ],
'keyword-spacing': [ 'error', {
before: true,
after: true,
}, ],
'linebreak-style': [ 'error', 'unix', ],
'lines-between-class-members': [ 'error', 'always', { exceptAfterSingleLine: true, }, ],
'max-depth': [ 'error', { max: 4, }, ],
'max-len': [ 'error', {
code: 150,
ignoreTrailingComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
}, ],
'max-params': [ 'warn', {
max: 3,
}, ],
'max-statements': [ 'warn', { max: 25, }, { ignoreTopLevelFunctions: true, }, ],
'max-statements-per-line': [ 'error', { max: 2, }, ],
'multiline-comment-style': [ 'error', 'separate-lines', ],
'multiline-ternary': [ 'error', 'always-multiline', ],
'new-cap': [ 'error', {
newIsCap: true,
}, ],
'new-parens': [ 'error', 'always', ],
'newline-per-chained-call': [ 'error', {
ignoreChainWithDepth: 2,
}, ],
'no-bitwise': [ 'error', ],
'no-continue': [ 'error', ],
'no-lonely-if': [ 'error', ],
'no-mixed-spaces-and-tabs': [ 'error', ],
'no-multi-assign': [ 'error', ],
'no-multiple-empty-lines': [ 'error', {
max: 2,
}, ],
'no-nested-ternary': [ 'error', ],
'no-new-object': [ 'error', ],
'no-trailing-spaces': [ 'error', ],
'no-underscore-dangle': [ 'error', {
allowAfterThis: true,
}, ],
'no-unneeded-ternary': [ 'error', ],
'no-whitespace-before-property': [ 'error', ],
'object-curly-newline': [ 'error', { consistent: true, }, ],
'object-curly-spacing': [ 'error', 'always', ],
'one-var': [ 'error', 'never', ],
'padded-blocks': [ 'error', 'never', ],
'padding-line-between-statements': [ 'error', { blankLine: 'always', prev: '*', next: 'return', }, ],
'prefer-object-spread': [ 'error', ],
'quote-props': [ 'error', 'consistent-as-needed', { keywords: true, }, ],
'quotes': [ 'error', 'single', { avoidEscape: true, }, ],
'semi': [ 'error', 'always', ],
'semi-spacing': [ 'error', ],
'semi-style': [ 'error', 'last', ],
'space-before-blocks': [ 'error', 'always', ],
'space-before-function-paren': [ 'error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
}, ],
'space-in-parens': [ 'error', 'never', ],
'space-infix-ops': [ 'error', ],
'spaced-comment': [ 'error', 'always', ],
'switch-colon-spacing': [ 'error', { after: false, before: true, }, ],
'wrap-regex': [ 'error', ],
};
const variableRules = {
'no-delete-var': [ 'error', ],
'no-label-var': [ 'error', ],
'no-shadow': [ 'error', ],
'no-shadow-restricted-names': [ 'error', ],
'no-undef': [ 'error', ],
'no-undef-init': [ 'error', ],
'no-unused-vars': [ 'error', ],
'no-use-before-define': [ 'error', {
functions: false,
}, ],
};
const es6Rules = {
'arrow-body-style': [ 'error', 'as-needed', { requireReturnForObjectLiteral: false, }, ],
'arrow-parens': [ 'error', 'as-needed', ],
'arrow-spacing': [ 'error', { before: true, after: true, }, ],
'constructor-super': [ 'error', ],
'generator-star-spacing': [ 'error', { before: false, after: true, }, ],
'no-class-assign': [ 'error', ],
'no-confusing-arrow': [ 'error', ],
'no-const-assign': [ 'error', ],
'no-dupe-class-members': [ 'error', ],
'no-duplicate-imports': [ 'error', ],
'no-new-symbol': [ 'error', ],
'no-this-before-super': [ 'error', ],
'no-useless-computed-key': [ 'error', ],
'no-useless-constructor': [ 'error', ],
'no-useless-rename': [ 'error', ],
'no-var': [ 'error', ],
'object-shorthand': [ 'error', 'consistent-as-needed', ],
'prefer-arrow-callback': [ 'error', ],
'prefer-const': [ 'error', {
destructuring: 'all',
ignoreReadBeforeAssign: true,
}, ],
'prefer-destructuring': [ 'error', {
array: true,
object: true,
}, ],
'prefer-numeric-literals': [ 'error', ],
'prefer-rest-params': [ 'error', ],
'prefer-spread': [ 'error', ],
'prefer-template': [ 'error', ],
'require-yield': [ 'error', ],
'rest-spread-spacing': [ 'error', 'never', ],
'symbol-description': [ 'error', ],
'template-curly-spacing': [ 'error', 'never', ],
'yield-star-spacing': [ 'error', 'after', ],
};
const bestPracticeRules = {
'array-callback-return': [ 'error', ],
'consistent-return': [ 'error', ],
'curly': [ 'error', ],
'default-case': [ 'error', ],
'default-param-last': [ 'error', ],
'dot-notation': [ 'error', ],
'eqeqeq': [ 'error', 'always', ],
'max-classes-per-file': [ 'error', 1, ],
'no-alert': [ 'warn', ],
'no-caller': [ 'error', ],
'no-case-declarations': [ 'error', ],
'no-div-regex': [ 'error', ],
'no-else-return': [ 'error', ],
'no-empty-pattern': [ 'error', ],
'no-eval': [ 'warn', ],
'no-extend-native': [ 'error', ],
'no-extra-bind': [ 'error', ],
'no-fallthrough': [ 'error', ],
'no-global-assign': [ 'error', ],
'no-implicit-coercion': [ 'error', ],
'no-implicit-globals': [ 'error', ],
'no-implied-eval': [ 'error', ],
'no-invalid-this': [ 'error', ],
'no-labels': [ 'error', ],
'no-lone-blocks': [ 'error', ],
'no-loop-func': [ 'error', ],
'no-magic-numbers': [ 'error', {
ignoreArrayIndexes: true,
ignore: [ -1, 0, 1, 2, ],
}, ],
'no-multi-spaces': [ 'error', { ignoreEOLComments: true, }, ],
'no-new-func': [ 'error', ],
'no-new-wrappers': [ 'error', ],
'no-octal': [ 'error', ],
'no-octal-escape': [ 'error', ],
'no-param-reassign': [ 'error', ],
'no-proto': [ 'error', ],
'no-redeclare': [ 'error', ],
'no-return-assign': [ 'error', 'always', ],
'no-return-await': [ 'error', ],
'no-script-url': [ 'error', ],
'no-self-assign': [ 'error', ],
'no-self-compare': [ 'error', ],
'no-throw-literal': [ 'error', ],
'no-unmodified-loop-condition': [ 'error', ],
'no-unused-expressions': [ 'error', ],
'no-useless-call': [ 'error', ],
'no-useless-catch': [ 'warn', ],
'no-useless-concat': [ 'error', ],
'no-useless-escape': [ 'error', ],
'no-void': [ 'error', ],
'no-with': [ 'error', ],
'prefer-promise-reject-errors': [ 'error', ],
'prefer-regex-literals': [ 'warn', ],
'radix': [ 'error', 'as-needed', ],
'require-await': [ 'error', ],
'require-unicode-regexp': [ 'warn', ],
'yoda': [ 'error', 'never', ],
};
const commonjsRules = {
'handle-callback-err': [ 'error', 'error', ],
'no-buffer-constructor': [ 'error', ],
'no-path-concat': [ 'error', ],
'no-sync': [ 'error', ],
};
const importRules = {
// eslint-plugin-import
// https://github.com/benmosher/eslint-plugin-import
'import/no-default-export': [ 'error', ],
'import/first': [ 'error', ],
'import/no-duplicates': [ 'error', ],
'import/newline-after-import': [ 'error', ],
'import/no-self-import': [ 'error', ],
'import/no-useless-path-segments': [ 'error', ],
'import/order': [ 'error', {
'newlines-between': 'never',
'groups': [
'builtin',
'external',
'internal',
],
}, ],
};
const unicornRules = {
// eslint-plugin-unicorn
// https://github.com/sindresorhus/eslint-plugin-unicorn
'unicorn/catch-error-name': [ 'error', ],
'unicorn/error-message': [ 'error', ],
'unicorn/explicit-length-check': [ 'error', ],
'unicorn/filename-case': [ 'error', { 'case': 'camelCase', }, ],
'unicorn/no-abusive-eslint-disable': [ 'error', ],
'unicorn/no-array-instanceof': [ 'error', ],
'unicorn/no-for-loop': [ 'error', ],
'unicorn/no-unreadable-array-destructuring': [ 'warn', ],
'unicorn/no-unsafe-regex': [ 'warn', ],
'unicorn/no-unused-properties': [ 'warn', ],
'unicorn/number-literal-case': [ 'error', ],
'unicorn/prefer-add-event-listener': [ 'error', ],
'unicorn/prefer-dataset': [ 'error', ],
'unicorn/prefer-event-key': [ 'error', ],
'unicorn/prefer-flat-map': [ 'error', ],
'unicorn/prefer-includes': [ 'error', ],
'unicorn/prefer-node-append': [ 'error', ],
'unicorn/prefer-node-remove': [ 'error', ],
'unicorn/prefer-query-selector': [ 'error', ],
'unicorn/prefer-spread': [ 'error', ],
'unicorn/prefer-starts-ends-with': [ 'error', ],
'unicorn/prefer-text-content': [ 'error', ],
};
const typescriptRules = {
// Typescript
'@typescript-eslint/no-unused-vars': [ 'error', ],
'@typescript-eslint/type-annotation-spacing': [ 'error', { after: true, }, ],
'@typescript-eslint/no-var-requires': [ 'error', ],
'@typescript-eslint/no-parameter-properties': [ 'error', ],
};
module.exports = {
'parser': '@typescript-eslint/parser',
'parserOptions': {
ecmaVersion: 2020,
sourceType: 'module',
},
'plugins': [
'import',
'unicorn',
'@typescript-eslint/eslint-plugin',
],
'env': {
es6: true,
browser: true,
node: true,
},
'extends': [
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
],
'rules': {
...bestPracticeRules,
...es6Rules,
...variableRules,
...stylisticRules,
...commonjsRules,
...importRules,
...unicornRules,
...typescriptRules,
},
};