Skip to content

Commit

Permalink
pref: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Rel1cx committed Feb 2, 2025
1 parent 169ebaf commit ff465b6
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as AST from "@eslint-react/ast";
import { isReactHookCall, useComponentCollector } from "@eslint-react/core";
import { getOrUpdate } from "@eslint-react/eff";
import type { RuleFeature } from "@eslint-react/shared";
import * as VAR from "@eslint-react/var";
import type { TSESTree } from "@typescript-eslint/types";
Expand Down Expand Up @@ -38,7 +39,7 @@ export default createRule<[], MessageID>({
name: RULE_NAME,
create(context) {
const { ctx, listeners } = useComponentCollector(context);
const declarators = new WeakMap<
const declarators = new Map<
AST.TSESTreeFunction,
ObjectDestructuringDeclarator[]
>();
Expand Down Expand Up @@ -93,8 +94,11 @@ export default createRule<[], MessageID>({
"VariableDeclarator[id.type='ObjectPattern'][init.type='Identifier']"(node: ObjectDestructuringDeclarator) {
const functionEntry = ctx.getCurrentEntry();
if (functionEntry == null) return;
const prevs = declarators.get(functionEntry.node) ?? [];
declarators.set(functionEntry.node, [...prevs, node]);
getOrUpdate(
declarators,
functionEntry.node,
() => [],
).push(node);
},
};
},
Expand Down

0 comments on commit ff465b6

Please sign in to comment.