Skip to content

Commit 4d6e050

Browse files
committed
Fix prop validation in constructor (fixes #259)
1 parent 77459ec commit 4d6e050

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/rules/prop-types.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,11 @@ module.exports = function(context) {
331331
* @return {string} the name of the property or undefined if not found
332332
*/
333333
function getPropertyName(node) {
334-
if (componentUtil.getNode(context, node) && !inConstructor()) {
335-
if (node.object.name === 'props') {
336-
return void 0;
337-
}
334+
var directProp = /^props\./.test(context.getSource(node));
335+
if (directProp && componentUtil.getNode(context, node) && !inConstructor(node)) {
336+
return void 0;
337+
}
338+
if (!directProp) {
338339
node = node.parent;
339340
}
340341
var property = node.property;

0 commit comments

Comments
 (0)