@@ -33,26 +33,39 @@ module.exports = {
33
33
'plugin:markdown/recommended' ,
34
34
'plugin:import/errors' ,
35
35
'plugin:eslint-comments/recommended' ,
36
+ 'plugin:unicorn/recommended' ,
37
+ 'plugin:promise/recommended' ,
36
38
'plugin:prettier/recommended' ,
37
39
] ,
38
40
globals : {
39
41
console : 'readonly' ,
40
42
} ,
41
43
overrides : [
42
44
{
43
- extends : [ 'plugin:@typescript-eslint/strict' , 'plugin:import/typescript' ] ,
45
+ extends : [
46
+ 'plugin:@typescript-eslint/eslint-recommended' ,
47
+ 'plugin:@typescript-eslint/strict' ,
48
+ 'plugin:@typescript-eslint/stylistic' ,
49
+ 'plugin:import/typescript' ,
50
+ ] ,
44
51
files : [ '*.ts' , '*.tsx' ] ,
45
52
plugins : [ '@typescript-eslint/eslint-plugin' , 'local' ] ,
46
53
rules : {
47
54
'@typescript-eslint/array-type' : [ 'error' , { default : 'generic' } ] ,
48
55
'@typescript-eslint/ban-types' : 'error' ,
56
+ '@typescript-eslint/consistent-type-imports' : [
57
+ 'error' ,
58
+ { fixStyle : 'inline-type-imports' , disallowTypeAnnotations : false } ,
59
+ ] ,
60
+ '@typescript-eslint/no-import-type-side-effects' : 'error' ,
49
61
'@typescript-eslint/no-inferrable-types' : 'error' ,
50
62
'@typescript-eslint/no-unused-vars' : [
51
63
'error' ,
52
64
{ argsIgnorePattern : '^_' } ,
53
65
] ,
54
66
'@typescript-eslint/prefer-ts-expect-error' : 'error' ,
55
67
'@typescript-eslint/no-var-requires' : 'off' ,
68
+ '@typescript-eslint/consistent-indexed-object-style' : 'off' ,
56
69
// TS verifies these
57
70
'consistent-return' : 'off' ,
58
71
'no-dupe-class-members' : 'off' ,
@@ -62,24 +75,14 @@ module.exports = {
62
75
'@typescript-eslint/no-explicit-any' : 'off' ,
63
76
'@typescript-eslint/no-non-null-assertion' : 'off' ,
64
77
'@typescript-eslint/no-invalid-void-type' : 'off' ,
65
-
66
- // TODO: part of "stylistic" rules, remove explicit activation when that lands
67
- '@typescript-eslint/no-empty-function' : 'error' ,
68
- '@typescript-eslint/no-empty-interface' : 'error' ,
78
+ '@typescript-eslint/consistent-type-definitions' : 'off' ,
69
79
70
80
// not needed to be enforced for TS
71
81
'import/namespace' : 'off' ,
72
82
} ,
73
83
} ,
74
84
{
75
85
files : [
76
- 'packages/jest-jasmine2/src/jasmine/Env.ts' ,
77
- 'packages/jest-jasmine2/src/jasmine/ReportDispatcher.ts' ,
78
- 'packages/jest-jasmine2/src/jasmine/Spec.ts' ,
79
- 'packages/jest-jasmine2/src/jasmine/SpyStrategy.ts' ,
80
- 'packages/jest-jasmine2/src/jasmine/Suite.ts' ,
81
- 'packages/jest-jasmine2/src/jasmine/createSpy.ts' ,
82
- 'packages/jest-jasmine2/src/jasmine/jasmineLight.ts' ,
83
86
'packages/jest-mock/src/__tests__/index.test.ts' ,
84
87
'packages/jest-mock/src/index.ts' ,
85
88
'packages/pretty-format/src/__tests__/Immutable.test.ts' ,
@@ -94,13 +97,7 @@ module.exports = {
94
97
files : [
95
98
'packages/expect/src/index.ts' ,
96
99
'packages/jest-fake-timers/src/legacyFakeTimers.ts' ,
97
- 'packages/jest-jasmine2/src/jasmine/Env.ts' ,
98
- 'packages/jest-jasmine2/src/jasmine/ReportDispatcher.ts' ,
99
- 'packages/jest-jasmine2/src/jasmine/Spec.ts' ,
100
- 'packages/jest-jasmine2/src/jasmine/Suite.ts' ,
101
- 'packages/jest-jasmine2/src/jasmine/jasmineLight.ts' ,
102
100
'packages/jest-jasmine2/src/jestExpect.ts' ,
103
- 'packages/jest-resolve/src/resolver.ts' ,
104
101
] ,
105
102
rules : {
106
103
'local/prefer-spread-eventually' : 'warn' ,
@@ -117,8 +114,6 @@ module.exports = {
117
114
'packages/expect-utils/src/utils.ts' ,
118
115
'packages/jest-core/src/collectHandles.ts' ,
119
116
'packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts' ,
120
- 'packages/jest-jasmine2/src/jasmine/SpyStrategy.ts' ,
121
- 'packages/jest-jasmine2/src/jasmine/Suite.ts' ,
122
117
'packages/jest-leak-detector/src/index.ts' ,
123
118
'packages/jest-matcher-utils/src/index.ts' ,
124
119
'packages/jest-mock/src/__tests__/index.test.ts' ,
@@ -151,6 +146,13 @@ module.exports = {
151
146
] ,
152
147
} ,
153
148
} ,
149
+ {
150
+ files : 'e2e/coverage-remapping/covered.ts' ,
151
+ rules : {
152
+ 'no-constant-binary-expression' : 'off' ,
153
+ 'no-constant-condition' : 'off' ,
154
+ } ,
155
+ } ,
154
156
155
157
// 'eslint-plugin-jest' rules for test and test related files
156
158
{
@@ -213,9 +215,15 @@ module.exports = {
213
215
'jest/no-focused-tests' : 'off' ,
214
216
'jest/require-to-throw-message' : 'off' ,
215
217
'no-console' : 'off' ,
218
+ 'no-constant-condition' : 'off' ,
216
219
'no-undef' : 'off' ,
217
220
'no-unused-vars' : 'off' ,
218
221
'sort-keys' : 'off' ,
222
+ 'unicorn/consistent-function-scoping' : 'off' ,
223
+ 'unicorn/error-message' : 'off' ,
224
+ 'unicorn/no-await-expression-member' : 'off' ,
225
+ 'unicorn/no-static-only-class' : 'off' ,
226
+ 'unicorn/prefer-number-properties' : 'off' ,
219
227
} ,
220
228
} ,
221
229
// demonstration of matchers usage
@@ -278,6 +286,16 @@ module.exports = {
278
286
'no-restricted-imports' : 'off' ,
279
287
} ,
280
288
} ,
289
+ {
290
+ files : [ 'examples/angular/**/*' ] ,
291
+ rules : {
292
+ // Angular DI for some reason doesn't work with type imports
293
+ '@typescript-eslint/consistent-type-imports' : [
294
+ 'error' ,
295
+ { prefer : 'no-type-imports' , disallowTypeAnnotations : false } ,
296
+ ] ,
297
+ } ,
298
+ } ,
281
299
{
282
300
files : 'packages/**/*.ts' ,
283
301
rules : {
@@ -301,6 +319,7 @@ module.exports = {
301
319
rules : {
302
320
'@typescript-eslint/ban-ts-comment' : 'off' ,
303
321
'@typescript-eslint/no-empty-function' : 'off' ,
322
+ '@typescript-eslint/class-literal-property-style' : 'off' ,
304
323
} ,
305
324
} ,
306
325
{
@@ -313,6 +332,9 @@ module.exports = {
313
332
] ,
314
333
rules : {
315
334
'@typescript-eslint/explicit-module-boundary-types' : 'off' ,
335
+ 'unicorn/consistent-function-scoping' : 'off' ,
336
+ 'unicorn/no-await-expression-member' : 'off' ,
337
+ 'unicorn/prefer-spread' : 'off' ,
316
338
} ,
317
339
} ,
318
340
{
@@ -321,8 +343,12 @@ module.exports = {
321
343
'packages/expect-utils/src/jasmineUtils.ts' ,
322
344
] ,
323
345
rules : {
346
+ '@typescript-eslint/ban-types' : 'off' ,
324
347
'eslint-comments/disable-enable-pair' : 'off' ,
325
348
'eslint-comments/no-unlimited-disable' : 'off' ,
349
+ 'prefer-rest-params' : 'off' ,
350
+ 'prefer-spread' : 'off' ,
351
+ 'sort-keys ' : 'off' ,
326
352
} ,
327
353
} ,
328
354
{
@@ -342,11 +368,13 @@ module.exports = {
342
368
'website/**' ,
343
369
'**/__benchmarks__/**' ,
344
370
'**/__tests__/**' ,
345
- 'packages/jest-types/ **/*' ,
371
+ '**/__typetests__/* *' ,
346
372
'.eslintplugin/**' ,
347
373
] ,
348
374
rules : {
349
375
'import/no-extraneous-dependencies' : 'off' ,
376
+ 'unicorn/consistent-function-scoping' : 'off' ,
377
+ 'unicorn/error-message' : 'off' ,
350
378
} ,
351
379
} ,
352
380
{
@@ -389,12 +417,43 @@ module.exports = {
389
417
'no-unused-vars' : 'off' ,
390
418
} ,
391
419
} ,
420
+ {
421
+ files : 'packages/jest-mock/src/__tests__/**/*' ,
422
+ rules : {
423
+ 'unicorn/no-static-only-class' : 'off' ,
424
+ } ,
425
+ } ,
426
+ {
427
+ files : '**/*.mjs' ,
428
+ rules : {
429
+ 'unicorn/prefer-top-level-await' : 'error' ,
430
+ } ,
431
+ } ,
432
+ {
433
+ files : [
434
+ 'e2e/coverage-report/__mocks__/sumDependency.js' ,
435
+ 'e2e/require-main-after-create-require/empty.js' ,
436
+ 'packages/create-jest/src/__tests__/__fixtures__/**/*' ,
437
+ 'packages/jest-core/src/__tests__/**/*' ,
438
+ 'packages/jest-haste-map/src/__tests__/test_dotfiles_root/**/*' ,
439
+ 'packages/jest-resolve/src/__mocks__/**/*' ,
440
+ ] ,
441
+ rules : {
442
+ 'unicorn/no-empty-file' : 'off' ,
443
+ } ,
444
+ } ,
445
+ {
446
+ files : 'packages/expect/src/__tests__/*.test.js' ,
447
+ rules : {
448
+ 'unicorn/prefer-number-properties' : 'off' ,
449
+ } ,
450
+ } ,
392
451
] ,
393
452
parser : '@typescript-eslint/parser' ,
394
453
parserOptions : {
395
454
sourceType : 'module' ,
396
455
} ,
397
- plugins : [ 'import' , 'jsdoc' , 'unicorn' ] ,
456
+ plugins : [ 'import' , 'jsdoc' ] ,
398
457
rules : {
399
458
'accessor-pairs' : [ 'warn' , { setWithoutGet : true } ] ,
400
459
'block-scoped-var' : 'off' ,
@@ -416,6 +475,7 @@ module.exports = {
416
475
'handle-callback-err' : 'off' ,
417
476
'id-length' : 'off' ,
418
477
'id-match' : 'off' ,
478
+ 'import/no-duplicates' : 'error' ,
419
479
'import/no-extraneous-dependencies' : [
420
480
'error' ,
421
481
{
@@ -473,7 +533,8 @@ module.exports = {
473
533
{ allow : [ 'warn' , 'error' , 'time' , 'timeEnd' , 'timeStamp' ] } ,
474
534
] ,
475
535
'no-const-assign' : 'error' ,
476
- 'no-constant-condition' : 'off' ,
536
+ 'no-constant-condition' : 'error' ,
537
+ 'no-constant-binary-expression' : 'error' ,
477
538
'no-continue' : 'off' ,
478
539
'no-control-regex' : 'off' ,
479
540
'no-debugger' : 'error' ,
@@ -515,9 +576,7 @@ module.exports = {
515
576
'no-multi-str' : 'error' ,
516
577
'no-multiple-empty-lines' : 'off' ,
517
578
'no-native-reassign' : [ 'error' , { exceptions : [ 'Map' , 'Set' ] } ] ,
518
- 'no-negated-condition' : 'off' ,
519
579
'no-negated-in-lhs' : 'error' ,
520
- 'no-nested-ternary' : 'off' ,
521
580
'no-new' : 'warn' ,
522
581
'no-new-func' : 'error' ,
523
582
'no-new-object' : 'warn' ,
@@ -579,6 +638,11 @@ module.exports = {
579
638
'prefer-arrow-callback' : [ 'error' , { allowNamedFunctions : true } ] ,
580
639
'prefer-const' : 'error' ,
581
640
'prefer-template' : 'error' ,
641
+
642
+ 'promise/always-return' : 'off' ,
643
+ 'promise/catch-or-return' : 'off' ,
644
+ 'promise/no-callback-in-promise' : 'off' ,
645
+
582
646
quotes : [
583
647
'error' ,
584
648
'single' ,
@@ -600,13 +664,43 @@ module.exports = {
600
664
'wrap-regex' : 'off' ,
601
665
yoda : 'off' ,
602
666
603
- 'unicorn/explicit-length-check' : 'error' ,
604
- 'unicorn/no-array-for-each' : 'error' ,
605
- 'unicorn/no-negated-condition' : 'error' ,
606
- 'unicorn/numeric-separators-style' : 'error' ,
607
- 'unicorn/prefer-default-parameters' : 'error' ,
608
- 'unicorn/prefer-includes' : 'error' ,
609
- 'unicorn/template-indent' : 'error' ,
667
+ // doesn't work without ESModuleInterop
668
+ 'unicorn/import-style' : 'off' ,
669
+ // we're a CJS project
670
+ 'unicorn/prefer-module' : 'off' ,
671
+
672
+ // enforced by `@typescript-eslint/no-this-alias` already
673
+ 'unicorn/no-this-assignment' : 'off' ,
674
+
675
+ // Not an issue with TypeScript
676
+ 'unicorn/no-array-callback-reference' : 'off' ,
677
+
678
+ // reduce is fine
679
+ 'unicorn/no-array-reduce' : 'off' ,
680
+
681
+ // this is very aggressive (600+ files changed). might make sense to apply bit by bit over time?
682
+ 'unicorn/prevent-abbreviations' : 'off' ,
683
+
684
+ // nah
685
+ 'unicorn/consistent-destructuring' : 'off' ,
686
+ 'unicorn/no-lonely-if' : 'off' ,
687
+ 'unicorn/no-null' : 'off' ,
688
+ 'unicorn/no-process-exit' : 'off' ,
689
+ 'unicorn/no-useless-undefined' : 'off' ,
690
+ 'unicorn/prefer-event-target' : 'off' ,
691
+ 'unicorn/prefer-switch' : 'off' ,
692
+ 'unicorn/prefer-ternary' : 'off' ,
693
+ 'unicorn/prefer-top-level-await' : 'off' ,
694
+ 'unicorn/switch-case-braces' : 'off' ,
695
+
696
+ // TODO: decide whether or not we want these
697
+ 'unicorn/filename-case' : 'off' ,
698
+ 'unicorn/prefer-reflect-apply' : 'off' ,
699
+
700
+ // enabling this is blocked by https://github.com/microsoft/rushstack/issues/2780
701
+ 'unicorn/prefer-export-from' : 'off' ,
702
+ // enabling this is blocked by https://github.com/jestjs/jest/pull/14297
703
+ 'unicorn/prefer-node-protocol' : 'off' ,
610
704
} ,
611
705
settings : {
612
706
'import/ignore' : [ 'react-native' ] ,
0 commit comments