File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,12 @@ const utils = require('../utils')
10
10
* Collect used variables recursively.
11
11
*
12
12
* @param {Node } node - The node to collect.
13
- * @param {Object } used - The object to restore result.
13
+ * @param {Object } used(optional) - The object to restore result.
14
14
* @returns {Object } used variables.
15
15
*/
16
16
function collectUsed ( node , used ) {
17
+ used = used || { }
18
+
17
19
if ( node . type === 'VExpressionContainer' ) {
18
20
node . references . forEach ( ref => {
19
21
used [ ref . id . name ] = true
@@ -42,7 +44,7 @@ function create (context) {
42
44
utils . registerTemplateBodyVisitor ( context , {
43
45
"VAttribute[directive=true][key.name='for']" : function ( node ) {
44
46
const vars = node . value . expression . left
45
- const used = collectUsed ( node . parent . parent , { } )
47
+ const used = collectUsed ( node . parent . parent )
46
48
47
49
// report unused.
48
50
vars . filter ( v => ! used [ v . name ] ) . forEach ( v => {
@@ -58,7 +60,7 @@ function create (context) {
58
60
} ,
59
61
60
62
"VAttribute[directive=false][key.name='scope']" : function ( node ) {
61
- const used = collectUsed ( node . parent . parent , { } )
63
+ const used = collectUsed ( node . parent . parent )
62
64
63
65
if ( ! used [ node . value . value ] ) {
64
66
context . report ( {
You can’t perform that action at this time.
0 commit comments