-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.yml
507 lines (480 loc) · 13.8 KB
/
.eslintrc.yml
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# eslint-disable max-lines
root: true
parserOptions:
sourceType: module
ecmaVersion: 2021
ecmaFeatures:
modules: true
impliedStrict: true
jsx: true
reportUnusedDisableDirectives: true
plugins:
- react
- import
- unicorn
- promise
- sonarjs
- jsx-a11y
- sort-keys-fix
extends:
- eslint:all
- plugin:import/recommended
- plugin:unicorn/recommended
- plugin:compat/recommended
- plugin:jsx-a11y/strict
- plugin:react/all
- plugin:react-hooks/recommended
- plugin:promise/recommended
- plugin:array-func/all
- plugin:sonarjs/recommended
- plugin:eslint-comments/recommended
# - plugin:json-schema-validator/recommended
- plugin:toml/standard
- plugin:@next/next/recommended
- prettier
env:
es6: true
browser: true
node: true
settings:
react:
version: detect
import/resolver:
node:
extensions:
- '.js'
- '.jsx'
# for eslint-plugin-compat, @see https://github.com/amilajack/eslint-plugin-compat#adding-polyfills
polyfills:
- Promise
- fetch
rules:
# config for core eslint rules
id-length:
- error
- exceptions: ['_']
max-lines-per-function:
- warn
- max: 120
skipComments: true
skipBlankLines: true
max-statements: warn
no-console:
- warn
- allow:
- warn
- error
no-magic-numbers:
- warn
- ignoreArrayIndexes: true
ignoreDefaultValues: true
detectObjects: true
enforceConst: false
no-unused-vars:
- error
- argsIgnorePattern: '^_'
varsIgnorePattern: '^_'
no-void:
- error
- allowAsStatement: true
# integrating with import plugin
sort-imports:
- error
- allowSeparatedGroups: true
ignoreDeclarationSort: true
# I want to re-enable those
func-style: off
sort-keys: off
# disable core rules I don't agree with
capitalized-comments: off
line-comment-position: off
no-inline-comments: off
no-warning-comments: off
no-ternary: off
no-undefined: off
no-underscore-dangle: off
one-var: off
# config for react linter rules
react/jsx-filename-extension:
- error
- extensions:
- '.jsx'
- '.tsx'
react/no-unknown-property:
- error
- ignore:
- jsx
- global
react/jsx-sort-props:
- error
- callbacksLast: true
shorthandFirst: true
reservedFirst: true
react/function-component-definition:
- error
- namedComponents: 'arrow-function'
unnamedComponents: 'arrow-function'
# I want to re-enable those
react/no-multi-comp: off
react/forbid-component-props: off
# disable some react rules
react/react-in-jsx-scope: off
react/jsx-no-literals: off
react/jsx-max-depth: off
react/require-default-props: off
# enable some non-recommended unicorn rules
unicorn/import-index: error
# unicorn/no-keyword-prefix: error
unicorn/no-unsafe-regex: error
unicorn/no-unused-properties: error
unicorn/prefer-at: error
unicorn/prefer-object-has-own: error
unicorn/prefer-string-replace-all: error
unicorn/prefer-top-level-await: error
unicorn/string-content: error
# configure some unicorn rules
unicorn/expiring-todo-comments:
- warn
- allowWarningComments: false
ignoreDatesOnPullRequests: true
unicorn/filename-case:
- error
- case: kebabCase
ignore:
- '^__coverage__.ts$'
unicorn/prevent-abbreviations:
- error
- checkProperties: true
replacements:
props:
properties: false
allowList:
args: true
dest: true
devServer: true
e2e: true
env: true
i18n: true
params: true
src: true
# disable some unicorn rules
unicorn/prefer-spread: off # in favour of array-func/prefer-array-from
unicorn/no-empty-file: off
# I want to re-enable those
unicorn/prefer-module: off
unicorn/prefer-node-protocol: off # enable when import/no-unresolved properly supports this
# configure import plugin
import/dynamic-import-chunkname: error
import/exports-last: error
import/extensions: error
import/first: error
import/group-exports: error
import/max-dependencies:
- error
- max: 10
import/newline-after-import: error
import/no-absolute-path: error
import/no-amd: error
import/no-anonymous-default-export: error
import/no-cycle: warn # slow
import/no-deprecated: error # slow
import/no-dynamic-require: error
import/no-extraneous-dependencies: error
import/no-import-module-exports: error
import/no-mutable-exports: error
import/no-named-default: error # slow
import/no-namespace: error
import/no-nodejs-modules:
- error
- allow: [querystring]
import/no-relative-packages: error
import/no-restricted-paths: error
import/no-self-import: error
import/no-unassigned-import: error
import/no-unused-modules: error
import/no-useless-path-segments: error
import/no-webpack-loader-syntax: error
import/order:
- error
- newlines-between: always
warnOnUnassignedImports: true
alphabetize:
order: asc # sort in ascending order. Options: ['ignore', 'asc', 'desc']
caseInsensitive: false # ignore case. Options: [true, false]
# difficult topic,
# @see https://github.com/airbnb/javascript/issues/1365
# @see https://github.com/ni/javascript-styleguide/issues/39#issuecomment-856246109
import/prefer-default-export: error
# disable some import rules
import/no-commonjs: off
import/no-default-export: off
import/no-internal-modules: off
import/no-named-export: off
import/no-relative-parent-imports: off
import/unambiguous: off
# the default rule gets messed up with nextjs' ways of doing links
jsx-a11y/anchor-is-valid:
- error
- components:
- Link
specialLink:
- hrefLeft
- hrefRight
aspects:
- invalidHref
- preferButton
jsx-a11y/lang: error
jsx-a11y/label-has-for: off # deprecated
eslint-comments/no-unused-disable: error
promise/avoid-new: error
promise/prefer-await-to-then: warn
promise/prefer-await-to-callbacks: warn
sort-keys-fix/sort-keys-fix: error
'@next/next/no-img-element': off
'@next/next/no-page-custom-font': off
toml/array-bracket-spacing:
- error
- never
overrides:
# Config for Typescript Linting
- files:
- '**/*.ts'
- '**/*.tsx'
parser: '@typescript-eslint/parser'
parserOptions:
project:
# - tsconfig.json
- tsconfig.eslint.json
- cypress/tsconfig.json
tsconfigRootDir: '.'
warnOnUnsupportedTypeScriptVersion: true
plugins:
- '@typescript-eslint'
- tsdoc
extends:
- plugin:import/recommended
- plugin:import/typescript
- plugin:@typescript-eslint/all
- prettier
settings:
import/parsers:
'@typescript-eslint/parser':
- '.ts'
- '.tsx'
import/resolver:
typescript:
- alwaysTryTypes: true
project: tsconfig.json
node:
extensions:
- '.ts'
- '.tsx'
rules:
# re-enable later when renaming stuff
'@typescript-eslint/naming-convention': off
# re-enable when I want to restict usage of a specific package
'@typescript-eslint/no-restricted-imports': off
# @typescript-eslint rules config
'@typescript-eslint/consistent-type-definitions': [error, type]
'@typescript-eslint/sort-type-union-intersection-members': warn
'@typescript-eslint/no-unnecessary-condition': warn
'@typescript-eslint/no-misused-promises': warn
'@typescript-eslint/no-namespace': [error, { 'allowDeclarations': true }]
'@typescript-eslint/no-redundant-type-constituents': warn
'@typescript-eslint/no-type-alias':
- error
- allowAliases: always
allowLiterals: always
allowGenerics: always
'@typescript-eslint/no-unused-vars':
- error
- argsIgnorePattern: '^_'
varsIgnorePattern: '^_'
tsdoc/syntax: warn
# disable some @typescript-eslint rules
'@typescript-eslint/explicit-function-return-type': off
'@typescript-eslint/explicit-member-accessibility': off
'@typescript-eslint/explicit-module-boundary-types': off
'@typescript-eslint/no-magic-numbers': off
'@typescript-eslint/non-nullable-type-assertion-style': off
'@typescript-eslint/prefer-readonly-parameter-types': off
# improved versions of core rules in @typescript-eslint
# @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/README.md#extension-rules
brace-style: off
comma-dangle: off
comma-spacing: off
default-param-last: off
dot-notation: off
func-call-spacing: off
indent: off
init-declarations: off
keyword-spacing: off
lines-between-class-members: off
no-array-constructor: off
no-dupe-class-members: off
no-duplicate-imports: off
no-empty-function: off
no-extra-parens: off
no-extra-semi: off
no-implied-eval: off
no-invalid-this: off
no-loop-func: off
no-loss-of-precision: off
no-magic-numbers: off
no-redeclare: off
no-restricted-imports: off
no-shadow: off
no-throw-literal: off
no-unused-expressions: off
no-unused-vars: off
no-use-before-define: off
no-useless-constructor: off
object-curly-spacing: off
quotes: off
require-await: off
return-await: off
semi: off
space-before-function-paren: off
space-infix-ops: off
# rules that should be disabled as per FAQ
# @see https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#my-linting-feels-really-slow
'@typescript-eslint/indent': off
import/named: off
import/namespace: off
import/default: off
import/no-named-as-default-member: off
# nested overrides are allowed, the schemastore needs an update...
# https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work
# https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/eslintrc.json
# wip-eslint-disable-next-line json-schema-validator/no-invalid
overrides:
# Config for typescript cypress Linting
- files:
- 'cypress/**/*.ts'
- 'cypress/**/*.tsx'
- '**/*.spec.ts'
- '**/*.spec.tsx'
plugins:
- cypress
extends:
- plugin:cypress/recommended
env:
cypress/globals: true
rules:
no-console: off
no-unused-expressions: off
no-magic-numbers: off
multiline-comment-style: off
max-lines-per-function: off
max-statements: off
max-lines: off
id-length: off
cypress/no-unnecessary-waiting: off
unicorn/consistent-function-scoping:
- error
- checkArrowFunctions: false
# try to enable the following rules at some point in the future
require-unicode-regexp: off
prefer-destructuring: off
no-invalid-this: off
func-names: off
no-empty-function: off
import/no-unassigned-import: off
# Config for typescript jest Linting
- files:
- 'test/**/*.ts'
- 'test/**/*.tsx'
- '**/*.test.ts'
- '**/*.test.tsx'
plugins:
- jest
- jest-dom
- jest-formatting
extends:
- plugin:jest/all
- plugin:jest-dom/recommended
- plugin:jest-formatting/strict
env:
jest: true
jest/globals: true
rules:
'@typescript-eslint/no-unsafe-call': off
'@typescript-eslint/no-unsafe-return': off
'@typescript-eslint/no-unsafe-argument': off
'@typescript-eslint/no-unsafe-assignment': off
'@typescript-eslint/no-unsafe-member-access': off
jest/prefer-expect-assertions: warn
# allow triple-slash-directives in typing files
- files:
- '**/*.d.ts'
rules:
multiline-comment-style: off
spaced-comment:
- error
- always
- markers: ['/']
# Config for default Cypress Linting
- files:
- 'cypress/**/*.js'
- 'cypress/**/*.jsx'
- '**/*.spec.js'
- '**/*.spec.jsx'
plugins:
- cypress
extends:
- plugin:cypress/recommended
env:
cypress/globals: true
rules:
no-console: off
no-unused-expressions: off
no-magic-numbers: off
multiline-comment-style: off
max-lines-per-function: off
max-statements: off
max-lines: off
id-length: off
spaced-comment:
- error
- always
- markers: ['/']
cypress/no-unnecessary-waiting: off
sort-keys-fix/sort-keys-fix: off
unicorn/consistent-function-scoping:
- error
- checkArrowFunctions: false
# try to enable the following rules at some point in the future
require-unicode-regexp: off
prefer-destructuring: off
no-invalid-this: off
func-names: off
no-empty-function: off
import/no-unassigned-import: off
# to lazy to fix those atm
promise/catch-or-return: off
promise/always-return: off
promise/no-nesting: off
promise/prefer-await-to-then: off
sonarjs/no-duplicate-string: off
sonarjs/no-identical-functions: off
# Config for general jest Linting
- files:
- 'test/**/*.js'
- 'test/**/*.jsx'
- '**/*.test.js'
- '**/*.test.jsx'
plugins:
- jest
- jest-dom
- jest-formatting
extends:
- plugin:jest/all
- plugin:jest-dom/recommended
- plugin:jest-formatting/strict
env:
jest: true
jest/globals: true
rules:
jest/unbound-method: off
import/no-unresolved: off
# eslint-enable max-lines