@@ -44,6 +44,37 @@ ruleTester.run('no-dupe-keys', rule, {
44
44
` ,
45
45
parserOptions : { ecmaVersion : 6 , sourceType : 'module' }
46
46
} ,
47
+ {
48
+ filename : 'test.vue' ,
49
+ code : `
50
+ export default {
51
+ props: ['foo'],
52
+ data () {
53
+ return {
54
+ dat: null
55
+ }
56
+ },
57
+ data () {
58
+ return
59
+ },
60
+ methods: {
61
+ _foo () {},
62
+ test () {
63
+ }
64
+ },
65
+ setup () {
66
+ const _foo = () => {}
67
+ const dat = ref(null)
68
+ const bar = computed(() => 'bar')
69
+
70
+ return {
71
+ bar
72
+ }
73
+ }
74
+ }
75
+ ` ,
76
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' }
77
+ } ,
47
78
48
79
{
49
80
filename : 'test.vue' ,
@@ -134,6 +165,51 @@ ruleTester.run('no-dupe-keys', rule, {
134
165
parserOptions : { ecmaVersion : 2018 , sourceType : 'module' }
135
166
} ,
136
167
168
+ {
169
+ filename : 'test.vue' ,
170
+ code : `
171
+ export default {
172
+ ...foo(),
173
+ props: {
174
+ ...foo(),
175
+ foo: String
176
+ },
177
+ computed: {
178
+ ...mapGetters({
179
+ test: 'getTest'
180
+ }),
181
+ bar: {
182
+ get () {
183
+ }
184
+ }
185
+ },
186
+ data: {
187
+ ...foo(),
188
+ dat: null
189
+ },
190
+ methods: {
191
+ ...foo(),
192
+ test () {
193
+ }
194
+ },
195
+ data () {
196
+ return {
197
+ ...dat
198
+ }
199
+ },
200
+ setup () {
201
+ const com = computed(() => 1)
202
+
203
+ return {
204
+ ...foo(),
205
+ com
206
+ }
207
+ }
208
+ }
209
+ ` ,
210
+ parserOptions : { ecmaVersion : 2018 , sourceType : 'module' }
211
+ } ,
212
+
137
213
{
138
214
filename : 'test.vue' ,
139
215
code : `
@@ -224,6 +300,39 @@ ruleTester.run('no-dupe-keys', rule, {
224
300
}
225
301
` ,
226
302
parserOptions : { ecmaVersion : 6 , sourceType : 'module' }
303
+ } ,
304
+ {
305
+ filename : 'test.vue' ,
306
+ code : `
307
+ // @vue/component
308
+ export const compA = {
309
+ props: {
310
+ propA: String
311
+ },
312
+ setup (props) {
313
+ const com = computed(() => props.propA)
314
+
315
+ return {
316
+ com
317
+ }
318
+ }
319
+ }
320
+
321
+ // @vue/component
322
+ export const compB = {
323
+ props: {
324
+ propA: String
325
+ },
326
+ setup (props) {
327
+ const com = computed(() => props.propA)
328
+
329
+ return {
330
+ com
331
+ }
332
+ }
333
+ }
334
+ ` ,
335
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' }
227
336
}
228
337
] ,
229
338
@@ -245,6 +354,13 @@ ruleTester.run('no-dupe-keys', rule, {
245
354
methods: {
246
355
foo () {
247
356
}
357
+ },
358
+ setup () {
359
+ const foo = ref(1)
360
+
361
+ return {
362
+ foo
363
+ }
248
364
}
249
365
}
250
366
` ,
@@ -258,6 +374,9 @@ ruleTester.run('no-dupe-keys', rule, {
258
374
} , {
259
375
message : 'Duplicated key \'foo\'.' ,
260
376
line : 14
377
+ } , {
378
+ message : 'Duplicated key \'foo\'.' ,
379
+ line : 21
261
380
} ]
262
381
} ,
263
382
{
@@ -277,6 +396,13 @@ ruleTester.run('no-dupe-keys', rule, {
277
396
methods: {
278
397
foo () {
279
398
}
399
+ },
400
+ setup: () => {
401
+ const foo = computed(() => 0)
402
+
403
+ return {
404
+ foo
405
+ }
280
406
}
281
407
}
282
408
` ,
@@ -290,6 +416,9 @@ ruleTester.run('no-dupe-keys', rule, {
290
416
} , {
291
417
message : 'Duplicated key \'foo\'.' ,
292
418
line : 14
419
+ } , {
420
+ message : 'Duplicated key \'foo\'.' ,
421
+ line : 21
293
422
} ]
294
423
} ,
295
424
{
@@ -341,6 +470,13 @@ ruleTester.run('no-dupe-keys', rule, {
341
470
methods: {
342
471
foo () {
343
472
}
473
+ },
474
+ setup (props) {
475
+ const foo = computed(() => props.foo)
476
+
477
+ return {
478
+ foo
479
+ }
344
480
}
345
481
}
346
482
` ,
@@ -354,6 +490,9 @@ ruleTester.run('no-dupe-keys', rule, {
354
490
} , {
355
491
message : 'Duplicated key \'foo\'.' ,
356
492
line : 16
493
+ } , {
494
+ message : 'Duplicated key \'foo\'.' ,
495
+ line : 23
357
496
} ]
358
497
} ,
359
498
{
@@ -374,6 +513,132 @@ ruleTester.run('no-dupe-keys', rule, {
374
513
message : 'Duplicated key \'bar\'.' ,
375
514
line : 7
376
515
} ]
516
+ } ,
517
+ {
518
+ filename : 'test.vue' ,
519
+ code : `
520
+ export default {
521
+ methods: {
522
+ foo () {
523
+ return 0
524
+ }
525
+ },
526
+ setup () {
527
+ const foo = () => 0
528
+
529
+ return {
530
+ foo
531
+ }
532
+ }
533
+ }
534
+ ` ,
535
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
536
+ errors : [ {
537
+ message : 'Duplicated key \'foo\'.' ,
538
+ line : 12
539
+ } ]
540
+ } ,
541
+ {
542
+ filename : 'test.vue' ,
543
+ code : `
544
+ export default {
545
+ methods: {
546
+ foo () {
547
+ return 0
548
+ }
549
+ },
550
+ setup () {
551
+ return {
552
+ foo: () => 0
553
+ }
554
+ }
555
+ }
556
+ ` ,
557
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
558
+ errors : [ {
559
+ message : 'Duplicated key \'foo\'.' ,
560
+ line : 10
561
+ } ]
562
+ } ,
563
+ {
564
+ filename : 'test.vue' ,
565
+ code : `
566
+ export default {
567
+ methods: {
568
+ foo () {
569
+ return 0
570
+ }
571
+ },
572
+ setup: () => ({
573
+ foo: () => 0
574
+ })
575
+ }
576
+ ` ,
577
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
578
+ errors : [ {
579
+ message : 'Duplicated key \'foo\'.' ,
580
+ line : 9
581
+ } ]
582
+ } ,
583
+ {
584
+ filename : 'test.vue' ,
585
+ code : `
586
+ export default {
587
+ computed: {
588
+ foo () {
589
+ return 0
590
+ }
591
+ },
592
+ setup: () => ({
593
+ foo: computed(() => 0)
594
+ })
595
+ }
596
+ ` ,
597
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
598
+ errors : [ {
599
+ message : 'Duplicated key \'foo\'.' ,
600
+ line : 9
601
+ } ]
602
+ } ,
603
+ {
604
+ filename : 'test.vue' ,
605
+ code : `
606
+ export default {
607
+ data() {
608
+ return {
609
+ foo: 0
610
+ }
611
+ },
612
+ setup: () => ({
613
+ foo: ref(0)
614
+ })
615
+ }
616
+ ` ,
617
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
618
+ errors : [ {
619
+ message : 'Duplicated key \'foo\'.' ,
620
+ line : 9
621
+ } ]
622
+ } ,
623
+ {
624
+ filename : 'test.vue' ,
625
+ code : `
626
+ export default {
627
+ data() {
628
+ return {
629
+ foo: 0
630
+ }
631
+ },
632
+ setup: () => ({
633
+ foo: 0
634
+ })
635
+ }
636
+ ` ,
637
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
638
+ errors : [ {
639
+ message : 'Duplicated key \'foo\'.' ,
640
+ line : 9
641
+ } ]
377
642
}
378
643
]
379
644
} )
0 commit comments