Skip to content

Commit

Permalink
Fix no-unused-prop-types crash with Flow spread operator (fixes #1178
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed May 8, 2017
1 parent 159d0e5 commit 1ced710
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,10 @@ module.exports = {
switch (propTypes && propTypes.type) {
case 'ObjectTypeAnnotation':
iterateProperties(propTypes.properties, function(key, value) {
if (!value) {
ignorePropsValidation = true;
return;
}
var types = buildTypeAnnotationDeclarationTypes(value, key);
if (types === true) {
types = {};
Expand Down
28 changes: 28 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,34 @@ ruleTester.run('no-unused-prop-types', rule, {
' bar: PropTypes.bool',
'};'
].join('\n')
}, {
code: [
'type Person = {',
' ...data,',
' lastname: string',
'};',
'class Hello extends React.Component {',
' props: Person;',
' render () {',
' return <div>Hello {this.props.firstname}</div>;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint'
}, {
code: [
'type Person = {|',
' ...data,',
' lastname: string',
'|};',
'class Hello extends React.Component {',
' props: Person;',
' render () {',
' return <div>Hello {this.props.firstname}</div>;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit 1ced710

Please sign in to comment.