@@ -5,7 +5,56 @@ import * as VAR from "@eslint-react/var";
55import type { Scope } from "@typescript-eslint/scope-manager" ;
66import { AST_NODE_TYPES as T } from "@typescript-eslint/types" ;
77import type { TSESTree } from "@typescript-eslint/utils" ;
8- import { DEFAULT_JSX_DETECTION_HINT , JSXDetectionHint } from "./jsx-detection-hint" ;
8+
9+ // This is a representation of React Node types for reference
10+ // type ReactNode =
11+ // | ReactElement
12+ // | string
13+ // | number
14+ // | Iterable<ReactNode>
15+ // | ReactPortal
16+ // | boolean
17+ // | null
18+ // | undefined
19+ // | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
20+ // keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
21+ // ];
22+
23+ /**
24+ * BitFlags for configuring JSX detection behavior
25+ * Uses BigInt for bit operations to support many flags
26+ */
27+ export type JSXDetectionHint = bigint ;
28+
29+ /* eslint-disable perfectionist/sort-objects */
30+ /**
31+ * Flags to control JSX detection behavior:
32+ * - Skip* flags: Ignore specific node types when detecting JSX
33+ * - Strict* flags: Enforce stricter rules for container types
34+ */
35+ export const JSXDetectionHint = {
36+ None : 0n ,
37+ SkipUndefined : 1n << 0n , // Ignore undefined values
38+ SkipNullLiteral : 1n << 1n , // Ignore null literals
39+ SkipBooleanLiteral : 1n << 2n , // Ignore boolean literals
40+ SkipStringLiteral : 1n << 3n , // Ignore string literals
41+ SkipNumberLiteral : 1n << 4n , // Ignore number literals
42+ SkipBigIntLiteral : 1n << 5n , // Ignore bigint literals
43+ SkipEmptyArray : 1n << 6n , // Ignore empty arrays
44+ SkipCreateElement : 1n << 7n , // Ignore React.createElement calls
45+ StrictArray : 1n << 8n , // Require all array elements to be JSX
46+ StrictLogical : 1n << 9n , // Require both sides of logical expr to be JSX
47+ StrictConditional : 1n << 10n , // Require both branches of conditional to be JSX
48+ } as const ;
49+ /* eslint-enable perfectionist/sort-objects */
50+
51+ /**
52+ * Default JSX detection configuration
53+ * Skips undefined and boolean literals (common in React)
54+ */
55+ export const DEFAULT_JSX_DETECTION_HINT = 0n
56+ | JSXDetectionHint . SkipUndefined
57+ | JSXDetectionHint . SkipBooleanLiteral ;
958
1059/**
1160 * Checks if a node is a `JSXText` or a `Literal` node
0 commit comments