Skip to content

Commit

Permalink
Fix crash when retrieving propType name (fixes #163)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jul 21, 2015
1 parent 94eb949 commit 6f6f4c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ module.exports = function(context) {
propTypes = null;
}
}
if (propTypes) {
if (propTypes && propTypes.property) {
curDeclaredPropTypes[propTypes.property.name] =
buildReactDeclarationTypes(propTypes.parent.right);
}
Expand Down
20 changes: 20 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,26 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
classes: true,
jsx: true
}
}, {
code: [
'class Comp1 extends Component {',
' render() {',
' return <span />;',
' }',
'}',
'Comp1.propTypes = {',
' prop1: PropTypes.number',
'};',
'class Comp2 extends Component {',
' render() {',
' return <span />;',
' }',
'}',
'Comp2.propTypes = {',
' prop2: PropTypes.arrayOf(Comp1.propTypes.prop1)',
'};'
].join('\n'),
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit 6f6f4c0

Please sign in to comment.