@@ -2479,10 +2479,11 @@ function isVueComponentFile(node, path) {
2479
2479
/**
2480
2480
* Get the Vue component definition type from given node
2481
2481
* Vue.component('xxx', {}) || component('xxx', {})
2482
+ * @param {RuleContext } context The rule context to use parser services.
2482
2483
* @param {ObjectExpression } node Node to check
2483
2484
* @returns {'component' | 'mixin' | 'extend' | 'createApp' | 'defineComponent' | null }
2484
2485
*/
2485
- function getVueComponentDefinitionType ( node ) {
2486
+ function getVueComponentDefinitionType ( context , node ) {
2486
2487
const parent = getParent ( node )
2487
2488
if ( parent . type === 'CallExpression' ) {
2488
2489
const callee = parent . callee
@@ -2527,6 +2528,23 @@ function getVueComponentDefinitionType(node) {
2527
2528
if ( callee . name === 'createApp' ) {
2528
2529
// for Vue.js 3.x
2529
2530
// 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 (
2538
+ def . type === 'ImportBinding' &&
2539
+ def . node . type === 'ImportSpecifier' &&
2540
+ def . node . imported . type === 'Identifier' &&
2541
+ def . node . parent . type === 'ImportDeclaration' &&
2542
+ def . node . parent . source . value !== 'vue'
2543
+ ) {
2544
+ return null
2545
+ }
2546
+ }
2547
+
2530
2548
const isAppVueComponent = isObjectArgument ( parent )
2531
2549
return isAppVueComponent ? 'createApp' : null
2532
2550
}
@@ -2603,7 +2621,7 @@ function getVueObjectType(context, node) {
2603
2621
case 'CallExpression' : {
2604
2622
// Vue.component('xxx', {}) || component('xxx', {})
2605
2623
if (
2606
- getVueComponentDefinitionType ( node ) != null &&
2624
+ getVueComponentDefinitionType ( context , node ) != null &&
2607
2625
skipTSAsExpression ( parent . arguments . slice ( - 1 ) [ 0 ] ) === node
2608
2626
) {
2609
2627
return 'definition'
0 commit comments