@@ -349,15 +349,26 @@ module.exports = {
349
349
} )
350
350
} ,
351
351
352
+ /**
353
+ * Check whether the given node is a Vue component based
354
+ * @param {RuleContext } context The ESLint rule context object.
355
+ * @returns {boolean }
356
+ */
357
+ hasVueComponentComment ( context ) {
358
+ const sourceCode = context . getSourceCode ( )
359
+ return Boolean ( sourceCode . getAllComments ( ) . find ( item => / @ v u e \/ c o m p o n e n t / g. test ( item . value ) ) )
360
+ } ,
361
+
352
362
/**
353
363
* Check whether the given node is a Vue component based
354
364
* on the filename and default export type
355
365
* export default {} in .vue || .jsx
356
366
* @param {ASTNode } node Node to check
357
367
* @param {string } path File name with extension
368
+ * @param {RuleContext } context The ESLint rule context object.
358
369
* @returns {boolean }
359
370
*/
360
- isVueComponentFile ( node , path ) {
371
+ isVueComponentFile ( node , path , context ) {
361
372
const isVueFile = path . endsWith ( '.vue' ) || path . endsWith ( '.jsx' )
362
373
return isVueFile &&
363
374
node . type === 'ExportDefaultDeclaration' &&
@@ -443,8 +454,8 @@ module.exports = {
443
454
444
455
return {
445
456
'ExportDefaultDeclaration:exit' ( node ) {
446
- // export default {} in .vue || .jsx
447
- if ( ! _this . isVueComponentFile ( node , filePath ) ) return
457
+ // export default {} in .vue || .jsx or comment with @vue/component
458
+ if ( ! _this . isVueComponentFile ( node , filePath , context ) && ! _this . hasVueComponentComment ( context ) ) return
448
459
cb ( node . declaration )
449
460
} ,
450
461
'CallExpression:exit' ( node ) {
0 commit comments