Skip to content

Commit

Permalink
pref: improve 'no-duplicate-key' rule to skip processing when no 'key…
Browse files Browse the repository at this point in the history
…=' attribute is present
  • Loading branch information
Rel1cx committed Dec 29, 2024
1 parent ed43e7e commit 33ab3cc
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default createRule<[], MessageID>({
},
name: RULE_NAME,
create(context) {
if (!context.sourceCode.getText().includes("key=")) return {};
const keyedEntries: Map<TSESTree.Node, KeyedEntry> = new Map();
function isKeyValueEqual(
a: TSESTree.JSXAttribute,
Expand All @@ -44,10 +45,7 @@ export default createRule<[], MessageID>({
const aValue = a.value;
const bValue = b.value;
if (aValue === null || bValue === null) return false;
return VAR.isNodeValueEqual(aValue, bValue, [
context.sourceCode.getScope(aValue),
context.sourceCode.getScope(bValue),
]);
return AST.isNodeEqual(aValue, bValue);
}
return {
"JSXAttribute[name.name='key']"(node: TSESTree.JSXAttribute) {
Expand Down

0 comments on commit 33ab3cc

Please sign in to comment.