@@ -9,15 +9,15 @@ import { DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint } from "./jsx-detection-hi
99
1010/**
1111 * Heuristic decision to determine if a node is a JSX-like node.
12+ * @param code The sourceCode object
13+ * @param code.getScope The function to get the scope of a node
1214 * @param node The AST node to check
13- * @param jsxCtx The requirements for the check
14- * @param jsxCtx.getScope The function to get the scope of a node
1515 * @param hint The `JSXDetectionHint` to use
1616 * @returns boolean
1717 */
18- export function isJSXLike (
18+ export function isJsxLike (
19+ code : { getScope : ( node : TSESTree . Node ) => Scope } ,
1920 node : TSESTree . Node | _ | null ,
20- jsxCtx : { getScope : ( node : TSESTree . Node ) => Scope } ,
2121 hint : JSXDetectionHint = DEFAULT_JSX_DETECTION_HINT ,
2222) : boolean {
2323 switch ( node ?. type ) {
@@ -59,15 +59,15 @@ export function isJSXLike(
5959 }
6060 case T . ArrayExpression : {
6161 if ( hint & JSXDetectionHint . StrictArray ) {
62- return node . elements . every ( ( n ) => isJSXLike ( n , jsxCtx , hint ) ) ;
62+ return node . elements . every ( ( n ) => isJsxLike ( code , n , hint ) ) ;
6363 }
64- return node . elements . some ( ( n ) => isJSXLike ( n , jsxCtx , hint ) ) ;
64+ return node . elements . some ( ( n ) => isJsxLike ( code , n , hint ) ) ;
6565 }
6666 case T . LogicalExpression : {
6767 if ( hint & JSXDetectionHint . StrictLogical ) {
68- return isJSXLike ( node . left , jsxCtx , hint ) && isJSXLike ( node . right , jsxCtx , hint ) ;
68+ return isJsxLike ( code , node . left , hint ) && isJsxLike ( code , node . right , hint ) ;
6969 }
70- return isJSXLike ( node . left , jsxCtx , hint ) || isJSXLike ( node . right , jsxCtx , hint ) ;
70+ return isJsxLike ( code , node . left , hint ) || isJsxLike ( code , node . right , hint ) ;
7171 }
7272 case T . ConditionalExpression : {
7373 function leftHasJSX ( node : TSESTree . ConditionalExpression ) {
@@ -76,14 +76,14 @@ export function isJSXLike(
7676 return ! ( hint & JSXDetectionHint . SkipEmptyArray ) ;
7777 }
7878 if ( hint & JSXDetectionHint . StrictArray ) {
79- return node . consequent . every ( ( n : TSESTree . Expression ) => isJSXLike ( n , jsxCtx , hint ) ) ;
79+ return node . consequent . every ( ( n : TSESTree . Expression ) => isJsxLike ( code , n , hint ) ) ;
8080 }
81- return node . consequent . some ( ( n : TSESTree . Expression ) => isJSXLike ( n , jsxCtx , hint ) ) ;
81+ return node . consequent . some ( ( n : TSESTree . Expression ) => isJsxLike ( code , n , hint ) ) ;
8282 }
83- return isJSXLike ( node . consequent , jsxCtx , hint ) ;
83+ return isJsxLike ( code , node . consequent , hint ) ;
8484 }
8585 function rightHasJSX ( node : TSESTree . ConditionalExpression ) {
86- return isJSXLike ( node . alternate , jsxCtx , hint ) ;
86+ return isJsxLike ( code , node . alternate , hint ) ;
8787 }
8888 if ( hint & JSXDetectionHint . StrictConditional ) {
8989 return leftHasJSX ( node ) && rightHasJSX ( node ) ;
@@ -92,7 +92,7 @@ export function isJSXLike(
9292 }
9393 case T . SequenceExpression : {
9494 const exp = node . expressions . at ( - 1 ) ;
95- return isJSXLike ( exp , jsxCtx , hint ) ;
95+ return isJsxLike ( code , exp , hint ) ;
9696 }
9797 case T . CallExpression : {
9898 if ( hint & JSXDetectionHint . SkipCreateElement ) {
@@ -114,11 +114,11 @@ export function isJSXLike(
114114 if ( AST . isJSXTagNameExpression ( node ) ) {
115115 return true ;
116116 }
117- const variable = VAR . findVariable ( name , jsxCtx . getScope ( node ) ) ;
117+ const variable = VAR . findVariable ( name , code . getScope ( node ) ) ;
118118 const variableNode = variable
119119 && VAR . getVariableInitNode ( variable , 0 ) ;
120120 return ! ! variableNode
121- && isJSXLike ( variableNode , jsxCtx , hint ) ;
121+ && isJsxLike ( code , variableNode , hint ) ;
122122 }
123123 }
124124 return false ;
0 commit comments