Skip to content

Commit 7065e1e

Browse files
committed
Fix usage of this.props without property (fixes #8)
1 parent 10f66c4 commit 7065e1e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/rules/prop-types.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = function(context) {
3131
return {
3232

3333
'MemberExpression': function(node) {
34-
if (node.object.type !== 'ThisExpression' || node.property.name !== 'props') {
34+
if (node.object.type !== 'ThisExpression' || node.property.name !== 'props' || !node.parent.property) {
3535
return;
3636
}
3737
usedPropTypes.push(node.parent.property.name);

tests/lib/rules/prop-types.js

+11
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
6565
ecmaFeatures: {
6666
jsx: true
6767
}
68+
}, {
69+
code: '\
70+
var Hello = React.createClass({\
71+
render: function() {\
72+
var props = this.props;\
73+
return <div>Hello World</div>;\
74+
}\
75+
});',
76+
ecmaFeatures: {
77+
jsx: true
78+
}
6879
}
6980
],
7081

0 commit comments

Comments
 (0)