Skip to content

Commit

Permalink
Fix identifier handling in default-props-match-prop-types
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Masters committed Aug 11, 2017
1 parent c98ce02 commit f072966
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/default-props-match-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module.exports = {
propWrapperFunctions.has(node.callee.name) &&
node.arguments && node.arguments[0]
) {
return node.arguments[0];
return resolveNodeValue(node.arguments[0]);
}
return node;
}
Expand Down
23 changes: 23 additions & 0 deletions tests/lib/rules/default-props-match-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,29 @@ ruleTester.run('default-props-match-prop-types', rule, {
column: 3
}]
},
{
code: [
'function MyStatelessComponent({ foo, bar }) {',
' return <div>{foo}{bar}</div>;',
'}',
'const propTypes = {',
' foo: React.PropTypes.string,',
' bar: React.PropTypes.string.isRequired',
'};',
'MyStatelessComponent.propTypes = forbidExtraProps(propTypes);',
'MyStatelessComponent.defaultProps = {',
' baz: "baz"',
'};'
].join('\n'),
settings: {
propWrapperFunctions: ['forbidExtraProps']
},
errors: [{
message: 'defaultProp "baz" has no corresponding propTypes declaration.',
line: 10,
column: 3
}]
},
{
code: [
'function MyStatelessComponent({ foo, bar }) {',
Expand Down

0 comments on commit f072966

Please sign in to comment.