Skip to content

Commit

Permalink
Merge pull request #36 from burnnat/computed-prop-types
Browse files Browse the repository at this point in the history
Fix prop-types to check for computed prop names
  • Loading branch information
yannickcr committed Mar 29, 2015
2 parents 0d7b069 + 3b5cf97 commit 1577129
Show file tree
Hide file tree
Showing 2 changed files with 13 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 @@ -129,7 +129,7 @@ module.exports = function(context) {
function markPropTypesAsUsed(node) {
var component = getComponent(node);
var type;
if (node.parent.property && node.parent.property.name) {
if (node.parent.property && node.parent.property.name && !node.parent.computed) {
type = 'direct';
} else if (
node.parent.parent.declarations &&
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
ecmaFeatures: {
jsx: true
}
}, {
code: [
'var Hello = React.createClass({',
' render: function() {',
' var propName = "foo";',
' return <div>Hello World {this.props[propName]}</div>;',
' }',
'});'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}, {
code: [
'var Hello = React.createClass({',
Expand Down

0 comments on commit 1577129

Please sign in to comment.