Skip to content

Commit

Permalink
Correct React.createClass defaultProps
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Sutton committed Feb 24, 2017
1 parent 0a2abc5 commit b36e82d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 0 additions & 4 deletions lib/rules/no-invalid-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,6 @@ module.exports = {
return;
}

if (isDefaultProp && property.value.type === 'ObjectExpression') {
addDefaultPropsToComponent(component, getDefaultPropsFromObjectExpression(property.value));
}

if (isDefaultProp && property.value.type === 'FunctionExpression') {
var returnStatement = utils.findReturnStatement(property);
if (!returnStatement || returnStatement.argument.type !== 'ObjectExpression') {
Expand Down
10 changes: 6 additions & 4 deletions tests/lib/rules/no-invalid-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,15 +887,17 @@ ruleTester.run('no-invalid-default-props', rule, {
' foo: React.PropTypes.string,',
' bar: React.PropTypes.string.isRequired',
' },',
' defaultProps: {',
' baz: "baz"',
' getDefaultProps: function() {',
' return {',
' baz: "baz"',
' };',
' }',
'});'
].join('\n'),
errors: [{
message: 'defaultProp "baz" has no corresponding propTypes declaration.',
line: 10,
column: 5
line: 11,
column: 7
}]
},
{
Expand Down

0 comments on commit b36e82d

Please sign in to comment.