@@ -318,7 +318,7 @@ function getComponentNamesByStaticPropTypeAttribute(ast: AstQuery): string[] {
318318 ]
319319 ` ) ;
320320 if ( res . length > 0 ) {
321- return res . map ( match => match . id . name ) ;
321+ return res . map ( match => match . id ? match . id . name : '' ) ;
322322 }
323323 return [ ] ;
324324}
@@ -337,7 +337,7 @@ function getComponentNamesByJsxInBody(ast: AstQuery): string[] {
337337 ]
338338 ` ) ;
339339 if ( res . length > 0 ) {
340- return res . map ( match => match . id . name ) ;
340+ return res . map ( match => match . id ? match . id . name : '' ) ;
341341 }
342342 return [ ] ;
343343}
@@ -358,6 +358,19 @@ function getPropTypesFromAssignment(ast: AstQuery, componentName: string): any|u
358358}
359359
360360function getPropTypesFromStaticAttribute ( ast : AstQuery , componentName : string ) : any | undefined {
361+ if ( componentName === '' ) {
362+ const res = ast . query ( `
363+ //ClassDeclaration
364+ /:body *
365+ //ClassProperty[
366+ /:key Identifier[@name == 'propTypes']
367+ ]
368+ /:value*
369+ ` ) ;
370+ if ( res . length > 0 && ! res [ 0 ] . id ) {
371+ return res [ 0 ] ;
372+ }
373+ }
361374 const res = ast . query ( `
362375 //ClassDeclaration[
363376 /:id Identifier[@name == '${ componentName } ']
@@ -375,6 +388,19 @@ function getPropTypesFromStaticAttribute(ast: AstQuery, componentName: string):
375388}
376389
377390function getComponentExportType ( ast : AstQuery , componentName : string ) : dom . DeclarationFlags | undefined {
391+ if ( componentName === '' ) {
392+ // case: unnamed default export
393+ const res = ast . query ( `
394+ // ExportDefaultDeclaration[
395+ // ClassDeclaration
396+ ||
397+ // FunctionDeclaration
398+ ]
399+ ` ) ;
400+ if ( res . length > 0 && ! res [ 0 ] . id ) {
401+ return dom . DeclarationFlags . ExportDefault ;
402+ }
403+ }
378404 let res = ast . query ( `
379405 // ExportDefaultDeclaration[
380406 // ClassDeclaration
@@ -424,6 +450,14 @@ function getComponentExportType(ast: AstQuery, componentName: string): dom.Decla
424450
425451function isClassComponent ( ast : AstQuery , componentName : string ,
426452 reactComponentName : string | undefined ) : boolean {
453+ if ( componentName === '' ) {
454+ const res = ast . query ( `
455+ // ClassDeclaration
456+ ` ) ;
457+ if ( res . length > 0 && ! res [ 0 ] . id ) {
458+ return true ;
459+ }
460+ }
427461 const res = ast . query ( `
428462 // ClassDeclaration
429463 /:id Identifier[@name == '${ componentName } ']
0 commit comments