Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TypeError: Cannot read property 'name' of undefined at require-default-props.js:291:23 #1029

Closed
@jwarykowski

Description

@jwarykowski

Overview

Seen another instance of theCannot read property 'name' issue which has already been raised in issue#1021. Again using the following package versions:

  • eslint-config-airbnb@14.0.0
  • eslint-plugin-react@6.9.0

Error returned is:

Cannotreadproperty'name'ofundefinedTypeError:Cannotreadproperty'name'ofundefinedatisPropTypeAnnotation(/Users/user/path/org/project/node_modules/eslint-plugin-react/lib/rules/require-default-props.js:291:23)atObject.ClassProperty(/Users/user/path/org/project/node_modules/eslint-plugin-react/lib/rules/require-default-props.js:461:13)

After checkingrequire-default-props.js its failing at this point:

functionisPropTypeAnnotation(node){return(node.key.name==='props'&&!!node.typeAnnotation);}

After inspecting the node I have the following returned:

Node{type:'ClassProperty',start:301,end:414,loc:SourceLocation{start:Position{line:11,column:2},end:Position{line:15,column:3}},computed:false,variance:null,static:true,value:Node{type:'ObjectExpression',start:320,end:414,loc:SourceLocation{start:[Object],end:[Object]},properties:[[Object],[Object],[Object]],range:[320,414],_babelType:'ObjectExpression'},range:[301,414],_babelType:'ClassProperty',parent:Node{type:'ClassBody',start:296,end:1235,loc:SourceLocation{start:[Object],end:[Object]},body:[[Circular],[Object],[Object],[Object]],range:[296,1235],_babelType:'ClassBody',parent:Node{type:'ClassDeclaration',start:265,end:1235,loc:[Object],id:[Object],superClass:[Object],body:[Circular],decorators:[Object],range:[Object],_babelType:'ClassDeclaration',parent:[Object]}}}

After inspecting then source in question returned fromcontext.getFilename() and checking the line number, I have the following code:

exportdefaultclassAnchorextendsComponent{staticpropTypes={active:PropTypes.bool,underline:PropTypes.bool,tooltip:PropTypes.array,}...}

After checking the source commentshere this all appears to be valid.

As you can see in the above node output there is nokey property? Has there been a breaking change here? Any insight would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp