Skip to content

Commit

Permalink
Add invalid test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jseminck committed Aug 16, 2017
1 parent 3e85c55 commit 585b94a
Show file tree
Hide file tree
Showing 2 changed files with 20 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 @@ -919,7 +919,7 @@ module.exports = {

TypeParameterInstantiation: function(node) {
if (node.params && node.params[0].type === 'GenericTypeAnnotation' && node.params[0].id.name === 'Props') {
markPropTypesAsDeclared(node, resolveTypeAnnotation(node));
markPropTypesAsDeclared(node, resolveTypeAnnotation(node.params[0]));
}
},

Expand Down
19 changes: 19 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,25 @@ ruleTester.run('prop-types', rule, {
type: 'Identifier'
}],
parser: 'babel-eslint'
}, {
code: `
type Props = {
foo: string,
};
class Bar extends React.Component<Props> {
render() {
return <div>{this.props.bar}</div>
}
}
`,
errors: [{
message: '\'bar\' is missing in props validation',
line: 8,
column: 37,
type: 'Identifier'
}],
parser: 'babel-eslint'
}
]
});

0 comments on commit 585b94a

Please sign in to comment.