@@ -7,15 +7,14 @@ import type { TSESTree } from "@typescript-eslint/types";
77import { AST_NODE_TYPES as T } from "@typescript-eslint/types" ;
88import type { ESLintUtils } from "@typescript-eslint/utils" ;
99
10- import { isChildrenOfCreateElement } from "../element" ;
1110import { isReactHookCall } from "../hook" ;
1211import { DISPLAY_NAME_ASSIGNMENT_SELECTOR } from "../utils" ;
13- import { DEFAULT_COMPONENT_HINT , ERComponentHint } from "./component-collector-hint" ;
12+ import { DEFAULT_COMPONENT_HINT } from "./component-collector-hint" ;
1413import { ERComponentFlag } from "./component-flag" ;
1514import { getFunctionComponentIdentifier } from "./component-id" ;
16- import { isFunctionOfRenderMethod } from "./component-lifecycle" ;
1715import { getComponentNameFromIdentifier , hasNoneOrValidComponentName } from "./component-name" ;
1816import type { ERFunctionComponent } from "./component-semantic-node" ;
17+ import { hasValidHierarchy } from "./hierarchy" ;
1918
2019type FunctionEntry = {
2120 key : string ;
@@ -172,35 +171,6 @@ export function useComponentCollector(
172171 return { ctx, listeners } as const ;
173172}
174173
175- function hasValidHierarchy ( node : AST . TSESTreeFunction , context : RuleContext , hint : bigint ) {
176- if ( isChildrenOfCreateElement ( node , context ) || isFunctionOfRenderMethod ( node ) ) {
177- return false ;
178- }
179- if ( hint & ERComponentHint . SkipMapCallback && AST . isMapCallLoose ( node . parent ) ) {
180- return false ;
181- }
182- if ( hint & ERComponentHint . SkipObjectMethod && AST . isFunctionOfObjectMethod ( node . parent ) ) {
183- return false ;
184- }
185- if ( hint & ERComponentHint . SkipClassMethod && AST . isFunctionOfClassMethod ( node . parent ) ) {
186- return false ;
187- }
188- if ( hint & ERComponentHint . SkipClassProperty && AST . isFunctionOfClassProperty ( node . parent ) ) {
189- return false ;
190- }
191- const boundaryNode = AST . findParentNode (
192- node ,
193- AST . isOneOf ( [
194- T . JSXExpressionContainer ,
195- T . ArrowFunctionExpression ,
196- T . FunctionExpression ,
197- T . Property ,
198- T . ClassBody ,
199- ] ) ,
200- ) ;
201- return boundaryNode == null || boundaryNode . type !== T . JSXExpressionContainer ;
202- }
203-
204174function getComponentFlag ( initPath : ERFunctionComponent [ "initPath" ] ) {
205175 let flag = ERComponentFlag . None ;
206176 if ( initPath != null && AST . hasCallInFunctionInitPath ( "memo" , initPath ) ) {
0 commit comments