Skip to content

Commit 6f6f4c0

Browse files
committed
Fix crash when retrieving propType name (fixes #163)
1 parent 94eb949 commit 6f6f4c0

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/rules/prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ module.exports = function(context) {
461461
propTypes = null;
462462
}
463463
}
464-
if (propTypes) {
464+
if (propTypes && propTypes.property) {
465465
curDeclaredPropTypes[propTypes.property.name] =
466466
buildReactDeclarationTypes(propTypes.parent.right);
467467
}

tests/lib/rules/prop-types.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,26 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
597597
classes: true,
598598
jsx: true
599599
}
600+
}, {
601+
code: [
602+
'class Comp1 extends Component {',
603+
' render() {',
604+
' return <span />;',
605+
' }',
606+
'}',
607+
'Comp1.propTypes = {',
608+
' prop1: PropTypes.number',
609+
'};',
610+
'class Comp2 extends Component {',
611+
' render() {',
612+
' return <span />;',
613+
' }',
614+
'}',
615+
'Comp2.propTypes = {',
616+
' prop2: PropTypes.arrayOf(Comp1.propTypes.prop1)',
617+
'};'
618+
].join('\n'),
619+
parser: 'babel-eslint'
600620
}
601621
],
602622

0 commit comments

Comments
 (0)