Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Sutton committed Feb 24, 2017
1 parent b36e82d commit 3118f4d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/rules/no-invalid-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ module.exports = {
* @returns {Boolean} `true` if the node is a defaultProps declaration, `false` if not
*/
function isDefaultPropsDeclaration(node) {
return (getPropertyName(node) === 'defaultProps' || getPropertyName(node) === 'getDefaultProps');
var propName = getPropertyName(node);
return (propName === 'defaultProps' || propName === 'getDefaultProps');
}

/**
Expand Down Expand Up @@ -424,7 +425,8 @@ module.exports = {

// e.g.:
// MyComponent.propTypes.baz = React.PropTypes.string;
if (node.parent.type === 'MemberExpression' && node.parent.parent.type === 'AssignmentExpression') {
if (node.parent.type === 'MemberExpression' && node.parent.parent &&
node.parent.parent.type === 'AssignmentExpression') {

if (isPropType) {
addPropTypesToComponent(component, [{
Expand Down Expand Up @@ -520,8 +522,9 @@ module.exports = {
return;
}

var isPropType = getPropertyName(node) === 'propTypes';
var isDefaultProp = getPropertyName(node) === 'defaultProps' || getPropertyName(node) === 'getDefaultProps';
var propName = getPropertyName(node);
var isPropType = propName === 'propTypes';
var isDefaultProp = propName === 'defaultProps' || propName === 'getDefaultProps';

if (!isPropType && !isDefaultProp) {
return;
Expand Down

0 comments on commit 3118f4d

Please sign in to comment.