@@ -43,60 +43,56 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, {
43
43
</script>
44
44
`
45
45
} ,
46
+ // ignore multi root by default
46
47
{
47
48
filename : 'test.vue' ,
48
49
code : `
49
50
<script setup>
50
51
defineOptions({ inheritAttrs: true })
51
52
</script>
52
53
<template><div v-bind="$attrs"/><div/></template>
53
- ` ,
54
- options : [ { checkMultiRootNodes : true } ]
54
+ `
55
55
} ,
56
- // ignore multi root
57
56
{
58
57
filename : 'test.vue' ,
59
58
code : `
60
- <template>
61
- <div v-if="condition1"></div>
62
- <div v-if="condition2" v-bind="$attrs"></div>
63
- <div v-else></div>
64
- </template>
65
- ` ,
66
- options : [ { checkMultiRootNodes : true } ]
59
+ <template>
60
+ <div v-if="condition1"></div>
61
+ <div v-if="condition2" v-bind="$attrs"></div>
62
+ <div v-else></div>
63
+ </template>
64
+ `
67
65
} ,
68
66
{
69
67
filename : 'test.vue' ,
70
68
code : `
71
- <template>
72
- <div v-if="condition1"></div>
73
- <div v-else-if="condition2"></div>
74
- <div v-bind="$attrs"></div>
75
- </template>
76
- ` ,
77
- options : [ { checkMultiRootNodes : true } ]
69
+ <template>
70
+ <div v-if="condition1"></div>
71
+ <div v-else-if="condition2"></div>
72
+ <div v-bind="$attrs"></div>
73
+ </template>
74
+ `
78
75
} ,
79
76
{
80
77
filename : 'test.vue' ,
81
78
code : `
82
- <template>
83
- <div v-bind="$attrs"></div>
84
- <div v-if="condition1"></div>
85
- <div v-else></div>
86
- </template>
87
- ` ,
88
- options : [ { checkMultiRootNodes : true } ]
79
+ <template>
80
+ <div v-bind="$attrs"></div>
81
+ <div v-if="condition1"></div>
82
+ <div v-else></div>
83
+ </template>
84
+ `
89
85
} ,
90
86
{
91
87
filename : 'test.vue' ,
92
88
code : `
93
- <template>
94
- <div v-if="condition1"></div>
95
- <div v-else-if="condition2"></div>
96
- <div v-if="condition3" v-bind="$attrs"></div>
97
- </template>
89
+ <template>
90
+ <div v-if="condition1"></div>
91
+ <div v-else-if="condition2"></div>
92
+ <div v-if="condition3" v-bind="$attrs"></div>
93
+ </template>
98
94
` ,
99
- options : [ { checkMultiRootNodes : true } ]
95
+ options : [ { checkMultiRootNodes : false } ]
100
96
} ,
101
97
{
102
98
filename : 'test.vue' ,
@@ -207,62 +203,65 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, {
207
203
}
208
204
]
209
205
} ,
206
+ {
207
+ filename : 'test.vue' ,
208
+ code : `<template><div v-bind="$attrs"></div><div></div></template>` ,
209
+ options : [ { checkMultiRootNodes : true } ] ,
210
+ errors : [ { message : 'Set "inheritAttrs" to false.' } ]
211
+ } ,
210
212
{
211
213
filename : 'test.vue' ,
212
214
code : `
213
- <script setup>
214
- defineOptions({ inheritAttrs: true })
215
- </script>
216
- <template><div v-bind="$attrs"/><div/></template>
215
+ <template>
216
+ <div v-if="condition1" v-bind="$attrs"></div>
217
+ <div v-else></div>
218
+ <div v-if="condition2"></div>
219
+ </template>
217
220
` ,
218
- options : [ { checkMultiRootNodes : false } ] ,
221
+ options : [ { checkMultiRootNodes : true } ] ,
219
222
errors : [ { message : 'Set "inheritAttrs" to false.' } ]
220
223
} ,
221
- // single root with a condition group
224
+ // condition group as a single root node
222
225
{
223
226
filename : 'test.vue' ,
224
227
code : `
225
- <template>
226
- <div v-if="condition1" v-bind="$attrs"></div>
227
- <div v-else-if="condition2"></div>
228
- <div v-else></div>
229
- </template>
228
+ <template>
229
+ <div v-if="condition1" v-bind="$attrs"></div>
230
+ <div v-else-if="condition2"></div>
231
+ <div v-else></div>
232
+ </template>
230
233
` ,
231
- options : [ { checkMultiRootNodes : true } ] ,
232
234
errors : [ { message : 'Set "inheritAttrs" to false.' } ]
233
235
} ,
234
236
{
235
237
filename : 'test.vue' ,
236
238
code : `
237
- <template>
238
- <div v-if="condition1" v-bind="$attrs"></div>
239
- <div v-else-if="condition2"></div>
240
- <div v-else-if="condition3"></div>
241
- <div v-else></div>
242
- </template>
239
+ <template>
240
+ <div v-if="condition1" v-bind="$attrs"></div>
241
+ <div v-else-if="condition2"></div>
242
+ <div v-else-if="condition3"></div>
243
+ <div v-else></div>
244
+ </template>
243
245
` ,
244
- options : [ { checkMultiRootNodes : true } ] ,
245
246
errors : [ { message : 'Set "inheritAttrs" to false.' } ]
246
247
} ,
247
248
{
248
249
filename : 'test.vue' ,
249
250
code : `
250
- <template>
251
- <div v-if="condition1" v-bind="$attrs"></div>
252
- <div v-else></div>
253
- </template>
251
+ <template>
252
+ <div v-if="condition1" v-bind="$attrs"></div>
253
+ <div v-else></div>
254
+ </template>
254
255
` ,
255
- options : [ { checkMultiRootNodes : true } ] ,
256
256
errors : [ { message : 'Set "inheritAttrs" to false.' } ]
257
257
} ,
258
258
{
259
259
filename : 'test.vue' ,
260
260
code : `
261
- <template>
262
- <div v-if="condition1" v-bind="$attrs"></div>
263
- </template>
261
+ <template>
262
+ <div v-if="condition1" v-bind="$attrs"></div>
263
+ </template>
264
264
` ,
265
- options : [ { checkMultiRootNodes : true } ] ,
266
265
errors : [ { message : 'Set "inheritAttrs" to false.' } ]
267
266
}
268
267
]
0 commit comments