Skip to content

Commit 585b94a

Browse files
committed
Add invalid test case
1 parent 3e85c55 commit 585b94a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/rules/prop-types.js

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

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

tests/lib/rules/prop-types.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,6 +2942,25 @@ ruleTester.run('prop-types', rule, {
29422942
type: 'Identifier'
29432943
}],
29442944
parser: 'babel-eslint'
2945+
}, {
2946+
code: `
2947+
type Props = {
2948+
foo: string,
2949+
};
2950+
2951+
class Bar extends React.Component<Props> {
2952+
render() {
2953+
return <div>{this.props.bar}</div>
2954+
}
2955+
}
2956+
`,
2957+
errors: [{
2958+
message: '\'bar\' is missing in props validation',
2959+
line: 8,
2960+
column: 37,
2961+
type: 'Identifier'
2962+
}],
2963+
parser: 'babel-eslint'
29452964
}
29462965
]
29472966
});

0 commit comments

Comments
 (0)