Skip to content

Commit 3b5cf97

Browse files
committed
Check for computed property names in prop-types.
1 parent 0d7b069 commit 3b5cf97

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/rules/prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ module.exports = function(context) {
129129
function markPropTypesAsUsed(node) {
130130
var component = getComponent(node);
131131
var type;
132-
if (node.parent.property && node.parent.property.name) {
132+
if (node.parent.property && node.parent.property.name && !node.parent.computed) {
133133
type = 'direct';
134134
} else if (
135135
node.parent.parent.declarations &&

tests/lib/rules/prop-types.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
8181
ecmaFeatures: {
8282
jsx: true
8383
}
84+
}, {
85+
code: [
86+
'var Hello = React.createClass({',
87+
' render: function() {',
88+
' var propName = "foo";',
89+
' return <div>Hello World {this.props[propName]}</div>;',
90+
' }',
91+
'});'
92+
].join('\n'),
93+
ecmaFeatures: {
94+
jsx: true
95+
}
8496
}, {
8597
code: [
8698
'var Hello = React.createClass({',

0 commit comments

Comments
 (0)