@@ -25,8 +25,7 @@ module.exports = {
25
25
* this generates a warning.
26
26
*
27
27
* @param {RuleContext } context The rule context to use parser services.
28
- * @param {object } visitor The visitor.
29
- * @returns {void }
28
+ * @param {Object } visitor The visitor.
30
29
*/
31
30
registerTemplateBodyVisitor ( context , visitor ) {
32
31
if ( context . parserServices . registerTemplateBodyVisitor == null ) {
@@ -175,11 +174,11 @@ module.exports = {
175
174
)
176
175
} ,
177
176
178
- /**
179
- * Check whether the previous sibling element has `if` or `else-if` directive.
180
- * @param {ASTNode } node The element node to check.
181
- * @returns {boolean } `true` if the previous sibling element has `if` or `else-if` directive.
182
- */
177
+ /**
178
+ * Check whether the previous sibling element has `if` or `else-if` directive.
179
+ * @param {ASTNode } node The element node to check.
180
+ * @returns {boolean } `true` if the previous sibling element has `if` or `else-if` directive.
181
+ */
183
182
prevElementHasIf ( node ) {
184
183
assert ( node && node . type === 'VElement' )
185
184
@@ -193,11 +192,11 @@ module.exports = {
193
192
)
194
193
} ,
195
194
196
- /**
197
- * Check whether the given node is a custom component or not.
198
- * @param {ASTNode } node The start tag node to check.
199
- * @returns {boolean } `true` if the node is a custom component.
200
- */
195
+ /**
196
+ * Check whether the given node is a custom component or not.
197
+ * @param {ASTNode } node The start tag node to check.
198
+ * @returns {boolean } `true` if the node is a custom component.
199
+ */
201
200
isCustomComponent ( node ) {
202
201
assert ( node && node . type === 'VElement' )
203
202
@@ -278,11 +277,11 @@ module.exports = {
278
277
*/
279
278
getComputedProperties ( componentObject ) {
280
279
const computedPropertiesNode = componentObject . properties
281
- . filter ( p =>
280
+ . find ( p =>
282
281
p . key . type === 'Identifier' &&
283
282
p . key . name === 'computed' &&
284
283
p . value . type === 'ObjectExpression'
285
- ) [ 0 ]
284
+ )
286
285
287
286
if ( ! computedPropertiesNode ) { return [ ] }
288
287
@@ -362,13 +361,23 @@ module.exports = {
362
361
node . arguments [ 0 ] . type === 'ObjectExpression'
363
362
} ,
364
363
364
+ /**
365
+ * Check if current file is a Vue instance or component and call callback
366
+ * @param {RuleContext } context The ESLint rule context object.
367
+ * @param {Function } cb Callback function
368
+ */
365
369
executeOnVue ( context , cb ) {
366
370
return Object . assign (
367
371
this . executeOnVueComponent ( context , cb ) ,
368
372
this . executeOnVueInstance ( context , cb )
369
373
)
370
374
} ,
371
375
376
+ /**
377
+ * Check if current file is a Vue instance (new Vue) and call callback
378
+ * @param {RuleContext } context The ESLint rule context object.
379
+ * @param {Function } cb Callback function
380
+ */
372
381
executeOnVueInstance ( context , cb ) {
373
382
const _this = this
374
383
@@ -381,6 +390,11 @@ module.exports = {
381
390
}
382
391
} ,
383
392
393
+ /**
394
+ * Check if current file is a Vue component and call callback
395
+ * @param {RuleContext } context The ESLint rule context object.
396
+ * @param {Function } cb Callback function
397
+ */
384
398
executeOnVueComponent ( context , cb ) {
385
399
const filePath = context . getFilename ( )
386
400
const _this = this
0 commit comments