@@ -43,60 +43,56 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, {
4343 </script>
4444 `
4545 } ,
46+ // ignore multi root by default
4647 {
4748 filename : 'test.vue' ,
4849 code : `
4950 <script setup>
5051 defineOptions({ inheritAttrs: true })
5152 </script>
5253 <template><div v-bind="$attrs"/><div/></template>
53- ` ,
54- options : [ { checkMultiRootNodes : true } ]
54+ `
5555 } ,
56- // ignore multi root
5756 {
5857 filename : 'test.vue' ,
5958 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+ `
6765 } ,
6866 {
6967 filename : 'test.vue' ,
7068 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+ `
7875 } ,
7976 {
8077 filename : 'test.vue' ,
8178 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+ `
8985 } ,
9086 {
9187 filename : 'test.vue' ,
9288 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>
9894 ` ,
99- options : [ { checkMultiRootNodes : true } ]
95+ options : [ { checkMultiRootNodes : false } ]
10096 } ,
10197 {
10298 filename : 'test.vue' ,
@@ -207,62 +203,65 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, {
207203 }
208204 ]
209205 } ,
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+ } ,
210212 {
211213 filename : 'test.vue' ,
212214 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>
217220 ` ,
218- options : [ { checkMultiRootNodes : false } ] ,
221+ options : [ { checkMultiRootNodes : true } ] ,
219222 errors : [ { message : 'Set "inheritAttrs" to false.' } ]
220223 } ,
221- // single root with a condition group
224+ // condition group as a single root node
222225 {
223226 filename : 'test.vue' ,
224227 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>
230233 ` ,
231- options : [ { checkMultiRootNodes : true } ] ,
232234 errors : [ { message : 'Set "inheritAttrs" to false.' } ]
233235 } ,
234236 {
235237 filename : 'test.vue' ,
236238 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>
243245 ` ,
244- options : [ { checkMultiRootNodes : true } ] ,
245246 errors : [ { message : 'Set "inheritAttrs" to false.' } ]
246247 } ,
247248 {
248249 filename : 'test.vue' ,
249250 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>
254255 ` ,
255- options : [ { checkMultiRootNodes : true } ] ,
256256 errors : [ { message : 'Set "inheritAttrs" to false.' } ]
257257 } ,
258258 {
259259 filename : 'test.vue' ,
260260 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>
264264 ` ,
265- options : [ { checkMultiRootNodes : true } ] ,
266265 errors : [ { message : 'Set "inheritAttrs" to false.' } ]
267266 }
268267 ]
0 commit comments