11import * as AST from "@eslint-react/ast" ;
22import { unit } from "@eslint-react/eff" ;
33import { type RuleContext } from "@eslint-react/shared" ;
4- import { getId } from "@eslint-react/shared" ;
4+ import { IdGenerator } from "@eslint-react/shared" ;
55import type { TSESTree } from "@typescript-eslint/types" ;
66import { AST_NODE_TYPES as T } from "@typescript-eslint/types" ;
77import type { ESLintUtils } from "@typescript-eslint/utils" ;
@@ -16,6 +16,8 @@ import { getFunctionComponentId } from "./component-id";
1616import { getComponentFlagFromInitPath } from "./component-init-path" ;
1717import { getComponentNameFromId , hasNoneOrLooseComponentName } from "./component-name" ;
1818
19+ const idGen = new IdGenerator ( "function_component_" ) ;
20+
1921type FunctionEntry = {
2022 key : string ;
2123 node : AST . TSESTreeFunction ;
@@ -60,7 +62,7 @@ export function useComponentCollector(
6062
6163 const getCurrentEntry = ( ) => functionEntries . at ( - 1 ) ;
6264 const onFunctionEnter = ( node : AST . TSESTreeFunction ) => {
63- const key = getId ( ) ;
65+ const key = idGen . next ( ) ;
6466 functionEntries . push ( { key, node, hookCalls : [ ] , isComponent : false } ) ;
6567 } ;
6668 const onFunctionExit = ( ) => {
@@ -106,8 +108,8 @@ export function useComponentCollector(
106108 if ( ! isComponent ) return ;
107109 const initPath = AST . getFunctionInitPath ( entry . node ) ;
108110 const id = getFunctionComponentId ( context , entry . node ) ;
111+ const key = entry . key ;
109112 const name = getComponentNameFromId ( id ) ;
110- const key = getId ( ) ;
111113 components . set ( key , {
112114 id,
113115 key,
0 commit comments