File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
packages/plugins/eslint-plugin-react-x/src/rules Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 11import * as AST from "@eslint-react/ast" ;
22import { isReactHookCall , useComponentCollector } from "@eslint-react/core" ;
3+ import { getOrUpdate } from "@eslint-react/eff" ;
34import type { RuleFeature } from "@eslint-react/shared" ;
45import * as VAR from "@eslint-react/var" ;
56import type { TSESTree } from "@typescript-eslint/types" ;
@@ -38,7 +39,7 @@ export default createRule<[], MessageID>({
3839 name : RULE_NAME ,
3940 create ( context ) {
4041 const { ctx, listeners } = useComponentCollector ( context ) ;
41- const declarators = new WeakMap <
42+ const declarators = new Map <
4243 AST . TSESTreeFunction ,
4344 ObjectDestructuringDeclarator [ ]
4445 > ( ) ;
@@ -93,8 +94,11 @@ export default createRule<[], MessageID>({
9394 "VariableDeclarator[id.type='ObjectPattern'][init.type='Identifier']" ( node : ObjectDestructuringDeclarator ) {
9495 const functionEntry = ctx . getCurrentEntry ( ) ;
9596 if ( functionEntry == null ) return ;
96- const prevs = declarators . get ( functionEntry . node ) ?? [ ] ;
97- declarators . set ( functionEntry . node , [ ...prevs , node ] ) ;
97+ getOrUpdate (
98+ declarators ,
99+ functionEntry . node ,
100+ ( ) => [ ] ,
101+ ) . push ( node ) ;
98102 } ,
99103 } ;
100104 } ,
You can’t perform that action at this time.
0 commit comments