Skip to content

Commit

Permalink
📝 Addresses CR comments
Browse files Browse the repository at this point in the history
- Uses pragma context instead of 'React'
- Adds back spaces I removed which increase readability
  • Loading branch information
himynameisdave committed Dec 21, 2018
1 parent f7e3121 commit 8be52c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/rules/no-array-index-key.js
Expand Up @@ -7,6 +7,7 @@
const has = require('has');
const astUtil = require('../util/ast');
const docsUrl = require('../util/docsUrl');
const pragma = require('../util/pragma');

// ------------------------------------------------------------------------------
// Rule Definition
Expand Down Expand Up @@ -66,7 +67,7 @@ module.exports = {
if (obj && obj.name === 'Children') {
return true;
}
if (obj && obj.object && obj.object.name === 'React') {
if (obj && obj.object && obj.object.name === pragma.getFromContext(context)) {
return true;
}

Expand Down Expand Up @@ -161,20 +162,24 @@ module.exports = {
&& ['createElement', 'cloneElement'].indexOf(node.callee.property.name) !== -1
&& node.arguments.length > 1
) {
// React.createElement
if (!indexParamNames.length) {
return;
}

const props = node.arguments[1];

if (props.type !== 'ObjectExpression') {
return;
}

props.properties.forEach(prop => {
if (!prop.key || prop.key.name !== 'key') {
// { ...foo }
// { foo: bar }
return;
}

checkPropValue(prop.value);
});

Expand Down

0 comments on commit 8be52c7

Please sign in to comment.