Skip to content

Commit 33ab3cc

Browse files
committed
pref: improve 'no-duplicate-key' rule to skip processing when no 'key=' attribute is present
1 parent ed43e7e commit 33ab3cc

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-key.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default createRule<[], MessageID>({
3636
},
3737
name: RULE_NAME,
3838
create(context) {
39+
if (!context.sourceCode.getText().includes("key=")) return {};
3940
const keyedEntries: Map<TSESTree.Node, KeyedEntry> = new Map();
4041
function isKeyValueEqual(
4142
a: TSESTree.JSXAttribute,
@@ -44,10 +45,7 @@ export default createRule<[], MessageID>({
4445
const aValue = a.value;
4546
const bValue = b.value;
4647
if (aValue === null || bValue === null) return false;
47-
return VAR.isNodeValueEqual(aValue, bValue, [
48-
context.sourceCode.getScope(aValue),
49-
context.sourceCode.getScope(bValue),
50-
]);
48+
return AST.isNodeEqual(aValue, bValue);
5149
}
5250
return {
5351
"JSXAttribute[name.name='key']"(node: TSESTree.JSXAttribute) {

0 commit comments

Comments
 (0)