Skip to content

Commit 8be52c7

Browse files
📝 Addresses CR comments
- Uses pragma context instead of 'React' - Adds back spaces I removed which increase readability
1 parent f7e3121 commit 8be52c7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/rules/no-array-index-key.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
const has = require('has');
88
const astUtil = require('../util/ast');
99
const docsUrl = require('../util/docsUrl');
10+
const pragma = require('../util/pragma');
1011

1112
// ------------------------------------------------------------------------------
1213
// Rule Definition
@@ -66,7 +67,7 @@ module.exports = {
6667
if (obj && obj.name === 'Children') {
6768
return true;
6869
}
69-
if (obj && obj.object && obj.object.name === 'React') {
70+
if (obj && obj.object && obj.object.name === pragma.getFromContext(context)) {
7071
return true;
7172
}
7273

@@ -161,20 +162,24 @@ module.exports = {
161162
&& ['createElement', 'cloneElement'].indexOf(node.callee.property.name) !== -1
162163
&& node.arguments.length > 1
163164
) {
165+
// React.createElement
164166
if (!indexParamNames.length) {
165167
return;
166168
}
169+
167170
const props = node.arguments[1];
168171

169172
if (props.type !== 'ObjectExpression') {
170173
return;
171174
}
175+
172176
props.properties.forEach(prop => {
173177
if (!prop.key || prop.key.name !== 'key') {
174178
// { ...foo }
175179
// { foo: bar }
176180
return;
177181
}
182+
178183
checkPropValue(prop.value);
179184
});
180185

0 commit comments

Comments
 (0)