Skip to content

Commit

Permalink
Fix usage of this.props without property (fixes #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Mar 3, 2015
1 parent 10f66c4 commit 7065e1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function(context) {
return {

'MemberExpression': function(node) {
if (node.object.type !== 'ThisExpression' || node.property.name !== 'props') {
if (node.object.type !== 'ThisExpression' || node.property.name !== 'props' || !node.parent.property) {
return;
}
usedPropTypes.push(node.parent.property.name);
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
ecmaFeatures: {
jsx: true
}
}, {
code: '\
var Hello = React.createClass({\
render: function() {\
var props = this.props;\
return <div>Hello World</div>;\
}\
});',
ecmaFeatures: {
jsx: true
}
}
],

Expand Down

0 comments on commit 7065e1e

Please sign in to comment.