1- import * as AST from "@eslint-react/ast" ;
1+ import * as ast from "@eslint-react/ast" ;
22import type { RuleContext } from "@eslint-react/shared" ;
3- import { AST_NODE_TYPES as T , type TSESTree } from "@typescript-eslint/types" ;
3+ import { AST_NODE_TYPES as AST , type TSESTree } from "@typescript-eslint/types" ;
44
55import { isCreateElementCall } from "../api" ;
66import { ComponentDetectionHint } from "./component-detection-hint" ;
@@ -21,7 +21,7 @@ import { isRenderMethodLike } from "./component-render-method";
2121 * }
2222 * ```
2323 */
24- function isRenderMethodCallback ( node : AST . TSESTreeFunction ) {
24+ function isRenderMethodCallback ( node : ast . TSESTreeFunction ) {
2525 const parent = node . parent ;
2626 const grandparent = parent . parent ;
2727 const greatGrandparent = grandparent ?. parent ;
@@ -40,31 +40,31 @@ function isRenderMethodCallback(node: AST.TSESTreeFunction) {
4040 * @param hint Component detection hints as bit flags
4141 * @returns `true` if the function matches an exclusion hint
4242 */
43- function shouldExcludeBasedOnHint ( node : AST . TSESTreeFunction , hint : bigint ) : boolean {
43+ function shouldExcludeBasedOnHint ( node : ast . TSESTreeFunction , hint : bigint ) : boolean {
4444 switch ( true ) {
4545 case ( hint & ComponentDetectionHint . SkipObjectMethod )
46- && AST . isOneOf ( [ T . ArrowFunctionExpression , T . FunctionExpression ] ) ( node )
47- && node . parent . type === T . Property
48- && node . parent . parent . type === T . ObjectExpression :
46+ && ast . isOneOf ( [ AST . ArrowFunctionExpression , AST . FunctionExpression ] ) ( node )
47+ && node . parent . type === AST . Property
48+ && node . parent . parent . type === AST . ObjectExpression :
4949 return true ;
5050 case ( hint & ComponentDetectionHint . SkipClassMethod )
51- && AST . isOneOf ( [ T . ArrowFunctionExpression , T . FunctionExpression ] ) ( node )
52- && node . parent . type === T . MethodDefinition :
51+ && ast . isOneOf ( [ AST . ArrowFunctionExpression , AST . FunctionExpression ] ) ( node )
52+ && node . parent . type === AST . MethodDefinition :
5353 return true ;
5454 case ( hint & ComponentDetectionHint . SkipClassProperty )
55- && AST . isOneOf ( [ T . ArrowFunctionExpression , T . FunctionExpression ] ) ( node )
56- && node . parent . type === T . Property :
55+ && ast . isOneOf ( [ AST . ArrowFunctionExpression , AST . FunctionExpression ] ) ( node )
56+ && node . parent . type === AST . Property :
5757 return true ;
5858 case ( hint & ComponentDetectionHint . SkipArrayPattern )
59- && node . parent . type === T . ArrayPattern :
59+ && node . parent . type === AST . ArrayPattern :
6060 return true ;
6161 case ( hint & ComponentDetectionHint . SkipArrayExpression )
62- && node . parent . type === T . ArrayExpression :
62+ && node . parent . type === AST . ArrayExpression :
6363 return true ;
6464 case ( hint & ComponentDetectionHint . SkipArrayMapCallback )
65- && node . parent . type === T . CallExpression
66- && node . parent . callee . type === T . MemberExpression
67- && node . parent . callee . property . type === T . Identifier
65+ && node . parent . type === AST . CallExpression
66+ && node . parent . callee . type === AST . MemberExpression
67+ && node . parent . callee . property . type === AST . Identifier
6868 && node . parent . callee . property . name === "map" :
6969 return true ;
7070 }
@@ -81,7 +81,7 @@ function shouldExcludeBasedOnHint(node: AST.TSESTreeFunction, hint: bigint): boo
8181function isChildrenOfCreateElement ( context : RuleContext , node : TSESTree . Node ) : boolean {
8282 const parent = node . parent ;
8383
84- if ( parent ?. type !== T . CallExpression ) {
84+ if ( parent ?. type !== AST . CallExpression ) {
8585 return false ;
8686 }
8787
@@ -105,7 +105,7 @@ function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): b
105105 */
106106export function isComponentDefinition (
107107 context : RuleContext ,
108- node : AST . TSESTreeFunction ,
108+ node : ast . TSESTreeFunction ,
109109 hint : bigint ,
110110) {
111111 // 1. Check for basic naming conventions
@@ -125,19 +125,19 @@ export function isComponentDefinition(
125125
126126 // 4. Check if the function is embedded directly inside JSX (e.g., inline callbacks)
127127 // We look for the closest parent that is significant (Function, Class, or JSXContainer)
128- const significantParent = AST . findParentNode (
128+ const significantParent = ast . findParentNode (
129129 node ,
130- AST . isOneOf ( [
131- T . JSXExpressionContainer ,
132- T . ArrowFunctionExpression ,
133- T . FunctionExpression ,
134- T . Property ,
135- T . ClassBody ,
130+ ast . isOneOf ( [
131+ AST . JSXExpressionContainer ,
132+ AST . ArrowFunctionExpression ,
133+ AST . FunctionExpression ,
134+ AST . Property ,
135+ AST . ClassBody ,
136136 ] ) ,
137137 ) ;
138138
139139 if ( significantParent == null ) return true ;
140140 // If the immediate significant parent is a JSX expression, this is likely an event handler or a render prop, not a component definition itself
141- if ( significantParent . type === T . JSXExpressionContainer ) return false ;
141+ if ( significantParent . type === AST . JSXExpressionContainer ) return false ;
142142 return true ;
143143}
0 commit comments