@@ -10,6 +10,7 @@ import {
10
10
type StringLiteral ,
11
11
isBlockStatement ,
12
12
isCallExpression ,
13
+ isExportDefaultDeclaration ,
13
14
isIdentifier ,
14
15
isIfStatement ,
15
16
isImportDeclaration ,
@@ -201,8 +202,8 @@ function parseVueComponentName(filename: string) {
201
202
202
203
const exportDefaultDecliaration = scriptDescriptors
203
204
. get ( filename )
204
- ?. ast . body . find (
205
- ( v ) => v . type === 'ExportDefaultDeclaration'
205
+ ?. ast . body . find ( ( node ) =>
206
+ isExportDefaultDeclaration ( node )
206
207
) as ExportDefaultDeclaration | null
207
208
208
209
if ( ! exportDefaultDecliaration ) return name
@@ -211,11 +212,11 @@ function parseVueComponentName(filename: string) {
211
212
212
213
const { declaration } = exportDefaultDecliaration
213
214
214
- if ( declaration . type === 'ObjectExpression' ) {
215
+ if ( isObjectExpression ( declaration ) ) {
215
216
defineComponentDeclaration = declaration
216
217
} else if (
217
- declaration . type === 'CallExpression' &&
218
- declaration . callee . type === 'Identifier' &&
218
+ isCallExpression ( declaration ) &&
219
+ isIdentifier ( declaration . callee ) &&
219
220
/ _ * d e f i n e C o m p o n e n t / . test ( declaration . callee . name )
220
221
) {
221
222
defineComponentDeclaration =
@@ -226,10 +227,10 @@ function parseVueComponentName(filename: string) {
226
227
227
228
for ( const prop of defineComponentDeclaration . properties ) {
228
229
if (
229
- prop . type === 'ObjectProperty' &&
230
- prop . key . type === 'Identifier' &&
230
+ isObjectProperty ( prop ) &&
231
+ isIdentifier ( prop . key ) &&
231
232
/ ( _ _ ) ? n a m e / . test ( prop . key . name ) &&
232
- prop . value . type === 'StringLiteral'
233
+ isStringLiteral ( prop . value )
233
234
) {
234
235
return prop . value . value
235
236
}
0 commit comments