Skip to content

Commit

Permalink
Add support and test for custom props name
Browse files Browse the repository at this point in the history
  • Loading branch information
jseminck committed Aug 17, 2017
1 parent 585b94a commit f767f68
Show file tree
Hide file tree
Showing 2 changed files with 15 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 @@ -918,7 +918,7 @@ module.exports = {
},

TypeParameterInstantiation: function(node) {
if (node.params && node.params[0].type === 'GenericTypeAnnotation' && node.params[0].id.name === 'Props') {
if (node.params && node.params[0].type === 'GenericTypeAnnotation') {
markPropTypesAsDeclared(node, resolveTypeAnnotation(node.params[0]));
}
},
Expand Down
14 changes: 14 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,20 @@ ruleTester.run('prop-types', rule, {
`,
parser: 'babel-eslint'
},
{
code: `
type FancyProps = {
foo: string,
};
class Bar extends React.Component<FancyProps> {
render() {
return <div>{this.props.foo}</div>
}
}
`,
parser: 'babel-eslint'
},
// issue #1288
`function Foo() {
const props = {}
Expand Down

0 comments on commit f767f68

Please sign in to comment.