eslint-plugin-lube 0.1.3

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.
@@ -0,0 +1,1365 @@
1
+ const error = {
2
+ messageId: "not_match",
3
+ type: "Identifier"
4
+ }
5
+ /**
6
+ * @param {import("eslint").RuleTester.ValidTestCase[]} valid
7
+ * @param {import("eslint").RuleTester.InvalidTestCase[]} invalid
8
+ */
9
+ exports.module = (valid, invalid) => {
10
+ invalid.push(
11
+ // ArrayExpression
12
+ {
13
+ code: `
14
+ var value = [ deferA ]
15
+ var value = [ pendingA ]
16
+ var pendingA
17
+ var value = [ pendingA ]
18
+ `,
19
+ errors: [
20
+ {
21
+ ...error,
22
+ line: 3,
23
+ column: 18
24
+ },
25
+ {
26
+ ...error,
27
+ line: 4,
28
+ column: 8
29
+ },
30
+ {
31
+ ...error,
32
+ line: 5,
33
+ column: 18
34
+ }
35
+ ],
36
+ options: [{ fixSameNames: true }],
37
+ output: `
38
+ var value = [ deferA ]
39
+ var value = [ pending_a ]
40
+ var pending_a
41
+ var value = [ pending_a ]
42
+ `
43
+ },
44
+ // ArrayPattern
45
+ {
46
+ code: "var [ camelCase ] = value",
47
+ errors: [{
48
+ ...error,
49
+ line: 1,
50
+ column: 7
51
+ }],
52
+ output: "var [ camel_case ] = value",
53
+ parserOptions: { ecmaVersion: "latest" }
54
+ },
55
+ // ArrowFunctionExpression
56
+ {
57
+ code: "(camelCase) => {}",
58
+ errors: [{
59
+ ...error,
60
+ line: 1,
61
+ column: 2
62
+ }],
63
+ output: "(camel_case) => {}",
64
+ parserOptions: { ecmaVersion: "latest" }
65
+ },
66
+ // AssignmentExpression
67
+ {
68
+ code: `
69
+ deferA = deferB
70
+ pendingA = pendingB
71
+ var pendingA, pendingB
72
+ pendingA = pendingB
73
+ `,
74
+ errors: [
75
+ {
76
+ ...error,
77
+ line: 3,
78
+ column: 4
79
+ },
80
+ {
81
+ ...error,
82
+ line: 3,
83
+ column: 15
84
+ },
85
+ {
86
+ ...error,
87
+ line: 4,
88
+ column: 8
89
+ },
90
+ {
91
+ ...error,
92
+ line: 4,
93
+ column: 18
94
+ },
95
+ {
96
+ ...error,
97
+ line: 5,
98
+ column: 4
99
+ },
100
+ {
101
+ ...error,
102
+ line: 5,
103
+ column: 15
104
+ }
105
+ ],
106
+ options: [{ fixSameNames: true }],
107
+ output: `
108
+ deferA = deferB
109
+ pending_a = pending_b
110
+ var pending_a, pending_b
111
+ pending_a = pending_b
112
+ `
113
+ },
114
+ // AssignmentPattern
115
+ {
116
+ code: `
117
+ (camelCase = deferA) => {}
118
+ (snake_case = pendingA) => {}
119
+ var pendingA
120
+ (snake_case = pendingA) => {}
121
+ `,
122
+ errors: [
123
+ {
124
+ ...error,
125
+ line: 2,
126
+ column: 5
127
+ },
128
+ {
129
+ ...error,
130
+ line: 3,
131
+ column: 18
132
+ },
133
+ {
134
+ ...error,
135
+ line: 4,
136
+ column: 8
137
+ },
138
+ {
139
+ ...error,
140
+ line: 5,
141
+ column: 18
142
+ }
143
+ ],
144
+ options: [{ fixSameNames: true }],
145
+ output: `
146
+ (camel_case = deferA) => {}
147
+ (snake_case = pending_a) => {}
148
+ var pending_a
149
+ (snake_case = pending_a) => {}
150
+ `,
151
+ parserOptions: { ecmaVersion: "latest" }
152
+ },
153
+ // AwaitExpression
154
+ {
155
+ code: `
156
+ await deferA
157
+ await pendingA
158
+ var pendingA
159
+ await pendingA
160
+ `,
161
+ errors: [
162
+ {
163
+ ...error,
164
+ line: 3,
165
+ column: 10
166
+ },
167
+ {
168
+ ...error,
169
+ line: 4,
170
+ column: 8
171
+ },
172
+ {
173
+ ...error,
174
+ line: 5,
175
+ column: 10
176
+ }
177
+ ],
178
+ options: [{ fixSameNames: true }],
179
+ output: `
180
+ await deferA
181
+ await pending_a
182
+ var pending_a
183
+ await pending_a
184
+ `,
185
+ parserOptions: {
186
+ ecmaVersion: "latest",
187
+ sourceType: "module"
188
+ }
189
+ },
190
+ // BinaryExpression
191
+ {
192
+ code: `
193
+ deferA = deferB
194
+ pendingA - pendingB
195
+ var pendingA, pendingB
196
+ pendingA / pendingB
197
+ `,
198
+ errors: [
199
+ {
200
+ ...error,
201
+ line: 3,
202
+ column: 4
203
+ },
204
+ {
205
+ ...error,
206
+ line: 3,
207
+ column: 15
208
+ },
209
+ {
210
+ ...error,
211
+ line: 4,
212
+ column: 8
213
+ },
214
+ {
215
+ ...error,
216
+ line: 4,
217
+ column: 18
218
+ },
219
+ {
220
+ ...error,
221
+ line: 5,
222
+ column: 4
223
+ },
224
+ {
225
+ ...error,
226
+ line: 5,
227
+ column: 15
228
+ }
229
+ ],
230
+ options: [{ fixSameNames: true }],
231
+ output: `
232
+ deferA = deferB
233
+ pending_a - pending_b
234
+ var pending_a, pending_b
235
+ pending_a / pending_b
236
+ `
237
+ },
238
+ // CallExpression
239
+ {
240
+ code: `
241
+ deferA()
242
+ pendingA()
243
+ var pendingA
244
+ pendingA()
245
+ `,
246
+ errors: [
247
+ {
248
+ ...error,
249
+ line: 3,
250
+ column: 4
251
+ },
252
+ {
253
+ ...error,
254
+ line: 4,
255
+ column: 8
256
+ },
257
+ {
258
+ ...error,
259
+ line: 5,
260
+ column: 4
261
+ }
262
+ ],
263
+ options: [{ fixSameNames: true }],
264
+ output: `
265
+ deferA()
266
+ pending_a()
267
+ var pending_a
268
+ pending_a()
269
+ `
270
+ },
271
+ // ClassDeclaration
272
+ {
273
+ code: "class camelCase {}",
274
+ errors: [{
275
+ ...error,
276
+ line: 1,
277
+ column: 7
278
+ }],
279
+ output: "class camel_case {}",
280
+ parserOptions: { ecmaVersion: "latest" }
281
+ },
282
+ // ConditionalExpression
283
+ {
284
+ code: `
285
+ test ? deferA : deferB
286
+ test ? pendingA : pendingB
287
+ var pendingA, pendingB
288
+ test ? pendingA : pendingB
289
+ `,
290
+ errors: [
291
+ {
292
+ ...error,
293
+ line: 3,
294
+ column: 11
295
+ },
296
+ {
297
+ ...error,
298
+ line: 3,
299
+ column: 22
300
+ },
301
+ {
302
+ ...error,
303
+ line: 4,
304
+ column: 8
305
+ },
306
+ {
307
+ ...error,
308
+ line: 4,
309
+ column: 18
310
+ },
311
+ {
312
+ ...error,
313
+ line: 5,
314
+ column: 11
315
+ },
316
+ {
317
+ ...error,
318
+ line: 5,
319
+ column: 22
320
+ }
321
+ ],
322
+ options: [{ fixSameNames: true }],
323
+ output: `
324
+ test ? deferA : deferB
325
+ test ? pending_a : pending_b
326
+ var pending_a, pending_b
327
+ test ? pending_a : pending_b
328
+ `
329
+ },
330
+ // ExportAllDeclaration
331
+ {
332
+ code: `
333
+ export * as camelCase from "module"
334
+ var camelCase
335
+ `,
336
+ errors: [{
337
+ ...error,
338
+ line: 3,
339
+ column: 8
340
+ }],
341
+ options: [{ fixSameNames: true }],
342
+ output: `
343
+ export * as camelCase from "module"
344
+ var camel_case
345
+ `,
346
+ parserOptions: {
347
+ ecmaVersion: "latest",
348
+ sourceType: "module"
349
+ }
350
+ },
351
+ // ExportDefaultDeclaration
352
+ {
353
+ code: `
354
+ export default camelCase
355
+ var camelCase
356
+ `,
357
+ errors: [{
358
+ ...error,
359
+ line: 3,
360
+ column: 8
361
+ }],
362
+ output: `
363
+ export default camelCase
364
+ var camel_case
365
+ `,
366
+ parserOptions: {
367
+ ecmaVersion: "latest",
368
+ sourceType: "module"
369
+ }
370
+ },
371
+ {
372
+ code: `
373
+ export default camelCase
374
+ var camelCase
375
+ `,
376
+ errors: [
377
+ {
378
+ ...error,
379
+ line: 2,
380
+ column: 19
381
+ },
382
+ {
383
+ ...error,
384
+ line: 3,
385
+ column: 8
386
+ },
387
+ ],
388
+ options: [{ fixSameNames: true }],
389
+ output: `
390
+ export default camel_case
391
+ var camel_case
392
+ `,
393
+ parserOptions: {
394
+ ecmaVersion: "latest",
395
+ sourceType: "module"
396
+ }
397
+ },
398
+ // ExportSpecifier
399
+ {
400
+ code: `
401
+ export { default as camelCase, camelCase2 } from 'module'
402
+ var camelCase, camelCase2
403
+ `,
404
+ errors: [
405
+ {
406
+ ...error,
407
+ line: 3,
408
+ column: 8
409
+ },
410
+ {
411
+ ...error,
412
+ line: 3,
413
+ column: 19
414
+ },
415
+ ],
416
+ options: [{ fixSameNames: true }],
417
+ output: `
418
+ export { default as camelCase, camelCase2 } from 'module'
419
+ var camel_case, camel_case2
420
+ `,
421
+ parserOptions: {
422
+ ecmaVersion: "latest",
423
+ sourceType: "module"
424
+ }
425
+ },
426
+ // ExpressionStatement
427
+ {
428
+ code: `
429
+ deferA
430
+ pendingA
431
+ var pendingA
432
+ pendingA
433
+ `,
434
+ errors: [
435
+ {
436
+ ...error,
437
+ line: 3,
438
+ column: 4
439
+ },
440
+ {
441
+ ...error,
442
+ line: 4,
443
+ column: 8
444
+ },
445
+ {
446
+ ...error,
447
+ line: 5,
448
+ column: 4
449
+ }
450
+ ],
451
+ options: [{ fixSameNames: true }],
452
+ output: `
453
+ deferA
454
+ pending_a
455
+ var pending_a
456
+ pending_a
457
+ `
458
+ },
459
+ // ForInStatement
460
+ {
461
+ code: `
462
+ for (camelCase in deferA) {}
463
+ for (snake_case in pendingA) {}
464
+ var pendingA
465
+ for (snake_case in pendingA) {}
466
+ `,
467
+ errors: [
468
+ {
469
+ ...error,
470
+ line: 2,
471
+ column: 9
472
+ },
473
+ {
474
+ ...error,
475
+ line: 3,
476
+ column: 23
477
+ },
478
+ {
479
+ ...error,
480
+ line: 4,
481
+ column: 8
482
+ },
483
+ {
484
+ ...error,
485
+ line: 5,
486
+ column: 23
487
+ }
488
+ ],
489
+ options: [{ fixSameNames: true }],
490
+ output: `
491
+ for (camel_case in deferA) {}
492
+ for (snake_case in pending_a) {}
493
+ var pending_a
494
+ for (snake_case in pending_a) {}
495
+ `,
496
+ parserOptions: { ecmaVersion: "latest" }
497
+ },
498
+ // ForStatement
499
+ {
500
+ code: `
501
+ for (deferA; deferB; deferC) {}
502
+ for (pendingA; pendingB; pendingC) {}
503
+ var pendingA, pendingB, pendingC
504
+ for (pendingA; pendingB; pendingC) {}
505
+ `,
506
+ errors: [
507
+ {
508
+ ...error,
509
+ line: 3,
510
+ column: 9
511
+ },
512
+ {
513
+ ...error,
514
+ line: 3,
515
+ column: 19
516
+ },
517
+ {
518
+ ...error,
519
+ line: 3,
520
+ column: 29
521
+ },
522
+ {
523
+ ...error,
524
+ line: 4,
525
+ column: 8
526
+ },
527
+ {
528
+ ...error,
529
+ line: 4,
530
+ column: 18
531
+ },
532
+ {
533
+ ...error,
534
+ line: 4,
535
+ column: 28
536
+ },
537
+ {
538
+ ...error,
539
+ line: 5,
540
+ column: 9
541
+ },
542
+ {
543
+ ...error,
544
+ line: 5,
545
+ column: 19
546
+ },
547
+ {
548
+ ...error,
549
+ line: 5,
550
+ column: 29
551
+ }
552
+ ],
553
+ options: [{ fixSameNames: true }],
554
+ output: `
555
+ for (deferA; deferB; deferC) {}
556
+ for (pending_a; pending_b; pending_c) {}
557
+ var pending_a, pending_b, pending_c
558
+ for (pending_a; pending_b; pending_c) {}
559
+ `,
560
+ parserOptions: { ecmaVersion: "latest" }
561
+ },
562
+ // FunctionDeclaration
563
+ {
564
+ code: "function camelCase() {}",
565
+ errors: [{
566
+ ...error,
567
+ line: 1,
568
+ column: 10
569
+ }],
570
+ output: "function camel_case() {}"
571
+ },
572
+ // IfStatement
573
+ {
574
+ code: `
575
+ if (deferA) {}
576
+ if (pendingA) {}
577
+ var pendingA
578
+ if (pendingA) {}
579
+ `,
580
+ errors: [
581
+ {
582
+ ...error,
583
+ line: 3,
584
+ column: 8
585
+ },
586
+ {
587
+ ...error,
588
+ line: 4,
589
+ column: 8
590
+ },
591
+ {
592
+ ...error,
593
+ line: 5,
594
+ column: 8
595
+ }
596
+ ],
597
+ options: [{ fixSameNames: true }],
598
+ output: `
599
+ if (deferA) {}
600
+ if (pending_a) {}
601
+ var pending_a
602
+ if (pending_a) {}
603
+ `
604
+ },
605
+ // ImportDefaultSpecifier
606
+ {
607
+ code: "import camelCase from 'module'",
608
+ errors: [{
609
+ ...error,
610
+ line: 1,
611
+ column: 8
612
+ }],
613
+ output: "import camel_case from 'module'",
614
+ parserOptions: {
615
+ ecmaVersion: "latest",
616
+ sourceType: "module"
617
+ }
618
+ },
619
+ // ImportNamespaceSpecifier
620
+ {
621
+ code: "import * as camelCase from 'module'",
622
+ errors: [{
623
+ ...error,
624
+ line: 1,
625
+ column: 13
626
+ }],
627
+ output: "import * as camel_case from 'module'",
628
+ parserOptions: {
629
+ ecmaVersion: "latest",
630
+ sourceType: "module"
631
+ }
632
+ },
633
+ // ImportSpecifier
634
+ {
635
+ code: `
636
+ import { imported as camelCase, camelCase2, camelCase3 } from "module"
637
+ camelCase
638
+ camelCase2
639
+ `,
640
+ errors: [
641
+ {
642
+ ...error,
643
+ line: 2,
644
+ column: 25
645
+ },
646
+ {
647
+ ...error,
648
+ line: 3,
649
+ column: 4
650
+ }
651
+ ],
652
+ options: [{ fixSameNames: true }],
653
+ output: `
654
+ import { imported as camel_case, camelCase2, camelCase3 } from "module"
655
+ camel_case
656
+ camelCase2
657
+ `,
658
+ parserOptions: {
659
+ ecmaVersion: "latest",
660
+ sourceType: "module"
661
+ }
662
+ },
663
+ // LogicalExpression
664
+ {
665
+ code: `
666
+ deferA && deferB
667
+ pendingA || pendingB
668
+ var pendingA, pendingB
669
+ pendingA ?? pendingB
670
+ `,
671
+ errors: [
672
+ {
673
+ ...error,
674
+ line: 3,
675
+ column: 4
676
+ },
677
+ {
678
+ ...error,
679
+ line: 3,
680
+ column: 16
681
+ },
682
+ {
683
+ ...error,
684
+ line: 4,
685
+ column: 8
686
+ },
687
+ {
688
+ ...error,
689
+ line: 4,
690
+ column: 18
691
+ },
692
+ {
693
+ ...error,
694
+ line: 5,
695
+ column: 4
696
+ },
697
+ {
698
+ ...error,
699
+ line: 5,
700
+ column: 16
701
+ }
702
+ ],
703
+ options: [{ fixSameNames: true }],
704
+ output: `
705
+ deferA && deferB
706
+ pending_a || pending_b
707
+ var pending_a, pending_b
708
+ pending_a ?? pending_b
709
+ `,
710
+ parserOptions: { ecmaVersion: "latest" }
711
+ },
712
+ // MemberExpression
713
+ {
714
+ code: `
715
+ deferA.camelCase
716
+ pendingA.camelCase
717
+ var pendingA
718
+ pendingA.camelCase
719
+ object[deferB]
720
+ object[pendingB]
721
+ var pendingB
722
+ object[pendingB]
723
+ `,
724
+ errors: [
725
+ {
726
+ ...error,
727
+ line: 3,
728
+ column: 4
729
+ },
730
+ {
731
+ ...error,
732
+ line: 4,
733
+ column: 8
734
+ },
735
+ {
736
+ ...error,
737
+ line: 5,
738
+ column: 4
739
+ },
740
+ {
741
+ ...error,
742
+ line: 7,
743
+ column: 11
744
+ },
745
+ {
746
+ ...error,
747
+ line: 8,
748
+ column: 8
749
+ },
750
+ {
751
+ ...error,
752
+ line: 9,
753
+ column: 11
754
+ }
755
+ ],
756
+ options: [{ fixSameNames: true }],
757
+ output: `
758
+ deferA.camelCase
759
+ pending_a.camelCase
760
+ var pending_a
761
+ pending_a.camelCase
762
+ object[deferB]
763
+ object[pending_b]
764
+ var pending_b
765
+ object[pending_b]
766
+ `
767
+ },
768
+ // MethodDefinition
769
+ {
770
+ code: "class Object { camelCase() {} }",
771
+ errors: [{
772
+ ...error,
773
+ line: 1,
774
+ column: 16
775
+ }],
776
+ output: "class Object { camel_case() {} }",
777
+ parserOptions: { ecmaVersion: "latest" }
778
+ },
779
+ // NewExpression
780
+ {
781
+ code: `
782
+ new deferA
783
+ new pendingA
784
+ var pendingA
785
+ new pendingA
786
+ `,
787
+ errors: [
788
+ {
789
+ ...error,
790
+ line: 3,
791
+ column: 8
792
+ },
793
+ {
794
+ ...error,
795
+ line: 4,
796
+ column:8
797
+ },
798
+ {
799
+ ...error,
800
+ line: 5,
801
+ column: 8
802
+ }
803
+ ],
804
+ options: [{ fixSameNames: true }],
805
+ output: `
806
+ new deferA
807
+ new pending_a
808
+ var pending_a
809
+ new pending_a
810
+ `
811
+ },
812
+ // Property
813
+ {
814
+ code: `
815
+ var value = { camelCase: deferA }
816
+ var value = { key: pendingA }
817
+ var pendingA
818
+ var value = { key: pendingA }
819
+ var value = { pendingA }
820
+ `,
821
+ errors: [
822
+ {
823
+ ...error,
824
+ line: 3,
825
+ column: 23
826
+ },
827
+ {
828
+ ...error,
829
+ line: 4,
830
+ column:8
831
+ },
832
+ {
833
+ ...error,
834
+ line: 5,
835
+ column: 23
836
+ }
837
+ ],
838
+ options: [{ fixSameNames: true }],
839
+ output: `
840
+ var value = { camelCase: deferA }
841
+ var value = { key: pending_a }
842
+ var pending_a
843
+ var value = { key: pending_a }
844
+ var value = { pendingA }
845
+ `,
846
+ parserOptions: { ecmaVersion: "latest" }
847
+ },
848
+ // PropertyDefinition
849
+ {
850
+ code: `
851
+ class ObjectA { camelCase = deferA }
852
+ class ObjectB { snake_case = pendingA }
853
+ var pendingA
854
+ class ObjectC { snake_case = pendingA }
855
+ `,
856
+ errors: [
857
+ {
858
+ ...error,
859
+ line: 2,
860
+ column: 20
861
+ },
862
+ {
863
+ ...error,
864
+ line: 3,
865
+ column: 33
866
+ },
867
+ {
868
+ ...error,
869
+ line: 4,
870
+ column: 8
871
+ },
872
+ {
873
+ ...error,
874
+ line: 5,
875
+ column: 33
876
+ }
877
+ ],
878
+ options: [{ fixSameNames: true }],
879
+ output: `
880
+ class ObjectA { camel_case = deferA }
881
+ class ObjectB { snake_case = pending_a }
882
+ var pending_a
883
+ class ObjectC { snake_case = pending_a }
884
+ `,
885
+ parserOptions: { ecmaVersion: "latest" }
886
+ },
887
+ //RestElement
888
+ {
889
+ code: `
890
+ var [ ...camelCaseA ] = value
891
+ var { ...camelCaseB } = value
892
+ `,
893
+ errors: [
894
+ {
895
+ ...error,
896
+ line: 2,
897
+ column: 13
898
+ },
899
+ {
900
+ ...error,
901
+ line: 3,
902
+ column: 13
903
+ }
904
+ ],
905
+ options: [{ fixSameNames: true }],
906
+ output: `
907
+ var [ ...camel_case_a ] = value
908
+ var { ...camel_case_b } = value
909
+ `,
910
+ parserOptions: { ecmaVersion: "latest" }
911
+ },
912
+ // ReturnStatement
913
+ {
914
+ code: `
915
+ function func_a() { return deferA }
916
+ function func_b() { return pendingA }
917
+ var pendingA
918
+ function func_c() { return pendingA }
919
+ `,
920
+ errors: [
921
+ {
922
+ ...error,
923
+ line: 3,
924
+ column: 31
925
+ },
926
+ {
927
+ ...error,
928
+ line: 4,
929
+ column: 8
930
+ },
931
+ {
932
+ ...error,
933
+ line: 5,
934
+ column: 31
935
+ }
936
+ ],
937
+ options: [{ fixSameNames: true }],
938
+ output: `
939
+ function func_a() { return deferA }
940
+ function func_b() { return pending_a }
941
+ var pending_a
942
+ function func_c() { return pending_a }
943
+ `
944
+ },
945
+ // SequenceExpression
946
+ {
947
+ code: `
948
+ a, b, deferA
949
+ a, b, pendingA
950
+ var pendingA
951
+ a, b, pendingA
952
+ `,
953
+ errors: [
954
+ {
955
+ ...error,
956
+ line: 3,
957
+ column: 10
958
+ },
959
+ {
960
+ ...error,
961
+ line: 4,
962
+ column: 8
963
+ },
964
+ {
965
+ ...error,
966
+ line: 5,
967
+ column: 10
968
+ }
969
+ ],
970
+ options: [{ fixSameNames: true }],
971
+ output: `
972
+ a, b, deferA
973
+ a, b, pending_a
974
+ var pending_a
975
+ a, b, pending_a
976
+ `
977
+ },
978
+ // SpreadElement
979
+ {
980
+ code: `
981
+ var value = [ ...deferA, deferB ]
982
+ var value = [ ...pendingA, pendingB ]
983
+ var pendingA, pendingB
984
+ var value = [ ...pendingA, pendingB ]
985
+ `,
986
+ errors: [
987
+ {
988
+ ...error,
989
+ line: 3,
990
+ column: 21
991
+ },
992
+ {
993
+ ...error,
994
+ line: 3,
995
+ column: 31
996
+ },
997
+ {
998
+ ...error,
999
+ line: 4,
1000
+ column: 8
1001
+ },
1002
+ {
1003
+ ...error,
1004
+ line: 4,
1005
+ column: 18
1006
+ },
1007
+ {
1008
+ ...error,
1009
+ line: 5,
1010
+ column: 21
1011
+ },
1012
+ {
1013
+ ...error,
1014
+ line: 5,
1015
+ column: 31
1016
+ }
1017
+ ],
1018
+ options: [{ fixSameNames: true }],
1019
+ output: `
1020
+ var value = [ ...deferA, deferB ]
1021
+ var value = [ ...pending_a, pending_b ]
1022
+ var pending_a, pending_b
1023
+ var value = [ ...pending_a, pending_b ]
1024
+ `,
1025
+ parserOptions: { ecmaVersion: "latest" }
1026
+ },
1027
+ // SwitchCase
1028
+ {
1029
+ code: `
1030
+ switch (deferA) {}
1031
+ switch (pendingA) {}
1032
+ var pendingA
1033
+ switch (pendingA) {}
1034
+ `,
1035
+ errors: [
1036
+ {
1037
+ ...error,
1038
+ line: 3,
1039
+ column: 12
1040
+ },
1041
+ {
1042
+ ...error,
1043
+ line: 4,
1044
+ column:8
1045
+ },
1046
+ {
1047
+ ...error,
1048
+ line: 5,
1049
+ column: 12
1050
+ }
1051
+ ],
1052
+ options: [{ fixSameNames: true }],
1053
+ output: `
1054
+ switch (deferA) {}
1055
+ switch (pending_a) {}
1056
+ var pending_a
1057
+ switch (pending_a) {}
1058
+ `
1059
+ },
1060
+ // SwitchStatement
1061
+ {
1062
+ code: `
1063
+ switch (cond) { case deferA: break }
1064
+ switch (cond) { case pendingA: break }
1065
+ var pendingA
1066
+ switch (cond) { case pendingA: break }
1067
+ `,
1068
+ errors: [
1069
+ {
1070
+ ...error,
1071
+ line: 3,
1072
+ column: 25
1073
+ },
1074
+ {
1075
+ ...error,
1076
+ line: 4,
1077
+ column:8
1078
+ },
1079
+ {
1080
+ ...error,
1081
+ line: 5,
1082
+ column: 25
1083
+ }
1084
+ ],
1085
+ options: [{ fixSameNames: true }],
1086
+ output: `
1087
+ switch (cond) { case deferA: break }
1088
+ switch (cond) { case pending_a: break }
1089
+ var pending_a
1090
+ switch (cond) { case pending_a: break }
1091
+ `
1092
+ },
1093
+ // TaggedTemplateExpression
1094
+ {
1095
+ code: `
1096
+ deferA\`quasis\${expression}quasis\`
1097
+ pendingA\`quasis\${expression}quasis\`
1098
+ var pendingA
1099
+ pendingA\`quasis\${expression}quasis\`
1100
+ `,
1101
+ errors: [
1102
+ {
1103
+ ...error,
1104
+ line: 3,
1105
+ column: 4
1106
+ },
1107
+ {
1108
+ ...error,
1109
+ line: 4,
1110
+ column:8
1111
+ },
1112
+ {
1113
+ ...error,
1114
+ line: 5,
1115
+ column: 4
1116
+ }
1117
+ ],
1118
+ options: [{ fixSameNames: true }],
1119
+ output: `
1120
+ deferA\`quasis\${expression}quasis\`
1121
+ pending_a\`quasis\${expression}quasis\`
1122
+ var pending_a
1123
+ pending_a\`quasis\${expression}quasis\`
1124
+ `,
1125
+ parserOptions: { ecmaVersion: "latest" }
1126
+ },
1127
+ // ThrowStatement
1128
+ {
1129
+ code: `
1130
+ throw deferA
1131
+ throw pendingA
1132
+ var pendingA
1133
+ throw pendingA
1134
+ `,
1135
+ errors: [
1136
+ {
1137
+ ...error,
1138
+ line: 3,
1139
+ column: 10
1140
+ },
1141
+ {
1142
+ ...error,
1143
+ line: 4,
1144
+ column: 8
1145
+ },
1146
+ {
1147
+ ...error,
1148
+ line: 5,
1149
+ column: 10
1150
+ }
1151
+ ],
1152
+ options: [{ fixSameNames: true }],
1153
+ output: `
1154
+ throw deferA
1155
+ throw pending_a
1156
+ var pending_a
1157
+ throw pending_a
1158
+ `
1159
+ },
1160
+ // UnaryExpression
1161
+ {
1162
+ code: `
1163
+ +deferA
1164
+ -pendingA
1165
+ var pendingA
1166
+ ~pendingA
1167
+ `,
1168
+ errors: [
1169
+ {
1170
+ ...error,
1171
+ line: 3,
1172
+ column: 5
1173
+ },
1174
+ {
1175
+ ...error,
1176
+ line: 4,
1177
+ column: 8
1178
+ },
1179
+ {
1180
+ ...error,
1181
+ line: 5,
1182
+ column: 5
1183
+ }
1184
+ ],
1185
+ options: [{ fixSameNames: true }],
1186
+ output: `
1187
+ +deferA
1188
+ -pending_a
1189
+ var pending_a
1190
+ ~pending_a
1191
+ `
1192
+ },
1193
+ // UpdateExpression
1194
+ {
1195
+ code: `
1196
+ ++deferA
1197
+ --pendingA
1198
+ var pendingA
1199
+ pendingA++
1200
+ `,
1201
+ errors: [
1202
+ {
1203
+ ...error,
1204
+ line: 3,
1205
+ column: 6
1206
+ },
1207
+ {
1208
+ ...error,
1209
+ line: 4,
1210
+ column: 8
1211
+ },
1212
+ {
1213
+ ...error,
1214
+ line: 5,
1215
+ column: 4
1216
+ }
1217
+ ],
1218
+ options: [{ fixSameNames: true }],
1219
+ output: `
1220
+ ++deferA
1221
+ --pending_a
1222
+ var pending_a
1223
+ pending_a++
1224
+ `
1225
+ },
1226
+ // VariableDeclarator
1227
+ {
1228
+ code: `
1229
+ var camelCase = deferA
1230
+ var snake_case = pendingA
1231
+ var pendingA
1232
+ var snake_case = pendingA
1233
+ `,
1234
+ errors: [
1235
+ {
1236
+ ...error,
1237
+ line: 2,
1238
+ column: 8
1239
+ },
1240
+ {
1241
+ ...error,
1242
+ line: 3,
1243
+ column: 21
1244
+ },
1245
+ {
1246
+ ...error,
1247
+ line: 4,
1248
+ column: 8
1249
+ },
1250
+ {
1251
+ ...error,
1252
+ line: 5,
1253
+ column: 21
1254
+ }
1255
+ ],
1256
+ options: [{ fixSameNames: true }],
1257
+ output: `
1258
+ var camel_case = deferA
1259
+ var snake_case = pending_a
1260
+ var pending_a
1261
+ var snake_case = pending_a
1262
+ `
1263
+ },
1264
+ // WhileStatement
1265
+ {
1266
+ code: `
1267
+ while (deferA) {}
1268
+ while (pendingA) {}
1269
+ var pendingA
1270
+ while (pendingA) {}
1271
+ `,
1272
+ errors: [
1273
+ {
1274
+ ...error,
1275
+ line: 3,
1276
+ column: 11
1277
+ },
1278
+ {
1279
+ ...error,
1280
+ line: 4,
1281
+ column: 8
1282
+ },
1283
+ {
1284
+ ...error,
1285
+ line: 5,
1286
+ column: 11
1287
+ }
1288
+ ],
1289
+ options: [{ fixSameNames: true }],
1290
+ output: `
1291
+ while (deferA) {}
1292
+ while (pending_a) {}
1293
+ var pending_a
1294
+ while (pending_a) {}
1295
+ `
1296
+ },
1297
+ // WithStatement
1298
+ {
1299
+ code: `
1300
+ with (deferA) {}
1301
+ with (pendingA) {}
1302
+ var pendingA
1303
+ with (pendingA) {}
1304
+ `,
1305
+ errors: [
1306
+ {
1307
+ ...error,
1308
+ line: 3,
1309
+ column: 10
1310
+ },
1311
+ {
1312
+ ...error,
1313
+ line: 4,
1314
+ column: 8
1315
+ },
1316
+ {
1317
+ ...error,
1318
+ line: 5,
1319
+ column: 10
1320
+ }
1321
+ ],
1322
+ options: [{ fixSameNames: true }],
1323
+ output: `
1324
+ with (deferA) {}
1325
+ with (pending_a) {}
1326
+ var pending_a
1327
+ with (pending_a) {}
1328
+ `
1329
+ },
1330
+ // YieldStatement
1331
+ {
1332
+ code: `
1333
+ function* func_a() { yield deferA }
1334
+ function* func_b() { yield pendingA }
1335
+ var pendingA
1336
+ function* func_c() { yield pendingA }
1337
+ `,
1338
+ errors: [
1339
+ {
1340
+ ...error,
1341
+ line: 3,
1342
+ column: 31
1343
+ },
1344
+ {
1345
+ ...error,
1346
+ line: 4,
1347
+ column: 8
1348
+ },
1349
+ {
1350
+ ...error,
1351
+ line: 5,
1352
+ column: 31
1353
+ }
1354
+ ],
1355
+ options: [{ fixSameNames: true }],
1356
+ output: `
1357
+ function* func_a() { yield deferA }
1358
+ function* func_b() { yield pending_a }
1359
+ var pending_a
1360
+ function* func_c() { yield pending_a }
1361
+ `,
1362
+ parserOptions: { ecmaVersion: "latest" }
1363
+ },
1364
+ )
1365
+ }