Skip to content

Commit f072966

Browse files
author
Dustin Masters
committed
Fix identifier handling in default-props-match-prop-types
1 parent c98ce02 commit f072966

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/rules/default-props-match-prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ module.exports = {
119119
propWrapperFunctions.has(node.callee.name) &&
120120
node.arguments && node.arguments[0]
121121
) {
122-
return node.arguments[0];
122+
return resolveNodeValue(node.arguments[0]);
123123
}
124124
return node;
125125
}

tests/lib/rules/default-props-match-prop-types.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,29 @@ ruleTester.run('default-props-match-prop-types', rule, {
783783
column: 3
784784
}]
785785
},
786+
{
787+
code: [
788+
'function MyStatelessComponent({ foo, bar }) {',
789+
' return <div>{foo}{bar}</div>;',
790+
'}',
791+
'const propTypes = {',
792+
' foo: React.PropTypes.string,',
793+
' bar: React.PropTypes.string.isRequired',
794+
'};',
795+
'MyStatelessComponent.propTypes = forbidExtraProps(propTypes);',
796+
'MyStatelessComponent.defaultProps = {',
797+
' baz: "baz"',
798+
'};'
799+
].join('\n'),
800+
settings: {
801+
propWrapperFunctions: ['forbidExtraProps']
802+
},
803+
errors: [{
804+
message: 'defaultProp "baz" has no corresponding propTypes declaration.',
805+
line: 10,
806+
column: 3
807+
}]
808+
},
786809
{
787810
code: [
788811
'function MyStatelessComponent({ foo, bar }) {',

0 commit comments

Comments
 (0)