linter-bundle 2.19.0 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,9 +6,39 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.18.0...HEAD)
9
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.21.0...HEAD)
10
10
 
11
- ## [2.19.0] - 2022.08.28
11
+ ## [2.21.0] - 2022-09-14
12
+
13
+ ### Added
14
+
15
+ - [eslint] New rule [`no-unnecessary-typeof`](./eslint/rules/no-unnecessary-typeof.md), which prevents `typeof` checks at runtime, if a `typeof` operant has only one type in TypeScript.
16
+
17
+ ### Changed
18
+
19
+ - [eslint] Updated `@typescript-eslint` from `5.36.1` to `5.37.0`
20
+ - [eslint] Updated `eslint` from `8.23.0` to `8.23.1`
21
+ - [eslint] Updated `eslint-import-resolver-typescript` from `3.5.0` to `3.5.1`
22
+ - [eslint] Updated `eslint-plugin-functional` from `4.2.2` to `4.3.1`
23
+ - [eslint] Updated `eslint-plugin-jest` from `27.0.1` to `27.0.4`
24
+ - [eslint] Updated `eslint-plugin-react` from `7.31.1` to `7.31.8`
25
+
26
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.20.0...v2.21.0)
27
+
28
+ ## [2.20.0] - 2022-09-01
29
+
30
+ ### Changed
31
+
32
+ - [eslint] Updated `@typescript-eslint` from `5.35.1` to `5.36.1`
33
+ - [eslint] Updated `eslint-plugin-jest` from `26.9.0` to `27.0.1`
34
+
35
+ ### Removed
36
+
37
+ - [eslint/overrides-jest] Removed deprecated `jest/no-jest-import`
38
+
39
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.19.0...v2.20.0)
40
+
41
+ ## [2.19.0] - 2022-08-28
12
42
 
13
43
  ### Changed
14
44
 
@@ -27,7 +57,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
27
57
 
28
58
  - [eslint/overrides-jest] Make use of [jest/prefer-each](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-each.md) rule
29
59
 
30
- ## [2.18.0] - 2022.08.19
60
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.18.0...v2.19.0)
61
+
62
+ ## [2.18.0] - 2022-08-19
31
63
 
32
64
  ### Changed
33
65
 
@@ -47,7 +79,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
47
79
 
48
80
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.17.0...v2.18.0)
49
81
 
50
- ## [2.17.0] - 2022.08.10
82
+ ## [2.17.0] - 2022-08-10
51
83
 
52
84
  ### Changed
53
85
 
@@ -62,7 +94,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
62
94
 
63
95
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.16.0...v2.17.0)
64
96
 
65
- ## [2.16.0] - 2022.08.05
97
+ ## [2.16.0] - 2022-08-05
66
98
 
67
99
  ### Changed
68
100
 
@@ -104,7 +136,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
104
136
 
105
137
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.15.0...v2.16.0)
106
138
 
107
- ## [2.15.0] - 2022.05.05
139
+ ## [2.15.0] - 2022-05-05
108
140
 
109
141
  ### Fixed
110
142
 
@@ -113,7 +145,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
113
145
 
114
146
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.14.1...v2.15.0)
115
147
 
116
- ## [2.14.1] - 2022.05.05
148
+ ## [2.14.1] - 2022-05-05
117
149
 
118
150
  ### Fixed
119
151
 
@@ -121,7 +153,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
121
153
 
122
154
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.14.0...v2.14.1)
123
155
 
124
- ## [2.14.0] - 2022.05.05
156
+ ## [2.14.0] - 2022-05-05
125
157
 
126
158
  ### Changed
127
159
 
@@ -143,7 +175,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
143
175
 
144
176
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.13.0...v2.14.0)
145
177
 
146
- ## [2.13.0] - 2022.04.25
178
+ ## [2.13.0] - 2022-04-25
147
179
 
148
180
  ### Changed
149
181
 
@@ -171,7 +203,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
171
203
 
172
204
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.12.0...v2.13.0)
173
205
 
174
- ## [2.12.0] - 2022.03.30
206
+ ## [2.12.0] - 2022-03-30
175
207
 
176
208
  ### Changed
177
209
 
@@ -195,7 +227,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
195
227
 
196
228
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.11.1...v2.12.0)
197
229
 
198
- ## [2.11.1] - 2022.03.13
230
+ ## [2.11.1] - 2022-03-13
199
231
 
200
232
  ### Changed
201
233
 
@@ -204,7 +236,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
204
236
 
205
237
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.11.0...v2.11.1)
206
238
 
207
- ## [2.11.0] - 2022.03.12
239
+ ## [2.11.0] - 2022-03-12
208
240
 
209
241
  ### Added
210
242
 
@@ -219,7 +251,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
219
251
 
220
252
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.10.1...v2.11.0)
221
253
 
222
- ## [2.10.1] - 2022.03.11
254
+ ## [2.10.1] - 2022-03-11
223
255
 
224
256
  ### Fixed
225
257
 
@@ -227,7 +259,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
227
259
 
228
260
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.10.0...v2.10.1)
229
261
 
230
- ## [2.10.0] - 2022.03.10
262
+ ## [2.10.0] - 2022-03-10
231
263
 
232
264
  ### Changed
233
265
 
@@ -248,7 +280,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
248
280
 
249
281
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.9.0...v2.10.0)
250
282
 
251
- ## [2.9.0] - 2022.02.23
283
+ ## [2.9.0] - 2022-02-23
252
284
 
253
285
  ### Changed
254
286
 
@@ -263,7 +295,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
263
295
 
264
296
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.8.4...v2.9.0)
265
297
 
266
- ## [2.8.4] - 2022.02.19
298
+ ## [2.8.4] - 2022-02-19
267
299
 
268
300
  ### Changed
269
301
 
@@ -271,7 +303,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
271
303
 
272
304
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.8.3...v2.8.4)
273
305
 
274
- ## [2.8.3] - 2022.02.19
306
+ ## [2.8.3] - 2022-02-19
275
307
 
276
308
  ### Changed
277
309
 
@@ -279,7 +311,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
279
311
 
280
312
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.8.2...v2.8.3)
281
313
 
282
- ## [2.8.2] - 2022.02.19
314
+ ## [2.8.2] - 2022-02-19
283
315
 
284
316
  ### Changed
285
317
 
@@ -287,7 +319,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
287
319
 
288
320
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.8.1...v2.8.2)
289
321
 
290
- ## [2.8.1] - 2022.02.19
322
+ ## [2.8.1] - 2022-02-19
291
323
 
292
324
  ### Changed
293
325
 
@@ -295,7 +327,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
295
327
 
296
328
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.8.0...v2.8.1)
297
329
 
298
- ## [2.8.0] - 2022.02.18
330
+ ## [2.8.0] - 2022-02-18
299
331
 
300
332
  ### Changed
301
333
 
@@ -312,7 +344,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
312
344
 
313
345
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.7.0...v2.8.0)
314
346
 
315
- ## [2.7.0] - 2022.02.16
347
+ ## [2.7.0] - 2022-02-16
316
348
 
317
349
  ### Changed
318
350
 
@@ -325,7 +357,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
325
357
 
326
358
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.6.0...v2.7.0)
327
359
 
328
- ## [2.6.0] - 2022.02.14
360
+ ## [2.6.0] - 2022-02-14
329
361
 
330
362
  ### Changed
331
363
 
@@ -336,7 +368,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
336
368
 
337
369
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.5.0...v2.6.0)
338
370
 
339
- ## [2.5.0] - 2022.02.11
371
+ ## [2.5.0] - 2022-02-11
340
372
 
341
373
  ### Changed
342
374
 
@@ -346,7 +378,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
346
378
 
347
379
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.4.0...v2.5.0)
348
380
 
349
- ## [2.4.0] - 2022.02.09
381
+ ## [2.4.0] - 2022-02-09
350
382
 
351
383
  ### Changed
352
384
 
@@ -369,7 +401,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
369
401
 
370
402
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.3.1...v2.4.0)
371
403
 
372
- ## [2.3.1] - 2022.01.28
404
+ ## [2.3.1] - 2022-01-28
373
405
 
374
406
  ### Fixed
375
407
 
@@ -385,7 +417,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
385
417
 
386
418
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.3.0...v2.3.1)
387
419
 
388
- ## [2.3.0] - 2022.01.27
420
+ ## [2.3.0] - 2022-01-27
389
421
 
390
422
  ### Changed
391
423
 
@@ -429,7 +461,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
429
461
 
430
462
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.1.0...v2.3.0)
431
463
 
432
- ## [2.1.0] - 2021.11.07
464
+ ## [2.1.0] - 2021-11-07
433
465
 
434
466
  ### Changed
435
467
 
@@ -438,7 +470,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
438
470
 
439
471
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.0.0...v2.1.0)
440
472
 
441
- ## [2.0.0] - 2021.11.05
473
+ ## [2.0.0] - 2021-11-05
442
474
 
443
475
  ### Removed
444
476
 
@@ -492,7 +524,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
492
524
 
493
525
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.28.0...v2.0.0)
494
526
 
495
- ## [1.28.0] - 2021.09.18
527
+ ## [1.28.0] - 2021-09-18
496
528
 
497
529
  ### Changed
498
530
 
@@ -505,7 +537,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
505
537
 
506
538
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.27.0...v1.28.0)
507
539
 
508
- ## [1.27.0] - 2021.09.12
540
+ ## [1.27.0] - 2021-09-12
509
541
 
510
542
  ### Changed
511
543
 
@@ -523,7 +555,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
523
555
 
524
556
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.26.0...v1.27.0)
525
557
 
526
- ## [1.26.0] - 2021.08.29
558
+ ## [1.26.0] - 2021-08-29
527
559
 
528
560
  ### Changed
529
561
 
@@ -537,13 +569,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
537
569
 
538
570
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.25.2...v1.26.0)
539
571
 
540
- ## [1.25.2] - 2021.08.27
572
+ ## [1.25.2] - 2021-08-27
541
573
 
542
574
  - [eslint] Disabled `@typescript-eslint/no-implicit-any-catch` because of false-positive with the new TypeScript 4.4 option "useUnknownInCatchVariables"
543
575
 
544
576
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.25.1...v1.25.2)
545
577
 
546
- ## [1.25.1] - 2021.08.25
578
+ ## [1.25.1] - 2021-08-25
547
579
 
548
580
  ### Fixed
549
581
 
@@ -556,7 +588,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
556
588
 
557
589
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.25.0...v1.25.1)
558
590
 
559
- ## [1.25.0] - 2021.08.24
591
+ ## [1.25.0] - 2021-08-24
560
592
 
561
593
  ### Changed
562
594
 
@@ -580,7 +612,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
580
612
 
581
613
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.24.0...v1.25.0)
582
614
 
583
- ## [1.24.0] - 2021.07.28
615
+ ## [1.24.0] - 2021-07-28
584
616
 
585
617
  ### Changed
586
618
 
@@ -604,7 +636,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
604
636
 
605
637
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.23.0...v1.24.0)
606
638
 
607
- ## [1.23.0] - 2021.06.14
639
+ ## [1.23.0] - 2021-06-14
608
640
 
609
641
  ### Changed
610
642
 
@@ -613,7 +645,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
613
645
 
614
646
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.22.3...v1.23.0)
615
647
 
616
- ## [1.22.3] - 2021.06.08
648
+ ## [1.22.3] - 2021-06-08
617
649
 
618
650
  ### Added
619
651
 
@@ -621,7 +653,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
621
653
 
622
654
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.22.2...v1.22.3)
623
655
 
624
- ## [1.22.2] - 2021.06.08
656
+ ## [1.22.2] - 2021-06-08
625
657
 
626
658
  ### Changed
627
659
 
@@ -634,7 +666,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
634
666
 
635
667
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.22.1...v1.22.2)
636
668
 
637
- ## [1.22.1] - 2021.06.07
669
+ ## [1.22.1] - 2021-06-07
638
670
 
639
671
  ### Changed
640
672
 
@@ -649,7 +681,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
649
681
 
650
682
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.22.0...v1.22.1)
651
683
 
652
- ## [1.22.0] - 2021.06.02
684
+ ## [1.22.0] - 2021-06-02
653
685
 
654
686
  ### Changed
655
687
 
@@ -670,7 +702,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
670
702
 
671
703
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.21.0...v1.22.0)
672
704
 
673
- ## [1.21.0] - 2021.05.27
705
+ ## [1.21.0] - 2021-05-27
674
706
 
675
707
  ### Changed
676
708
 
@@ -680,7 +712,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
680
712
 
681
713
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.20.0...v1.21.0)
682
714
 
683
- ## [1.20.0] - 2021.05.22
715
+ ## [1.20.0] - 2021-05-22
684
716
 
685
717
  ### Changed
686
718
 
@@ -692,7 +724,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
692
724
 
693
725
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.19.0...v1.20.0)
694
726
 
695
- ## [1.19.0] - 2021.05.18
727
+ ## [1.19.0] - 2021-05-18
696
728
 
697
729
  ### Changed
698
730
 
@@ -700,7 +732,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
700
732
 
701
733
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.18.0...v1.19.0)
702
734
 
703
- ## [1.18.0] - 2021.05.17
735
+ ## [1.18.0] - 2021-05-17
704
736
 
705
737
  ### Added
706
738
 
@@ -716,7 +748,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
716
748
 
717
749
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.17.0...v1.18.0)
718
750
 
719
- ## [1.17.0] - 2021.05.15
751
+ ## [1.17.0] - 2021-05-15
720
752
 
721
753
  ### Added
722
754
 
@@ -736,7 +768,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
736
768
 
737
769
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.16.0...v1.17.0)
738
770
 
739
- ## [1.16.0] - 2021.05.12
771
+ ## [1.16.0] - 2021-05-12
740
772
 
741
773
  ### Added
742
774
 
@@ -954,7 +986,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
954
986
 
955
987
  ### Added
956
988
 
957
- - [gatsby/overrides-gatsby] New rule `no-global-undefined-check`, which prevents `typeof window === 'undefined'` checks, which are often [the source of rehydration problems](https://www.joshwcomeau.com/react/the-perils-of-rehydration/) in Gatsby
989
+ - [eslint/overrides-gatsby] New rule [`no-global-undefined-check`](./eslint/rules/no-global-undefined-check.md), which prevents `typeof window === 'undefined'` checks, which are often [the source of rehydration problems](https://www.joshwcomeau.com/react/the-perils-of-rehydration/) in Gatsby
958
990
 
959
991
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v1.1.0...v1.2.0)
960
992
 
package/README.md CHANGED
@@ -38,6 +38,7 @@ This setup is using the following additional plugins:
38
38
  Beside that, the following additional rules are part of this bundle:
39
39
 
40
40
  - [no-global-undefined-check](./eslint/rules/no-global-undefined-check.md)
41
+ - [no-unnecessary-typeof](./eslint/rules/no-unnecessary-typeof.md)
41
42
 
42
43
  ### stylelint
43
44
 
package/eslint/index.js CHANGED
@@ -91,6 +91,11 @@ module.exports = {
91
91
  },
92
92
  reportUnusedDisableDirectives: true,
93
93
  rules: {
94
+ /**
95
+ * ./rules
96
+ */
97
+ 'no-unnecessary-typeof': 'error',
98
+
94
99
  /**
95
100
  * eslint
96
101
  *
@@ -78,7 +78,6 @@ module.exports = {
78
78
  'jest/no-identical-title': 'error',
79
79
  'jest/no-interpolation-in-snapshots': 'error',
80
80
  'jest/no-jasmine-globals': 'error',
81
- 'jest/no-jest-import': 'error',
82
81
  'jest/no-large-snapshots': 'error',
83
82
  'jest/no-mocks-import': 'error',
84
83
  'jest/no-restricted-matchers': ['error', {
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @file ESLint rule which ensures that `typeof window === 'undefined'` is not used, since it's often the source of rehydration issues in Gatsby.
3
+ *
4
+ * @see https://www.joshwcomeau.com/react/the-perils-of-rehydration/
5
+ */
6
+
7
+ const { ESLintUtils } = require('@typescript-eslint/utils');
8
+
9
+ /**
10
+ * @type {import('eslint').Rule.RuleModule}
11
+ */
12
+ module.exports = {
13
+ meta: {
14
+ docs: {
15
+ description: 'If a `typeof` operant has only one type in TypeScript, it\'s unnecessary to check it\'s type at runtime.',
16
+ recommended: true
17
+ },
18
+ messages: {
19
+ text: 'Unnecessary `typeof`, because the only possible type of `{{ name }}` is `{{ type }}`.'
20
+ }
21
+ },
22
+ create (context) {
23
+ return {
24
+ UnaryExpression (node) {
25
+ if (node.operator !== 'typeof' || node.argument.type !== 'Identifier') {
26
+ return;
27
+ }
28
+
29
+ // @ts-expect-error -- Different type definitions for `Rule.RuleContext` in ESLint and @typescript-eslint
30
+ const parserServices = ESLintUtils.getParserServices(context);
31
+ const checker = parserServices.program.getTypeChecker();
32
+
33
+ // @ts-expect-error -- ESLint `Identifier` is not recognized as `Node` by @typescript-eslint
34
+ const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node.argument);
35
+
36
+ /** @type {import('typescript').Type & { intrinsicName?: string; }} */
37
+ const nodeType = checker.getTypeAtLocation(originalNode);
38
+
39
+ // `intrinsicName` only exists if there is exactly one type
40
+ if (nodeType.intrinsicName && !['any', 'error', 'unknown'].includes(nodeType.intrinsicName)) {
41
+ context.report({
42
+ node,
43
+ messageId: 'text',
44
+ data: {
45
+ name: node.argument.name,
46
+ type: nodeType.intrinsicName
47
+ }
48
+ });
49
+ }
50
+ }
51
+ };
52
+ }
53
+ };
@@ -0,0 +1,18 @@
1
+ # Disallow unnecessary `typeof` checks (`no-unnecessary-typeof`)
2
+
3
+ ## Rule Details
4
+
5
+ If a `typeof` operant has only one type in TypeScript, it's unnecessary to check it's type at runtime.
6
+
7
+ Examples of **incorrect** code for this rule:
8
+
9
+ ```ts
10
+ declare var myString: string;
11
+
12
+ if (typeof myString === 'string') {}
13
+ if (typeof myString === 'boolean') {}
14
+
15
+ declare var myBoolean: (boolean | string) & (boolean | number);
16
+
17
+ if (typeof myBoolean === 'boolean') {}
18
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linter-bundle",
3
- "version": "2.19.0",
3
+ "version": "2.21.0",
4
4
  "description": "Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -40,20 +40,21 @@
40
40
  "check-outdated": "npx --yes -- check-outdated --ignore-pre-releases"
41
41
  },
42
42
  "dependencies": {
43
- "@typescript-eslint/eslint-plugin": "5.35.1",
44
- "@typescript-eslint/parser": "5.35.1",
45
- "eslint": "8.23.0",
46
- "eslint-import-resolver-typescript": "3.5.0",
43
+ "@typescript-eslint/eslint-plugin": "5.37.0",
44
+ "@typescript-eslint/parser": "5.37.0",
45
+ "@typescript-eslint/utils": "5.37.0",
46
+ "eslint": "8.23.1",
47
+ "eslint-import-resolver-typescript": "3.5.1",
47
48
  "eslint-import-resolver-webpack": "0.13.2",
48
49
  "eslint-plugin-eslint-comments": "3.2.0",
49
- "eslint-plugin-functional": "4.2.2",
50
+ "eslint-plugin-functional": "4.3.1",
50
51
  "eslint-plugin-import": "2.26.0",
51
- "eslint-plugin-jest": "26.9.0",
52
+ "eslint-plugin-jest": "27.0.4",
52
53
  "eslint-plugin-jsdoc": "39.3.6",
53
54
  "eslint-plugin-jsx-a11y": "6.6.1",
54
55
  "eslint-plugin-node": "11.1.0",
55
56
  "eslint-plugin-promise": "6.0.1",
56
- "eslint-plugin-react": "7.31.1",
57
+ "eslint-plugin-react": "7.31.8",
57
58
  "eslint-plugin-react-hooks": "4.6.0",
58
59
  "eslint-plugin-unicorn": "43.0.2",
59
60
  "markdownlint-cli": "0.32.2",
@@ -73,8 +74,8 @@
73
74
  "devDependencies": {
74
75
  "@types/eslint": "8.4.6",
75
76
  "@types/micromatch": "4.0.2",
76
- "@types/node": "18.7.13",
77
+ "@types/node": "18.7.18",
77
78
  "stylelint-find-new-rules": "4.0.0",
78
- "typescript": "4.8.2"
79
+ "typescript": "4.8.3"
79
80
  }
80
81
  }