File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,13 @@ function collectUsed (node, used) {
20
20
} )
21
21
}
22
22
23
+ if ( node . type === 'VAttribute' ) {
24
+ collectUsed ( node . value , used )
25
+ }
26
+
23
27
if ( node . type === 'VElement' ) {
24
28
node . children . forEach ( child => collectUsed ( child , used ) )
29
+ node . startTag . attributes . forEach ( attr => collectUsed ( attr , used ) )
25
30
}
26
31
27
32
return used
Original file line number Diff line number Diff line change @@ -24,22 +24,24 @@ const tester = new RuleTester({
24
24
tester . run ( 'no-unused-vars' , rule , {
25
25
valid : [
26
26
{
27
- filename : 'test.vue' ,
28
27
code : '<template><ol v-for="i in 5"><li>{{i}}</li></ol></template>'
29
28
} ,
30
29
{
31
- filename : 'test.vue' ,
30
+ code : '<template><ol v-for="i in 5"><li :prop="i"></li></ol></template>'
31
+ } ,
32
+ {
32
33
code : '<template scope="props">{{props}}</template>'
34
+ } ,
35
+ {
36
+ code : '<template scope="props"><span v-if="props"></span></template>'
33
37
}
34
38
] ,
35
39
invalid : [
36
40
{
37
- filename : 'test.vue' ,
38
- code : '<template><ol v-for="i in 5"></ol></template>' ,
41
+ code : '<template><ol v-for="i in 5"><li></li></ol></template>' ,
39
42
errors : [ '\'i\' is defined but never used.' ]
40
43
} ,
41
44
{
42
- filename : 'test.vue' ,
43
45
code : '<template scope="props"></template>' ,
44
46
errors : [ '\'props\' is defined but never used.' ]
45
47
}
You can’t perform that action at this time.
0 commit comments