From dd10133298cb946edc00c917f287064ab395ed70 Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Sun, 7 May 2017 23:12:54 +0200 Subject: [PATCH] Fix prop-types crash with Flow spread operator (fixes #1178) --- lib/rules/prop-types.js | 4 ++++ tests/lib/rules/prop-types.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js index 46489d0bf2..3f153edc2c 100644 --- a/lib/rules/prop-types.js +++ b/lib/rules/prop-types.js @@ -678,6 +678,10 @@ module.exports = { switch (propTypes && propTypes.type) { case 'ObjectTypeAnnotation': iterateProperties(propTypes.properties, function(key, value) { + if (!value) { + ignorePropsValidation = true; + return; + } declaredPropTypes[key] = buildTypeAnnotationDeclarationTypes(value); }); break; diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index dda457f4fb..251dea4163 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -1428,6 +1428,20 @@ ruleTester.run('prop-types', rule, { '}' ].join('\n'), parser: 'babel-eslint' + }, { + code: [ + 'type Person = {', + ' ...data,', + ' lastname: string', + '};', + 'class Hello extends React.Component {', + ' props: Person;', + ' render () {', + ' return
Hello {this.props.firstname}
;', + ' }', + '}' + ].join('\n'), + parser: 'babel-eslint' } ],