@@ -2479,10 +2479,11 @@ function isVueComponentFile(node, path) {
24792479/**
24802480 * Get the Vue component definition type from given node
24812481 * Vue.component('xxx', {}) || component('xxx', {})
2482+ * @param {RuleContext } context The rule context to use parser services.
24822483 * @param {ObjectExpression } node Node to check
24832484 * @returns {'component' | 'mixin' | 'extend' | 'createApp' | 'defineComponent' | null }
24842485 */
2485- function getVueComponentDefinitionType ( node ) {
2486+ function getVueComponentDefinitionType ( context , node ) {
24862487 const parent = getParent ( node )
24872488 if ( parent . type === 'CallExpression' ) {
24882489 const callee = parent . callee
@@ -2527,6 +2528,26 @@ function getVueComponentDefinitionType(node) {
25272528 if ( callee . name === 'createApp' ) {
25282529 // for Vue.js 3.x
25292530 // createApp({})
2531+
2532+ const variable = findVariable ( context . getScope ( ) , callee )
2533+
2534+ // only lint the createApp function that import from vue
2535+ if ( variable != null && variable . defs . length === 1 ) {
2536+ const def = variable . defs [ 0 ]
2537+ if ( ! def . node . parent ) {
2538+ debugger
2539+ }
2540+ if (
2541+ def . type === 'ImportBinding' &&
2542+ def . node . type === 'ImportSpecifier' &&
2543+ def . node . imported . type === 'Identifier' &&
2544+ def . node . parent . type === 'ImportDeclaration' &&
2545+ def . node . parent . source . value !== 'vue'
2546+ ) {
2547+ return null
2548+ }
2549+ }
2550+
25302551 const isAppVueComponent = isObjectArgument ( parent )
25312552 return isAppVueComponent ? 'createApp' : null
25322553 }
@@ -2603,7 +2624,7 @@ function getVueObjectType(context, node) {
26032624 case 'CallExpression' : {
26042625 // Vue.component('xxx', {}) || component('xxx', {})
26052626 if (
2606- getVueComponentDefinitionType ( node ) != null &&
2627+ getVueComponentDefinitionType ( context , node ) != null &&
26072628 skipTSAsExpression ( parent . arguments . slice ( - 1 ) [ 0 ] ) === node
26082629 ) {
26092630 return 'definition'
0 commit comments