Skip to content

Commit 663838b

Browse files
author
Dustin Masters
committed
Fix identifier handling in require-default-props
1 parent f072966 commit 663838b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/rules/require-default-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module.exports = {
109109
propWrapperFunctions.has(node.callee.name) &&
110110
node.arguments && node.arguments[0]
111111
) {
112-
return node.arguments[0];
112+
return resolveNodeValue(node.arguments[0]);
113113
}
114114

115115
return node;

tests/lib/rules/require-default-props.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,26 @@ ruleTester.run('require-default-props', rule, {
776776
propWrapperFunctions: ['forbidExtraProps']
777777
}
778778
},
779+
{
780+
code: [
781+
'function MyStatelessComponent({ foo, bar }) {',
782+
' return <div>{foo}{bar}</div>;',
783+
'}',
784+
'const propTypes = {',
785+
' foo: PropTypes.string,',
786+
' bar: PropTypes.string.isRequired',
787+
'};',
788+
'MyStatelessComponent.propTypes = forbidExtraProps(propTypes);'
789+
].join('\n'),
790+
errors: [{
791+
message: 'propType "foo" is not required, but has no corresponding defaultProp declaration.',
792+
line: 5,
793+
column: 3
794+
}],
795+
settings: {
796+
propWrapperFunctions: ['forbidExtraProps']
797+
}
798+
},
779799
{
780800
code: [
781801
'function MyStatelessComponent({ foo, bar }) {',

0 commit comments

Comments
 (0)