@@ -95,6 +95,10 @@ module.exports = {
95
95
return temp ;
96
96
}
97
97
98
+ function isString ( node ) {
99
+ return typeof node . value === 'string' ;
100
+ }
101
+
98
102
const scriptVisitor = {
99
103
//
100
104
// ─── EXPORT AND IMPORT ───────────────────────────────────────────
@@ -162,7 +166,6 @@ module.exports = {
162
166
} ,
163
167
164
168
'Property > Literal' ( node ) {
165
- if ( visited . includes ( node ) ) return ;
166
169
const { parent } = node ;
167
170
// if node is key of property, skip
168
171
if ( parent . key === node ) visited . push ( node ) ;
@@ -174,14 +177,11 @@ module.exports = {
174
177
} ,
175
178
176
179
'CallExpression Literal' ( node ) {
177
- if ( visited . includes ( node ) ) return ;
178
180
const parent = getNearestAncestor ( node , 'CallExpression' ) ;
179
181
if ( isValidFunctionCall ( parent ) ) visited . push ( node ) ;
180
182
} ,
181
183
182
184
'Literal:exit' ( node ) {
183
- if ( visited . includes ( node ) ) return ;
184
-
185
185
if ( typeof node . value === 'string' ) {
186
186
const trimed = node . value . trim ( ) ;
187
187
if ( ! trimed ) return ;
@@ -196,6 +196,23 @@ module.exports = {
196
196
}
197
197
}
198
198
} ;
199
+
200
+ function wrapVisitor ( ) {
201
+ Object . keys ( scriptVisitor ) . forEach ( key => {
202
+ const old = scriptVisitor [ key ] ;
203
+ scriptVisitor [ key ] = node => {
204
+ // make sure node is string literal
205
+ if ( ! isString ( node ) ) return ;
206
+
207
+ // visited and passed linting
208
+ if ( visited . includes ( node ) ) return ;
209
+ old ( node ) ;
210
+ } ;
211
+ } ) ;
212
+ }
213
+
214
+ wrapVisitor ( ) ;
215
+
199
216
return (
200
217
( parserServices . defineTemplateBodyVisitor &&
201
218
parserServices . defineTemplateBodyVisitor (
0 commit comments