Skip to content

Commit f767f68

Browse files
committed
Add support and test for custom props name
1 parent 585b94a commit f767f68

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/rules/prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ module.exports = {
918918
},
919919

920920
TypeParameterInstantiation: function(node) {
921-
if (node.params && node.params[0].type === 'GenericTypeAnnotation' && node.params[0].id.name === 'Props') {
921+
if (node.params && node.params[0].type === 'GenericTypeAnnotation') {
922922
markPropTypesAsDeclared(node, resolveTypeAnnotation(node.params[0]));
923923
}
924924
},

tests/lib/rules/prop-types.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,20 @@ ruleTester.run('prop-types', rule, {
15721572
`,
15731573
parser: 'babel-eslint'
15741574
},
1575+
{
1576+
code: `
1577+
type FancyProps = {
1578+
foo: string,
1579+
};
1580+
1581+
class Bar extends React.Component<FancyProps> {
1582+
render() {
1583+
return <div>{this.props.foo}</div>
1584+
}
1585+
}
1586+
`,
1587+
parser: 'babel-eslint'
1588+
},
15751589
// issue #1288
15761590
`function Foo() {
15771591
const props = {}

0 commit comments

Comments
 (0)