-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.eslintrc.js
338 lines (327 loc) · 11.4 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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
module.exports = {
root: true,
plugins: [
'import',
'jsdoc',
'promise',
'react',
'react-hooks',
'security',
'unicorn',
'@typescript-eslint',
'prettier',
],
extends: [
'airbnb',
'airbnb-typescript',
'airbnb/hooks',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@next/next/recommended',
'plugin:prettier/recommended'
],
env: {
browser: true,
es6: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
project: './tsconfig.json',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts'],
},
},
jsdoc: {
preferredTypes: {
Array: 'Array<object>', //
'Array.': 'Array<object>',
'Array<>': '[]',
'Array.<>': '[]',
'Promise.<>': 'Promise<>',
},
},
},
rules: {
'prettier/prettier': [
'error',
{},
{
usePrettierrc: true,
},
],
'arrow-body-style': ['error', 'as-needed', { requireReturnForObjectLiteral: true }],
'class-methods-use-this': 'off',
curly: ['error', 'all'],
camelcase: 'off',
'comma-spacing': 'off',
eqeqeq: ['error', 'smart'],
'func-names': 'error',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
'id-length': ['error', { exceptions: ['_', '$', 'e', 'i', 'j', 'k', 'q', 'x', 'y'] }],
indent: 'off',
'max-len': 'off',
'no-confusing-arrow': ['error', { allowParens: false }],
'no-continue': 'off',
'no-dupe-class-members': 'off',
'no-extra-semi': 'off',
'no-loop-func': 'off',
'no-mixed-operators': 'error',
'no-new': 'off',
'no-plusplus': 'off',
'no-prototype-builtins': 'off',
'no-restricted-syntax': ['error', 'DebuggerStatement', 'LabeledStatement', 'WithStatement', 'SequenceExpression'],
'no-underscore-dangle': 'off',
'no-use-before-define': 'off',
'no-useless-constructor': 'off',
'no-unused-expressions': 'off',
'no-void': ['error', { allowAsStatement: true }],
'prefer-spread': 'error',
'prefer-destructuring': 'off',
radix: 'off',
'spaced-comment': 'off',
'import/prefer-default-export': 'off',
'import/no-extraneous-dependencies': 'off',
'import/extensions': ['error', 'never'],
'import/order': [
'error',
{
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
pathGroups: [
{
pattern: '@mpirik/**',
group: 'external',
position: 'after',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'off',
'jsdoc/check-param-names': 'off',
'jsdoc/check-tag-names': 'error',
'jsdoc/check-types': 'error',
'jsdoc/newline-after-description': 'off',
'jsdoc/no-undefined-types': 'off',
'jsdoc/require-description': 'off',
'jsdoc/require-description-complete-sentence': 'off',
'jsdoc/require-example': 'off',
'jsdoc/require-hyphen-before-param-description': 'error',
'jsdoc/require-param': 'error',
'jsdoc/require-param-description': 'off',
'jsdoc/require-param-name': 'error',
'jsdoc/require-param-type': 'error',
'jsdoc/require-returns-description': 'off',
'jsdoc/require-returns-type': 'error',
'jsdoc/valid-types': 'error',
'jsx-a11y/alt-text': 'error',
'jsx-a11y/anchor-has-content': 'error',
// Disable href validation for next.js Link
"jsx-a11y/anchor-is-valid": [ "error", {
"components": [ "Link" ],
"specialLink": [ "hrefLeft", "hrefRight" ],
"aspects": [ "invalidHref", "preferButton" ]
}],
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
'jsx-a11y/aria-props': 'error',
'jsx-a11y/aria-proptypes': 'error',
'jsx-a11y/aria-role': ['error', { ignoreNonDOM: true }],
'jsx-a11y/aria-unsupported-elements': 'error',
'jsx-a11y/heading-has-content': 'error',
'jsx-a11y/iframe-has-title': 'error',
'jsx-a11y/img-redundant-alt': 'error',
'jsx-a11y/no-access-key': 'error',
'jsx-a11y/no-distracting-elements': 'error',
'jsx-a11y/no-redundant-roles': 'error',
'jsx-a11y/role-has-required-aria-props': 'error',
'jsx-a11y/role-supports-aria-props': 'error',
'jsx-a11y/scope': 'error',
'promise/always-return': 'error',
'promise/always-catch': 'off',
'promise/catch-or-return': ['error', { allowThen: true }],
'promise/no-native': 'off',
'promise/param-names': 'error',
'react/forbid-foreign-prop-types': ['error', { allowInPropTypes: true }],
'react/jsx-closing-bracket-location': 'error',
'react/jsx-no-comment-textnodes': 'error',
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-script-url': 'error',
'react/jsx-no-target-blank': 'error',
'react/jsx-no-undef': 'error',
'react/jsx-pascal-case': [
'error',
{
allowAllCaps: true,
ignore: [],
},
],
'react/jsx-props-no-multi-spaces': 'error',
'react/no-danger-with-children': 'error',
'react/no-deprecated': 'error',
'react/no-direct-mutation-state': 'error',
'react/no-is-mounted': 'error',
'react/no-typos': 'error',
'react/no-unsafe': 'error',
'react/no-unstable-nested-components': 'error',
'react/prefer-stateless-function': 'error',
'react/require-render-return': 'error',
'react/self-closing-comp': 'error',
'react/style-prop-object': 'error',
// https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
'security/detect-buffer-noassert': 'error',
'security/detect-child-process': 'error',
'security/detect-disable-mustache-escape': 'error',
'security/detect-eval-with-expression': 'error',
'security/detect-new-buffer': 'error',
'security/detect-no-csrf-before-method-override': 'error',
'security/detect-non-literal-fs-filename': 'error',
'security/detect-non-literal-regexp': 'error',
'security/detect-non-literal-require': 'off',
'security/detect-object-injection': 'off',
'security/detect-possible-timing-attacks': 'error',
'security/detect-pseudoRandomBytes': 'error',
'security/detect-unsafe-regex': 'error',
'unicorn/better-regex': 'error',
'unicorn/custom-error-definition': 'error',
'unicorn/error-message': 'error',
'unicorn/no-abusive-eslint-disable': 'error',
'unicorn/no-array-for-each': 'error',
'unicorn/no-array-method-this-argument': 'error',
'unicorn/no-array-reduce': 'error',
'unicorn/no-for-loop': 'error',
'unicorn/no-instanceof-array': 'error',
'unicorn/no-new-array': 'error',
'unicorn/no-new-buffer': 'error',
'unicorn/no-useless-spread': 'error',
'unicorn/prefer-array-find': 'error',
'unicorn/prefer-array-flat': 'error',
'unicorn/prefer-array-flat-map': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/prefer-number-properties': 'error',
'unicorn/prefer-object-from-entries': 'error',
'unicorn/prefer-set-has': 'error',
'@typescript-eslint/array-type': ['error', { default: 'array' }],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/comma-spacing': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports', disallowTypeAnnotations: true }],
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': ['error'],
'@typescript-eslint/member-ordering': [
'error',
{
default: [
// Index signature
'signature',
// Fields
'private-field',
'public-field',
'protected-field',
// Constructors
'public-constructor',
'protected-constructor',
'private-constructor',
// Methods
'public-method',
'protected-method',
'private-method',
],
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'property',
format: null,
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-extra-semi': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-parameter-properties': ['error', { allows: ['readonly'] }],
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-throw-literal': 'error',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-use-before-define': [
'error',
{
functions: false,
classes: true,
variables: true,
enums: true,
typedefs: false,
ignoreTypeReferences: false,
},
],
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-regexp-exec': 'warn',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/sort-type-union-intersection-members': 'error',
'@typescript-eslint/unbound-method': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@next/next/no-img-element': 'off',
},
overrides: [{
files: ['components/**.tsx'],
rules: {
'@typescript-eslint/no-misused-promises': 'off',
},
}],
};