Skip to content

Commit

Permalink
Fix identifier handling in require-default-props
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Masters committed Aug 11, 2017
1 parent f072966 commit 663838b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/require-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,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
20 changes: 20 additions & 0 deletions tests/lib/rules/require-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,26 @@ ruleTester.run('require-default-props', rule, {
propWrapperFunctions: ['forbidExtraProps']
}
},
{
code: [
'function MyStatelessComponent({ foo, bar }) {',
' return <div>{foo}{bar}</div>;',
'}',
'const propTypes = {',
' foo: PropTypes.string,',
' bar: PropTypes.string.isRequired',
'};',
'MyStatelessComponent.propTypes = forbidExtraProps(propTypes);'
].join('\n'),
errors: [{
message: 'propType "foo" is not required, but has no corresponding defaultProp declaration.',
line: 5,
column: 3
}],
settings: {
propWrapperFunctions: ['forbidExtraProps']
}
},
{
code: [
'function MyStatelessComponent({ foo, bar }) {',
Expand Down

0 comments on commit 663838b

Please sign in to comment.