@@ -341,15 +341,26 @@ module.exports = {
341
341
} )
342
342
} ,
343
343
344
+ /**
345
+ * Check whether the given node is a Vue component based
346
+ * @param {RuleContext } context The ESLint rule context object.
347
+ * @returns {boolean }
348
+ */
349
+ hasVueComponentComment ( context ) {
350
+ const sourceCode = context . getSourceCode ( )
351
+ return Boolean ( sourceCode . getAllComments ( ) . find ( item => / @ v u e \/ c o m p o n e n t / g. test ( item . value ) ) )
352
+ } ,
353
+
344
354
/**
345
355
* Check whether the given node is a Vue component based
346
356
* on the filename and default export type
347
357
* export default {} in .vue || .jsx
348
358
* @param {ASTNode } node Node to check
349
359
* @param {string } path File name with extension
360
+ * @param {RuleContext } context The ESLint rule context object.
350
361
* @returns {boolean }
351
362
*/
352
- isVueComponentFile ( node , path ) {
363
+ isVueComponentFile ( node , path , context ) {
353
364
const isVueFile = path . endsWith ( '.vue' ) || path . endsWith ( '.jsx' )
354
365
return isVueFile &&
355
366
node . type === 'ExportDefaultDeclaration' &&
@@ -435,8 +446,8 @@ module.exports = {
435
446
436
447
return {
437
448
'ExportDefaultDeclaration:exit' ( node ) {
438
- // export default {} in .vue || .jsx
439
- if ( ! _this . isVueComponentFile ( node , filePath ) ) return
449
+ // export default {} in .vue || .jsx or comment with @vue/component
450
+ if ( ! _this . isVueComponentFile ( node , filePath , context ) && ! _this . hasVueComponentComment ( context ) ) return
440
451
cb ( node . declaration )
441
452
} ,
442
453
'CallExpression:exit' ( node ) {
0 commit comments