@eslint-react/ast 1.23.2-next.2 → 1.23.2-next.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,32 +1,63 @@
1
1
  import { O } from '@eslint-react/eff';
2
- import { TSESTree as TSESTree$1, AST_NODE_TYPES as AST_NODE_TYPES$2 } from '@typescript-eslint/types';
3
- import { TSESTree } from '@typescript-eslint/utils';
2
+ import { TSESTree, AST_NODE_TYPES as AST_NODE_TYPES$2 } from '@typescript-eslint/types';
3
+ import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
4
4
  import { SyntaxKind } from 'typescript';
5
5
  import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from '@typescript-eslint/typescript-estree';
6
6
  import * as effect_Predicate from 'effect/Predicate';
7
7
 
8
- type TSESTreeFunction = TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression;
9
- type TSESTreeFunctionType = TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSDeclareFunction | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignature | TSESTreeFunction;
10
- type TSESTreeClass = TSESTree.ClassDeclaration | TSESTree.ClassExpression;
11
- type TSESTreeLoop = TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
12
- type TSESTreeArrayTupleType = TSESTree.TSArrayType | TSESTree.TSTupleType;
13
- type TSESTreeProperty = TSESTree.PropertyDefinition | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignature;
14
- type TSESTreeJSX = TSESTree.JSXAttribute | TSESTree.JSXChild | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXElement | TSESTree.JSXEmptyExpression | TSESTree.JSXExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXFragment | TSESTree.JSXIdentifier | TSESTree.JSXIdentifierToken | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXTagNameExpression | TSESTree.JSXText | TSESTree.JSXTextToken;
15
- type TSESTreeDestructuringPattern = TSESTree.ArrayPattern | TSESTree.AssignmentPattern | TSESTree.ObjectPattern | TSESTree.RestElement;
16
- type TSESTreeTypeDeclaration = TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration;
8
+ /**
9
+ * Find the first parent node that satisfies the test
10
+ * @param node The node to start searching
11
+ * @param test The test function
12
+ * @returns The first parent node that satisfies the test
13
+ */
14
+ declare const findParentNode: {
15
+ (node: TSESTree.Node, test: (node: TSESTree.Node) => boolean): O.Option<TSESTree.Node>;
16
+ (test: (node: TSESTree.Node) => boolean): (node: TSESTree.Node) => O.Option<TSESTree.Node>;
17
+ };
18
+
19
+ /**
20
+ * Find the first parent node that satisfies the test
21
+ * @param node The node to start searching
22
+ * @param predicate The type guard function
23
+ * @returns The first parent node that satisfies the test
24
+ */
25
+ declare const findParentNodeGuard: {
26
+ <T extends TSESTree.Node>(node: TSESTree.Node, predicate: (node: TSESTree.Node) => node is T): O.Option<T>;
27
+ <T extends TSESTree.Node>(predicate: (node: TSESTree.Node) => node is T): (node: TSESTree.Node) => O.Option<T>;
28
+ };
29
+
30
+ /**
31
+ * Find the first parent node that satisfies the test and stops at the stop node
32
+ * @param node The node to start searching
33
+ * @param stopNode The node to stop searching
34
+ * @param predicate The test function
35
+ * @returns The first parent node that satisfies the test
36
+ */
37
+ declare function findParentNodeStop(node: TSESTree.Node, stopNode: TSESTree.Node, predicate: (node: TSESTree.Node) => boolean): O.Option<TSESTree.Node>;
38
+
39
+ type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
40
+ type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
41
+ type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
42
+ type TSESTreeLoop = TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TSESTree$1.ForOfStatement | TSESTree$1.ForStatement | TSESTree$1.WhileStatement;
43
+ type TSESTreeArrayTupleType = TSESTree$1.TSArrayType | TSESTree$1.TSTupleType;
44
+ type TSESTreeProperty = TSESTree$1.PropertyDefinition | TSESTree$1.TSIndexSignature | TSESTree$1.TSParameterProperty | TSESTree$1.TSPropertySignature;
45
+ type TSESTreeJSX = TSESTree$1.JSXAttribute | TSESTree$1.JSXChild | TSESTree$1.JSXClosingElement | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXElement | TSESTree$1.JSXEmptyExpression | TSESTree$1.JSXExpression | TSESTree$1.JSXExpressionContainer | TSESTree$1.JSXFragment | TSESTree$1.JSXIdentifier | TSESTree$1.JSXIdentifierToken | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXSpreadAttribute | TSESTree$1.JSXSpreadChild | TSESTree$1.JSXTagNameExpression | TSESTree$1.JSXText | TSESTree$1.JSXTextToken;
46
+ type TSESTreeDestructuringPattern = TSESTree$1.ArrayPattern | TSESTree$1.AssignmentPattern | TSESTree$1.ObjectPattern | TSESTree$1.RestElement;
47
+ type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
17
48
 
18
49
  type FunctionInitPath =
19
50
  /**
20
51
  * function Comp() { return <div />; }
21
52
  */
22
- readonly [TSESTree$1.FunctionDeclaration]
53
+ readonly [TSESTree.FunctionDeclaration]
23
54
  /**
24
55
  * const Comp = () => <div />;
25
56
  * const Comp = function () { return <div />; };
26
57
  */
27
58
  | readonly [
28
- TSESTree$1.VariableDeclaration,
29
- TSESTree$1.VariableDeclarator,
59
+ TSESTree.VariableDeclaration,
60
+ TSESTree.VariableDeclarator,
30
61
  TSESTreeFunction
31
62
  ]
32
63
  /**
@@ -34,19 +65,19 @@ readonly [TSESTree$1.FunctionDeclaration]
34
65
  * const Comp = React.forwardRef(() => <div />);
35
66
  */
36
67
  | readonly [
37
- TSESTree$1.VariableDeclaration,
38
- TSESTree$1.VariableDeclarator,
39
- TSESTree$1.CallExpression,
68
+ TSESTree.VariableDeclaration,
69
+ TSESTree.VariableDeclarator,
70
+ TSESTree.CallExpression,
40
71
  TSESTreeFunction
41
72
  ]
42
73
  /**
43
74
  * const Comp = React.memo(React.forwardRef(() => <div />));
44
75
  */
45
76
  | readonly [
46
- TSESTree$1.VariableDeclaration,
47
- TSESTree$1.VariableDeclarator,
48
- TSESTree$1.CallExpression,
49
- TSESTree$1.CallExpression,
77
+ TSESTree.VariableDeclaration,
78
+ TSESTree.VariableDeclarator,
79
+ TSESTree.CallExpression,
80
+ TSESTree.CallExpression,
50
81
  TSESTreeFunction
51
82
  ]
52
83
  /**
@@ -56,10 +87,10 @@ readonly [TSESTree$1.FunctionDeclaration]
56
87
  * }
57
88
  */
58
89
  | readonly [
59
- TSESTree$1.VariableDeclaration,
60
- TSESTree$1.VariableDeclarator,
61
- TSESTree$1.ObjectExpression,
62
- TSESTree$1.Property,
90
+ TSESTree.VariableDeclaration,
91
+ TSESTree.VariableDeclarator,
92
+ TSESTree.ObjectExpression,
93
+ TSESTree.Property,
63
94
  TSESTreeFunction
64
95
  ]
65
96
  /**
@@ -69,11 +100,11 @@ readonly [TSESTree$1.FunctionDeclaration]
69
100
  * }
70
101
  */
71
102
  | readonly [
72
- TSESTree$1.VariableDeclaration,
73
- TSESTree$1.VariableDeclarator,
74
- TSESTree$1.ObjectExpression,
75
- TSESTree$1.Property,
76
- TSESTree$1.CallExpression,
103
+ TSESTree.VariableDeclaration,
104
+ TSESTree.VariableDeclarator,
105
+ TSESTree.ObjectExpression,
106
+ TSESTree.Property,
107
+ TSESTree.CallExpression,
77
108
  TSESTreeFunction
78
109
  ]
79
110
  /**
@@ -83,12 +114,12 @@ readonly [TSESTree$1.FunctionDeclaration]
83
114
  * }
84
115
  */
85
116
  | readonly [
86
- TSESTree$1.VariableDeclaration,
87
- TSESTree$1.VariableDeclarator,
88
- TSESTree$1.ObjectExpression,
89
- TSESTree$1.Property,
90
- TSESTree$1.CallExpression,
91
- TSESTree$1.CallExpression,
117
+ TSESTree.VariableDeclaration,
118
+ TSESTree.VariableDeclarator,
119
+ TSESTree.ObjectExpression,
120
+ TSESTree.Property,
121
+ TSESTree.CallExpression,
122
+ TSESTree.CallExpression,
92
123
  TSESTreeFunction
93
124
  ]
94
125
  /**
@@ -97,9 +128,9 @@ readonly [TSESTree$1.FunctionDeclaration]
97
128
  * }
98
129
  */
99
130
  | readonly [
100
- TSESTree$1.ClassDeclaration,
101
- TSESTree$1.ClassBody,
102
- TSESTree$1.MethodDefinition,
131
+ TSESTree.ClassDeclaration,
132
+ TSESTree.ClassBody,
133
+ TSESTree.MethodDefinition,
103
134
  TSESTreeFunction
104
135
  ]
105
136
  /**
@@ -108,9 +139,9 @@ readonly [TSESTree$1.FunctionDeclaration]
108
139
  * }
109
140
  */
110
141
  | readonly [
111
- TSESTree$1.ClassDeclaration,
112
- TSESTree$1.ClassBody,
113
- TSESTree$1.PropertyDefinition,
142
+ TSESTree.ClassDeclaration,
143
+ TSESTree.ClassBody,
144
+ TSESTree.PropertyDefinition,
114
145
  TSESTreeFunction
115
146
  ];
116
147
  declare function getFunctionInitPath(node: TSESTreeFunction): O.Option<FunctionInitPath>;
@@ -121,7 +152,7 @@ declare function hasCallInFunctionInitPath(callName: string): (initPath: O.Optio
121
152
  * @param node The AST node to check
122
153
  * @returns class identifier or null
123
154
  */
124
- declare function getClassIdentifier(node: TSESTreeClass): O.Option<TSESTree$1.Identifier>;
155
+ declare function getClassIdentifier(node: TSESTreeClass): O.Option<TSESTree.Identifier>;
125
156
 
126
157
  /**
127
158
  * Gets the static name of a function AST node. For function declarations it is
@@ -131,9 +162,9 @@ declare function getClassIdentifier(node: TSESTreeClass): O.Option<TSESTree$1.Id
131
162
  * same AST nodes with some exceptions to better fit our use case.
132
163
  */
133
164
 
134
- declare function getFunctionIdentifier(node: TSESTree$1.Expression | TSESTreeFunction): O.Option<TSESTree$1.Identifier>;
165
+ declare function getFunctionIdentifier(node: TSESTree.Expression | TSESTreeFunction): O.Option<TSESTree.Identifier>;
135
166
 
136
- declare function getIdentifiersFromBinaryExpression(side: TSESTree$1.BinaryExpression | TSESTree$1.BinaryExpression["left"] | TSESTree$1.BinaryExpression["right"]): TSESTree$1.Identifier[];
167
+ declare function getIdentifiersFromBinaryExpression(side: TSESTree.BinaryExpression | TSESTree.BinaryExpression["left"] | TSESTree.BinaryExpression["right"]): TSESTree.Identifier[];
137
168
 
138
169
  declare function getLiteralValueType(input: bigint | boolean | null | number | string | symbol): "Null" | "Boolean" | "Number" | "String" | "BigInt" | "Symbol";
139
170
 
@@ -2292,8 +2323,8 @@ declare const getNestedCallExpressions: (node: Node) => CallExpression[];
2292
2323
  * @returns A partially applied function bound to a predicate of type T. The returned function can be called passing a
2293
2324
  * node, and it will return an array of all nested expressions of type T.
2294
2325
  */
2295
- declare function getNestedExpressionsOfType<T extends AST_NODE_TYPES$1>(type: T): (node: TSESTree$1.Node) => Extract<TSESTree$1.Node, {
2296
- type: T;
2326
+ declare function getNestedExpressionsOfType<TNodeType extends AST_NODE_TYPES$1>(type: TNodeType): (node: TSESTree.Node) => Extract<TSESTree.Node, {
2327
+ type: TNodeType;
2297
2328
  }>[];
2298
2329
 
2299
2330
  /**
@@ -2301,7 +2332,7 @@ declare function getNestedExpressionsOfType<T extends AST_NODE_TYPES$1>(type: T)
2301
2332
  * @param node The node to get the nested identifiers from
2302
2333
  * @returns All nested identifiers
2303
2334
  */
2304
- declare function getNestedIdentifiers(node: TSESTree$1.Node): readonly TSESTree$1.Identifier[];
2335
+ declare function getNestedIdentifiers(node: TSESTree.Node): readonly TSESTree.Identifier[];
2305
2336
 
2306
2337
  /**
2307
2338
  * Get all nested new expressions in an expression like node
@@ -2315,33 +2346,33 @@ declare const getNestedNewExpressions: (node: Node) => NewExpression[];
2315
2346
  * @param node The AST node
2316
2347
  * @returns The nested return statements in the node
2317
2348
  */
2318
- declare function getNestedReturnStatements(node: TSESTree$1.Node): readonly TSESTree$1.ReturnStatement[];
2349
+ declare function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTree.ReturnStatement[];
2319
2350
 
2320
- declare function getTopLevelIdentifier(node: TSESTree$1.Node): O.Option<TSESTree$1.Identifier>;
2351
+ declare function getTopLevelIdentifier(node: TSESTree.Node): O.Option<TSESTree.Identifier>;
2321
2352
 
2322
- declare const is: <NodeType extends AST_NODE_TYPES$2>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
2353
+ declare const is: <NodeType extends AST_NODE_TYPES$2>(nodeType: NodeType) => (node: TSESTree$1.Node | null | undefined) => node is Extract<TSESTree$1.Node, {
2323
2354
  type: NodeType;
2324
2355
  }>;
2325
- declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES$2[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
2356
+ declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES$2[]>(nodeTypes: NodeTypes) => (node: TSESTree$1.Node | null | undefined) => node is Extract<TSESTree$1.Node, {
2326
2357
  type: NodeTypes[number];
2327
2358
  }>;
2328
- declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
2329
- declare const isFunctionType: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression | TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSDeclareFunctionNoDeclare | TSESTree.TSDeclareFunctionWithDeclare | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignatureComputedName | TSESTree.TSMethodSignatureNonComputedName;
2330
- declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
2331
- declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
2332
- declare const isControlFlow: effect_Predicate.Refinement<TSESTree.Node | null | undefined, TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement | TSESTree.IfStatement | TSESTree.SwitchStatement>;
2333
- declare const isConditional: effect_Predicate.Refinement<TSESTree.Node | null | undefined, TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement | TSESTree.ConditionalExpression | TSESTree.IfStatement | TSESTree.LogicalExpression | TSESTree.SwitchStatement>;
2334
- declare const isArrayTupleType: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSArrayType | TSESTree.TSTupleType;
2335
- declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
2336
- declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
2337
- declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
2338
- declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXAttribute | TSESTree.JSXElement | TSESTree.JSXExpressionContainer | TSESTree.JSXSpreadChild | TSESTree.JSXFragment | TSESTree.JSXText | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXEmptyExpression | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute;
2339
- declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
2340
- declare const isDestructuringPattern: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrayPattern | TSESTree.AssignmentPattern | TSESTree.ObjectPattern | TSESTree.RestElement;
2341
- declare const isTypeDeclaration: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration;
2342
- declare const isLeftHandSideExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.ClassExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.ArrayPattern | TSESTree.ObjectPattern | TSESTree.CallExpression | TSESTree.ObjectExpression | TSESTree.ArrayExpression | TSESTree.Identifier | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression;
2343
- declare const isLeftHandSideExpressionType: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.ClassExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.ArrayPattern | TSESTree.ObjectPattern | TSESTree.CallExpression | TSESTree.ObjectExpression | TSESTree.ArrayExpression | TSESTree.Identifier | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSTypeAssertion;
2344
- declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
2359
+ declare const isFunction: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclarationWithName | TSESTree$1.FunctionDeclarationWithOptionalName | TSESTree$1.FunctionExpression;
2360
+ declare const isFunctionType: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclarationWithName | TSESTree$1.FunctionDeclarationWithOptionalName | TSESTree$1.FunctionExpression | TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunctionNoDeclare | TSESTree$1.TSDeclareFunctionWithDeclare | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignatureComputedName | TSESTree$1.TSMethodSignatureNonComputedName;
2361
+ declare const isClass: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ClassDeclarationWithName | TSESTree$1.ClassDeclarationWithOptionalName | TSESTree$1.ClassExpression;
2362
+ declare const isLoop: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TSESTree$1.ForOfStatement | TSESTree$1.ForStatement | TSESTree$1.WhileStatement;
2363
+ declare const isControlFlow: effect_Predicate.Refinement<TSESTree$1.Node | null | undefined, TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TSESTree$1.ForOfStatement | TSESTree$1.ForStatement | TSESTree$1.IfStatement | TSESTree$1.SwitchStatement | TSESTree$1.WhileStatement>;
2364
+ declare const isConditional: effect_Predicate.Refinement<TSESTree$1.Node | null | undefined, TSESTree$1.ConditionalExpression | TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TSESTree$1.ForOfStatement | TSESTree$1.ForStatement | TSESTree$1.IfStatement | TSESTree$1.LogicalExpression | TSESTree$1.SwitchStatement | TSESTree$1.WhileStatement>;
2365
+ declare const isArrayTupleType: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSArrayType | TSESTree$1.TSTupleType;
2366
+ declare const isProperty: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.PropertyDefinitionComputedName | TSESTree$1.PropertyDefinitionNonComputedName | TSESTree$1.TSIndexSignature | TSESTree$1.TSParameterProperty | TSESTree$1.TSPropertySignatureComputedName | TSESTree$1.TSPropertySignatureNonComputedName;
2367
+ declare const isJSXElement: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.JSXElement;
2368
+ declare const isJSXFragment: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.JSXFragment;
2369
+ declare const isJSX: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.JSXAttribute | TSESTree$1.JSXClosingElement | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXElement | TSESTree$1.JSXEmptyExpression | TSESTree$1.JSXExpressionContainer | TSESTree$1.JSXFragment | TSESTree$1.JSXIdentifier | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXSpreadAttribute | TSESTree$1.JSXSpreadChild | TSESTree$1.JSXText;
2370
+ declare const isJSXTagNameExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.JSXIdentifier | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName;
2371
+ declare const isDestructuringPattern: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrayPattern | TSESTree$1.AssignmentPattern | TSESTree$1.ObjectPattern | TSESTree$1.RestElement;
2372
+ declare const isTypeDeclaration: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
2373
+ declare const isLeftHandSideExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrayExpression | TSESTree$1.ArrayPattern | TSESTree$1.ArrowFunctionExpression | TSESTree$1.CallExpression | TSESTree$1.ClassExpression | TSESTree$1.FunctionExpression | TSESTree$1.Identifier | TSESTree$1.JSXElement | TSESTree$1.JSXFragment | TSESTree$1.BigIntLiteral | TSESTree$1.BooleanLiteral | TSESTree$1.NullLiteral | TSESTree$1.NumberLiteral | TSESTree$1.RegExpLiteral | TSESTree$1.StringLiteral | TSESTree$1.MemberExpressionComputedName | TSESTree$1.MemberExpressionNonComputedName | TSESTree$1.MetaProperty | TSESTree$1.ObjectExpression | TSESTree$1.ObjectPattern | TSESTree$1.SequenceExpression | TSESTree$1.Super | TSESTree$1.TaggedTemplateExpression | TSESTree$1.TemplateLiteral | TSESTree$1.ThisExpression;
2374
+ declare const isLeftHandSideExpressionType: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrayExpression | TSESTree$1.ArrayPattern | TSESTree$1.ArrowFunctionExpression | TSESTree$1.CallExpression | TSESTree$1.ClassExpression | TSESTree$1.FunctionExpression | TSESTree$1.Identifier | TSESTree$1.JSXElement | TSESTree$1.JSXFragment | TSESTree$1.BigIntLiteral | TSESTree$1.BooleanLiteral | TSESTree$1.NullLiteral | TSESTree$1.NumberLiteral | TSESTree$1.RegExpLiteral | TSESTree$1.StringLiteral | TSESTree$1.MemberExpressionComputedName | TSESTree$1.MemberExpressionNonComputedName | TSESTree$1.MetaProperty | TSESTree$1.ObjectExpression | TSESTree$1.ObjectPattern | TSESTree$1.SequenceExpression | TSESTree$1.Super | TSESTree$1.TaggedTemplateExpression | TSESTree$1.TemplateLiteral | TSESTree$1.ThisExpression | TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSTypeAssertion;
2375
+ declare const isTypeExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
2345
2376
 
2346
2377
  declare function isEmptyFunction(node: TSESTreeFunction): boolean;
2347
2378
 
@@ -2350,14 +2381,14 @@ declare function isEmptyFunction(node: TSESTreeFunction): boolean;
2350
2381
  * @param node The node to check.
2351
2382
  * @returns `true` if the node is a function expression or arrow function expression of a class method, `false` otherwise.
2352
2383
  */
2353
- declare const isFunctionOfClassMethod: (node: TSESTree$1.Node) => boolean;
2384
+ declare const isFunctionOfClassMethod: (node: TSESTree.Node) => boolean;
2354
2385
 
2355
2386
  /**
2356
2387
  * Checks if the given node is a function expression or arrow function expression of a class property.
2357
2388
  * @param node The node to check.
2358
2389
  * @returns `true` if the node is a function expression or arrow function expression of a class property, `false` otherwise.
2359
2390
  */
2360
- declare const isFunctionOfClassProperty: (node: TSESTree$1.Node) => boolean;
2391
+ declare const isFunctionOfClassProperty: (node: TSESTree.Node) => boolean;
2361
2392
 
2362
2393
  declare function isFunctionOfImmediatelyInvoked(node: TSESTreeFunction): boolean;
2363
2394
 
@@ -2366,18 +2397,18 @@ declare function isFunctionOfImmediatelyInvoked(node: TSESTreeFunction): boolean
2366
2397
  * @param node The node to check.
2367
2398
  * @returns `true` if the node is a function expression or arrow function expression of a object method, `false` otherwise.
2368
2399
  */
2369
- declare const isFunctionOfObjectMethod: (node: TSESTree$1.Node) => boolean;
2400
+ declare const isFunctionOfObjectMethod: (node: TSESTree.Node) => boolean;
2370
2401
 
2371
- declare function isKeyLiteralLike(node: TSESTree$1.MemberExpression | TSESTree$1.MethodDefinition | TSESTree$1.Property | TSESTree$1.PropertyDefinition, property: TSESTree$1.Node): boolean;
2402
+ declare function isKeyLiteralLike(node: TSESTree.MemberExpression | TSESTree.MethodDefinition | TSESTree.Property | TSESTree.PropertyDefinition, property: TSESTree.Node): boolean;
2372
2403
 
2373
- declare function isMapCallLoose(node: TSESTree$1.Node): node is TSESTree$1.CallExpression;
2404
+ declare function isMapCallLoose(node: TSESTree.Node): node is TSESTree.CallExpression;
2374
2405
 
2375
2406
  /**
2376
2407
  * Check if a node is multiline
2377
2408
  * @param node The AST node to check
2378
2409
  * @returns `true` if the node is multiline
2379
2410
  */
2380
- declare function isMultiLine(node: TSESTree$1.Node): boolean;
2411
+ declare function isMultiLine(node: TSESTree.Node): boolean;
2381
2412
 
2382
2413
  /**
2383
2414
  * Determines whether node equals to another node
@@ -2387,15 +2418,15 @@ declare function isMultiLine(node: TSESTree$1.Node): boolean;
2387
2418
  * @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
2388
2419
  */
2389
2420
  declare const isNodeEqual: {
2390
- (a: TSESTree$1.Node): (b: TSESTree$1.Node) => boolean;
2391
- (a: TSESTree$1.Node, b: TSESTree$1.Node): boolean;
2421
+ (a: TSESTree.Node): (b: TSESTree.Node) => boolean;
2422
+ (a: TSESTree.Node, b: TSESTree.Node): boolean;
2392
2423
  };
2393
2424
 
2394
- declare function isRegExpLiteral(node: TSESTree$1.Node): node is TSESTree$1.RegExpLiteral;
2425
+ declare function isRegExpLiteral(node: TSESTree.Node): node is TSESTree.RegExpLiteral;
2395
2426
 
2396
- declare function isStringLiteral(node: TSESTree$1.Node): node is TSESTree$1.StringLiteral;
2427
+ declare function isStringLiteral(node: TSESTree.Node): node is TSESTree.StringLiteral;
2397
2428
 
2398
- declare function isThisExpression(node: TSESTree$1.Expression): boolean;
2429
+ declare function isThisExpression(node: TSESTree.Expression): boolean;
2399
2430
 
2400
2431
  /**
2401
2432
  * Returns human readable node name for given AST node
@@ -2403,48 +2434,16 @@ declare function isThisExpression(node: TSESTree$1.Expression): boolean;
2403
2434
  * @param getText A function that returns the text of the node in the source code
2404
2435
  * @returns Human readable node name
2405
2436
  */
2406
- declare function toReadableNodeName(node: TSESTree$1.Node, getText: (node: TSESTree$1.Node) => string): string;
2437
+ declare function toReadableNodeName(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
2407
2438
 
2408
2439
  /**
2409
2440
  * Returns human readable node type for given AST node
2410
2441
  * @param node AST node
2411
2442
  * @returns Human readable node type
2412
2443
  */
2413
- declare function toReadableNodeType(node: TSESTree$1.Node): "property" | "RegExp literal" | "Null literal" | "Boolean literal" | "Number literal" | "String literal" | "BigInt literal" | "Symbol literal" | "identifier" | "member expression" | "JSX attribute" | "JSX element" | "JSX fragment" | "JSX identifier" | "JSX text" | "JSX closing element" | "JSX closing fragment" | "JSX empty expression" | "JSX expression container" | "JSX member expression" | "JSX namespaced name" | "JSX opening element" | "JSX opening fragment" | "JSX spread attribute" | "JSX spread child" | "decorator" | "program" | "super" | "accessor property" | "array expression" | "array pattern" | "function expression" | "arrow function expression" | "assignment expression" | "assignment pattern" | "await expression" | "binary expression" | "block statement" | "break statement" | "call expression" | "catch clause" | "chain expression" | "class body" | "class declaration" | "class expression" | "conditional expression" | "continue statement" | "debugger statement" | "while statement" | "do while statement" | "empty statement" | "export all declaration" | "export default declaration" | "export named declaration" | "export specifier" | "expression statement" | "for in statement" | "for of statement" | "for statement" | "function declaration" | "if statement" | "import attribute" | "import declaration" | "import default specifier" | "import expression" | "import namespace specifier" | "import specifier" | "labeled statement" | "logical expression" | "meta property" | "method definition" | "new expression" | "object expression" | "object pattern" | "private identifier" | "property definition" | "rest element" | "return statement" | "sequence expression" | "spread element" | "static block" | "switch case" | "switch statement" | "tagged template expression" | "template element" | "template literal" | "this expression" | "throw statement" | "try statement" | "unary expression" | "update expression" | "variable declaration" | "variable declarator" | "with statement" | "yield expression" | "ts abstract accessor property" | "ts abstract keyword" | "ts abstract method definition" | "ts abstract property definition" | "ts any keyword" | "ts array type" | "ts as expression" | "ts async keyword" | "ts big int keyword" | "ts boolean keyword" | "ts call signature declaration" | "ts class implements" | "ts conditional type" | "ts constructor type" | "ts construct signature declaration" | "ts declare function" | "ts declare keyword" | "ts empty body function expression" | "ts enum body" | "ts enum declaration" | "ts enum member" | "ts export assignment" | "ts export keyword" | "ts external module reference" | "ts function type" | "ts import equals declaration" | "ts import type" | "ts indexed access type" | "ts index signature" | "ts infer type" | "ts instantiation expression" | "ts interface body" | "ts interface declaration" | "ts interface heritage" | "ts intersection type" | "ts intrinsic keyword" | "ts literal type" | "ts mapped type" | "ts method signature" | "ts module block" | "ts module declaration" | "ts named tuple member" | "ts namespace export declaration" | "ts never keyword" | "ts non null expression" | "ts null keyword" | "ts number keyword" | "ts object keyword" | "ts optional type" | "ts parameter property" | "ts private keyword" | "ts property signature" | "ts protected keyword" | "ts public keyword" | "ts qualified name" | "ts readonly keyword" | "ts rest type" | "ts satisfies expression" | "ts static keyword" | "ts string keyword" | "ts symbol keyword" | "ts template literal type" | "ts this type" | "ts tuple type" | "ts type alias declaration" | "ts type annotation" | "ts type assertion" | "ts type literal" | "ts type operator" | "ts type parameter" | "ts type parameter declaration" | "ts type parameter instantiation" | "ts type predicate" | "ts type query" | "ts type reference" | "ts undefined keyword" | "ts union type" | "ts unknown keyword" | "ts void keyword";
2444
+ declare function toReadableNodeType(node: TSESTree.Node): "property" | "RegExp literal" | "Null literal" | "Boolean literal" | "Number literal" | "String literal" | "BigInt literal" | "Symbol literal" | "identifier" | "member expression" | "JSX attribute" | "JSX element" | "JSX fragment" | "JSX identifier" | "JSX text" | "JSX closing element" | "JSX closing fragment" | "JSX empty expression" | "JSX expression container" | "JSX member expression" | "JSX namespaced name" | "JSX opening element" | "JSX opening fragment" | "JSX spread attribute" | "JSX spread child" | "decorator" | "program" | "super" | "accessor property" | "array expression" | "array pattern" | "function expression" | "arrow function expression" | "assignment expression" | "assignment pattern" | "await expression" | "binary expression" | "block statement" | "break statement" | "call expression" | "catch clause" | "chain expression" | "class body" | "class declaration" | "class expression" | "conditional expression" | "continue statement" | "debugger statement" | "while statement" | "do while statement" | "empty statement" | "export all declaration" | "export default declaration" | "export named declaration" | "export specifier" | "expression statement" | "for in statement" | "for of statement" | "for statement" | "function declaration" | "if statement" | "import attribute" | "import declaration" | "import default specifier" | "import expression" | "import namespace specifier" | "import specifier" | "labeled statement" | "logical expression" | "meta property" | "method definition" | "new expression" | "object expression" | "object pattern" | "private identifier" | "property definition" | "rest element" | "return statement" | "sequence expression" | "spread element" | "static block" | "switch case" | "switch statement" | "tagged template expression" | "template element" | "template literal" | "this expression" | "throw statement" | "try statement" | "unary expression" | "update expression" | "variable declaration" | "variable declarator" | "with statement" | "yield expression" | "ts abstract accessor property" | "ts abstract keyword" | "ts abstract method definition" | "ts abstract property definition" | "ts any keyword" | "ts array type" | "ts as expression" | "ts async keyword" | "ts big int keyword" | "ts boolean keyword" | "ts call signature declaration" | "ts class implements" | "ts conditional type" | "ts constructor type" | "ts construct signature declaration" | "ts declare function" | "ts declare keyword" | "ts empty body function expression" | "ts enum body" | "ts enum declaration" | "ts enum member" | "ts export assignment" | "ts export keyword" | "ts external module reference" | "ts function type" | "ts import equals declaration" | "ts import type" | "ts indexed access type" | "ts index signature" | "ts infer type" | "ts instantiation expression" | "ts interface body" | "ts interface declaration" | "ts interface heritage" | "ts intersection type" | "ts intrinsic keyword" | "ts literal type" | "ts mapped type" | "ts method signature" | "ts module block" | "ts module declaration" | "ts named tuple member" | "ts namespace export declaration" | "ts never keyword" | "ts non null expression" | "ts null keyword" | "ts number keyword" | "ts object keyword" | "ts optional type" | "ts parameter property" | "ts private keyword" | "ts property signature" | "ts protected keyword" | "ts public keyword" | "ts qualified name" | "ts readonly keyword" | "ts rest type" | "ts satisfies expression" | "ts static keyword" | "ts string keyword" | "ts symbol keyword" | "ts template literal type" | "ts this type" | "ts tuple type" | "ts type alias declaration" | "ts type annotation" | "ts type assertion" | "ts type literal" | "ts type operator" | "ts type parameter" | "ts type parameter declaration" | "ts type parameter instantiation" | "ts type predicate" | "ts type query" | "ts type reference" | "ts undefined keyword" | "ts union type" | "ts unknown keyword" | "ts void keyword";
2414
2445
  type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
2415
2446
 
2416
- /**
2417
- * Traverses up the AST tree until the predicate returns `true` or the root node is reached
2418
- * @param node The AST node to start traversing from
2419
- * @param predicate The predicate to check each node
2420
- * @returns The first node that matches the predicate or `null` if no node matches
2421
- */
2422
- declare const traverseUp: {
2423
- (node: TSESTree$1.Node, predicate: (node: TSESTree$1.Node) => boolean): O.Option<TSESTree$1.Node>;
2424
- (predicate: (node: TSESTree$1.Node) => boolean): (node: TSESTree$1.Node) => O.Option<TSESTree$1.Node>;
2425
- };
2426
-
2427
- /**
2428
- * Traverses up the AST tree until the predicate returns `true` or the root node is reached
2429
- * @template T
2430
- * @param node The AST node to start traversing from
2431
- * @param predicate The predicate to check each node. **must be a type guard**
2432
- * @returns The first node that matches the predicate or `null` if no node matches
2433
- */
2434
- declare const traverseUpGuard: {
2435
- <T extends TSESTree$1.Node>(node: TSESTree$1.Node, predicate: (node: TSESTree$1.Node) => node is T): O.Option<T>;
2436
- <T extends TSESTree$1.Node>(predicate: (node: TSESTree$1.Node) => node is T): (node: TSESTree$1.Node) => O.Option<T>;
2437
- };
2438
-
2439
- /**
2440
- * Traverses up the AST tree until the predicate returns `true` or the stop node is reached
2441
- * @param node The AST node to start traversing from
2442
- * @param stopNode The AST node to stop traversing at
2443
- * @param predicate The predicate to check each node
2444
- * @returns The first node that matches the predicate or `null` if no node matches
2445
- */
2446
- declare function traverseUpStop(node: TSESTree$1.Node, stopNode: TSESTree$1.Node, predicate: (node: TSESTree$1.Node) => boolean): O.Option<TSESTree$1.Node>;
2447
-
2448
- declare function unwrapTypeExpression(node: TSESTree$1.Node): TSESTree$1.Node;
2447
+ declare function unwrapTypeExpression(node: TSESTree.Node): TSESTree.Node;
2449
2448
 
2450
- export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getIdentifiersFromBinaryExpression, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfImmediatelyInvoked, isFunctionOfObjectMethod, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMultiLine, isNodeEqual, isOneOf, isProperty, isRegExpLiteral, isStringLiteral, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, traverseUp, traverseUpGuard, traverseUpStop, unwrapTypeExpression };
2449
+ export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, findParentNodeGuard, findParentNodeStop, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getIdentifiersFromBinaryExpression, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfImmediatelyInvoked, isFunctionOfObjectMethod, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMultiLine, isNodeEqual, isOneOf, isProperty, isRegExpLiteral, isStringLiteral, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, unwrapTypeExpression };
package/dist/index.d.ts CHANGED
@@ -1,32 +1,63 @@
1
1
  import { O } from '@eslint-react/eff';
2
- import { TSESTree as TSESTree$1, AST_NODE_TYPES as AST_NODE_TYPES$2 } from '@typescript-eslint/types';
3
- import { TSESTree } from '@typescript-eslint/utils';
2
+ import { TSESTree, AST_NODE_TYPES as AST_NODE_TYPES$2 } from '@typescript-eslint/types';
3
+ import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
4
4
  import { SyntaxKind } from 'typescript';
5
5
  import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from '@typescript-eslint/typescript-estree';
6
6
  import * as effect_Predicate from 'effect/Predicate';
7
7
 
8
- type TSESTreeFunction = TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression;
9
- type TSESTreeFunctionType = TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSDeclareFunction | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignature | TSESTreeFunction;
10
- type TSESTreeClass = TSESTree.ClassDeclaration | TSESTree.ClassExpression;
11
- type TSESTreeLoop = TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
12
- type TSESTreeArrayTupleType = TSESTree.TSArrayType | TSESTree.TSTupleType;
13
- type TSESTreeProperty = TSESTree.PropertyDefinition | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignature;
14
- type TSESTreeJSX = TSESTree.JSXAttribute | TSESTree.JSXChild | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXElement | TSESTree.JSXEmptyExpression | TSESTree.JSXExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXFragment | TSESTree.JSXIdentifier | TSESTree.JSXIdentifierToken | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXTagNameExpression | TSESTree.JSXText | TSESTree.JSXTextToken;
15
- type TSESTreeDestructuringPattern = TSESTree.ArrayPattern | TSESTree.AssignmentPattern | TSESTree.ObjectPattern | TSESTree.RestElement;
16
- type TSESTreeTypeDeclaration = TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration;
8
+ /**
9
+ * Find the first parent node that satisfies the test
10
+ * @param node The node to start searching
11
+ * @param test The test function
12
+ * @returns The first parent node that satisfies the test
13
+ */
14
+ declare const findParentNode: {
15
+ (node: TSESTree.Node, test: (node: TSESTree.Node) => boolean): O.Option<TSESTree.Node>;
16
+ (test: (node: TSESTree.Node) => boolean): (node: TSESTree.Node) => O.Option<TSESTree.Node>;
17
+ };
18
+
19
+ /**
20
+ * Find the first parent node that satisfies the test
21
+ * @param node The node to start searching
22
+ * @param predicate The type guard function
23
+ * @returns The first parent node that satisfies the test
24
+ */
25
+ declare const findParentNodeGuard: {
26
+ <T extends TSESTree.Node>(node: TSESTree.Node, predicate: (node: TSESTree.Node) => node is T): O.Option<T>;
27
+ <T extends TSESTree.Node>(predicate: (node: TSESTree.Node) => node is T): (node: TSESTree.Node) => O.Option<T>;
28
+ };
29
+
30
+ /**
31
+ * Find the first parent node that satisfies the test and stops at the stop node
32
+ * @param node The node to start searching
33
+ * @param stopNode The node to stop searching
34
+ * @param predicate The test function
35
+ * @returns The first parent node that satisfies the test
36
+ */
37
+ declare function findParentNodeStop(node: TSESTree.Node, stopNode: TSESTree.Node, predicate: (node: TSESTree.Node) => boolean): O.Option<TSESTree.Node>;
38
+
39
+ type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
40
+ type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
41
+ type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
42
+ type TSESTreeLoop = TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TSESTree$1.ForOfStatement | TSESTree$1.ForStatement | TSESTree$1.WhileStatement;
43
+ type TSESTreeArrayTupleType = TSESTree$1.TSArrayType | TSESTree$1.TSTupleType;
44
+ type TSESTreeProperty = TSESTree$1.PropertyDefinition | TSESTree$1.TSIndexSignature | TSESTree$1.TSParameterProperty | TSESTree$1.TSPropertySignature;
45
+ type TSESTreeJSX = TSESTree$1.JSXAttribute | TSESTree$1.JSXChild | TSESTree$1.JSXClosingElement | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXElement | TSESTree$1.JSXEmptyExpression | TSESTree$1.JSXExpression | TSESTree$1.JSXExpressionContainer | TSESTree$1.JSXFragment | TSESTree$1.JSXIdentifier | TSESTree$1.JSXIdentifierToken | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXSpreadAttribute | TSESTree$1.JSXSpreadChild | TSESTree$1.JSXTagNameExpression | TSESTree$1.JSXText | TSESTree$1.JSXTextToken;
46
+ type TSESTreeDestructuringPattern = TSESTree$1.ArrayPattern | TSESTree$1.AssignmentPattern | TSESTree$1.ObjectPattern | TSESTree$1.RestElement;
47
+ type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
17
48
 
18
49
  type FunctionInitPath =
19
50
  /**
20
51
  * function Comp() { return <div />; }
21
52
  */
22
- readonly [TSESTree$1.FunctionDeclaration]
53
+ readonly [TSESTree.FunctionDeclaration]
23
54
  /**
24
55
  * const Comp = () => <div />;
25
56
  * const Comp = function () { return <div />; };
26
57
  */
27
58
  | readonly [
28
- TSESTree$1.VariableDeclaration,
29
- TSESTree$1.VariableDeclarator,
59
+ TSESTree.VariableDeclaration,
60
+ TSESTree.VariableDeclarator,
30
61
  TSESTreeFunction
31
62
  ]
32
63
  /**
@@ -34,19 +65,19 @@ readonly [TSESTree$1.FunctionDeclaration]
34
65
  * const Comp = React.forwardRef(() => <div />);
35
66
  */
36
67
  | readonly [
37
- TSESTree$1.VariableDeclaration,
38
- TSESTree$1.VariableDeclarator,
39
- TSESTree$1.CallExpression,
68
+ TSESTree.VariableDeclaration,
69
+ TSESTree.VariableDeclarator,
70
+ TSESTree.CallExpression,
40
71
  TSESTreeFunction
41
72
  ]
42
73
  /**
43
74
  * const Comp = React.memo(React.forwardRef(() => <div />));
44
75
  */
45
76
  | readonly [
46
- TSESTree$1.VariableDeclaration,
47
- TSESTree$1.VariableDeclarator,
48
- TSESTree$1.CallExpression,
49
- TSESTree$1.CallExpression,
77
+ TSESTree.VariableDeclaration,
78
+ TSESTree.VariableDeclarator,
79
+ TSESTree.CallExpression,
80
+ TSESTree.CallExpression,
50
81
  TSESTreeFunction
51
82
  ]
52
83
  /**
@@ -56,10 +87,10 @@ readonly [TSESTree$1.FunctionDeclaration]
56
87
  * }
57
88
  */
58
89
  | readonly [
59
- TSESTree$1.VariableDeclaration,
60
- TSESTree$1.VariableDeclarator,
61
- TSESTree$1.ObjectExpression,
62
- TSESTree$1.Property,
90
+ TSESTree.VariableDeclaration,
91
+ TSESTree.VariableDeclarator,
92
+ TSESTree.ObjectExpression,
93
+ TSESTree.Property,
63
94
  TSESTreeFunction
64
95
  ]
65
96
  /**
@@ -69,11 +100,11 @@ readonly [TSESTree$1.FunctionDeclaration]
69
100
  * }
70
101
  */
71
102
  | readonly [
72
- TSESTree$1.VariableDeclaration,
73
- TSESTree$1.VariableDeclarator,
74
- TSESTree$1.ObjectExpression,
75
- TSESTree$1.Property,
76
- TSESTree$1.CallExpression,
103
+ TSESTree.VariableDeclaration,
104
+ TSESTree.VariableDeclarator,
105
+ TSESTree.ObjectExpression,
106
+ TSESTree.Property,
107
+ TSESTree.CallExpression,
77
108
  TSESTreeFunction
78
109
  ]
79
110
  /**
@@ -83,12 +114,12 @@ readonly [TSESTree$1.FunctionDeclaration]
83
114
  * }
84
115
  */
85
116
  | readonly [
86
- TSESTree$1.VariableDeclaration,
87
- TSESTree$1.VariableDeclarator,
88
- TSESTree$1.ObjectExpression,
89
- TSESTree$1.Property,
90
- TSESTree$1.CallExpression,
91
- TSESTree$1.CallExpression,
117
+ TSESTree.VariableDeclaration,
118
+ TSESTree.VariableDeclarator,
119
+ TSESTree.ObjectExpression,
120
+ TSESTree.Property,
121
+ TSESTree.CallExpression,
122
+ TSESTree.CallExpression,
92
123
  TSESTreeFunction
93
124
  ]
94
125
  /**
@@ -97,9 +128,9 @@ readonly [TSESTree$1.FunctionDeclaration]
97
128
  * }
98
129
  */
99
130
  | readonly [
100
- TSESTree$1.ClassDeclaration,
101
- TSESTree$1.ClassBody,
102
- TSESTree$1.MethodDefinition,
131
+ TSESTree.ClassDeclaration,
132
+ TSESTree.ClassBody,
133
+ TSESTree.MethodDefinition,
103
134
  TSESTreeFunction
104
135
  ]
105
136
  /**
@@ -108,9 +139,9 @@ readonly [TSESTree$1.FunctionDeclaration]
108
139
  * }
109
140
  */
110
141
  | readonly [
111
- TSESTree$1.ClassDeclaration,
112
- TSESTree$1.ClassBody,
113
- TSESTree$1.PropertyDefinition,
142
+ TSESTree.ClassDeclaration,
143
+ TSESTree.ClassBody,
144
+ TSESTree.PropertyDefinition,
114
145
  TSESTreeFunction
115
146
  ];
116
147
  declare function getFunctionInitPath(node: TSESTreeFunction): O.Option<FunctionInitPath>;
@@ -121,7 +152,7 @@ declare function hasCallInFunctionInitPath(callName: string): (initPath: O.Optio
121
152
  * @param node The AST node to check
122
153
  * @returns class identifier or null
123
154
  */
124
- declare function getClassIdentifier(node: TSESTreeClass): O.Option<TSESTree$1.Identifier>;
155
+ declare function getClassIdentifier(node: TSESTreeClass): O.Option<TSESTree.Identifier>;
125
156
 
126
157
  /**
127
158
  * Gets the static name of a function AST node. For function declarations it is
@@ -131,9 +162,9 @@ declare function getClassIdentifier(node: TSESTreeClass): O.Option<TSESTree$1.Id
131
162
  * same AST nodes with some exceptions to better fit our use case.
132
163
  */
133
164
 
134
- declare function getFunctionIdentifier(node: TSESTree$1.Expression | TSESTreeFunction): O.Option<TSESTree$1.Identifier>;
165
+ declare function getFunctionIdentifier(node: TSESTree.Expression | TSESTreeFunction): O.Option<TSESTree.Identifier>;
135
166
 
136
- declare function getIdentifiersFromBinaryExpression(side: TSESTree$1.BinaryExpression | TSESTree$1.BinaryExpression["left"] | TSESTree$1.BinaryExpression["right"]): TSESTree$1.Identifier[];
167
+ declare function getIdentifiersFromBinaryExpression(side: TSESTree.BinaryExpression | TSESTree.BinaryExpression["left"] | TSESTree.BinaryExpression["right"]): TSESTree.Identifier[];
137
168
 
138
169
  declare function getLiteralValueType(input: bigint | boolean | null | number | string | symbol): "Null" | "Boolean" | "Number" | "String" | "BigInt" | "Symbol";
139
170
 
@@ -2292,8 +2323,8 @@ declare const getNestedCallExpressions: (node: Node) => CallExpression[];
2292
2323
  * @returns A partially applied function bound to a predicate of type T. The returned function can be called passing a
2293
2324
  * node, and it will return an array of all nested expressions of type T.
2294
2325
  */
2295
- declare function getNestedExpressionsOfType<T extends AST_NODE_TYPES$1>(type: T): (node: TSESTree$1.Node) => Extract<TSESTree$1.Node, {
2296
- type: T;
2326
+ declare function getNestedExpressionsOfType<TNodeType extends AST_NODE_TYPES$1>(type: TNodeType): (node: TSESTree.Node) => Extract<TSESTree.Node, {
2327
+ type: TNodeType;
2297
2328
  }>[];
2298
2329
 
2299
2330
  /**
@@ -2301,7 +2332,7 @@ declare function getNestedExpressionsOfType<T extends AST_NODE_TYPES$1>(type: T)
2301
2332
  * @param node The node to get the nested identifiers from
2302
2333
  * @returns All nested identifiers
2303
2334
  */
2304
- declare function getNestedIdentifiers(node: TSESTree$1.Node): readonly TSESTree$1.Identifier[];
2335
+ declare function getNestedIdentifiers(node: TSESTree.Node): readonly TSESTree.Identifier[];
2305
2336
 
2306
2337
  /**
2307
2338
  * Get all nested new expressions in an expression like node
@@ -2315,33 +2346,33 @@ declare const getNestedNewExpressions: (node: Node) => NewExpression[];
2315
2346
  * @param node The AST node
2316
2347
  * @returns The nested return statements in the node
2317
2348
  */
2318
- declare function getNestedReturnStatements(node: TSESTree$1.Node): readonly TSESTree$1.ReturnStatement[];
2349
+ declare function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTree.ReturnStatement[];
2319
2350
 
2320
- declare function getTopLevelIdentifier(node: TSESTree$1.Node): O.Option<TSESTree$1.Identifier>;
2351
+ declare function getTopLevelIdentifier(node: TSESTree.Node): O.Option<TSESTree.Identifier>;
2321
2352
 
2322
- declare const is: <NodeType extends AST_NODE_TYPES$2>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
2353
+ declare const is: <NodeType extends AST_NODE_TYPES$2>(nodeType: NodeType) => (node: TSESTree$1.Node | null | undefined) => node is Extract<TSESTree$1.Node, {
2323
2354
  type: NodeType;
2324
2355
  }>;
2325
- declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES$2[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
2356
+ declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES$2[]>(nodeTypes: NodeTypes) => (node: TSESTree$1.Node | null | undefined) => node is Extract<TSESTree$1.Node, {
2326
2357
  type: NodeTypes[number];
2327
2358
  }>;
2328
- declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
2329
- declare const isFunctionType: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression | TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSDeclareFunctionNoDeclare | TSESTree.TSDeclareFunctionWithDeclare | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignatureComputedName | TSESTree.TSMethodSignatureNonComputedName;
2330
- declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
2331
- declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
2332
- declare const isControlFlow: effect_Predicate.Refinement<TSESTree.Node | null | undefined, TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement | TSESTree.IfStatement | TSESTree.SwitchStatement>;
2333
- declare const isConditional: effect_Predicate.Refinement<TSESTree.Node | null | undefined, TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement | TSESTree.ConditionalExpression | TSESTree.IfStatement | TSESTree.LogicalExpression | TSESTree.SwitchStatement>;
2334
- declare const isArrayTupleType: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSArrayType | TSESTree.TSTupleType;
2335
- declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
2336
- declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
2337
- declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
2338
- declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXAttribute | TSESTree.JSXElement | TSESTree.JSXExpressionContainer | TSESTree.JSXSpreadChild | TSESTree.JSXFragment | TSESTree.JSXText | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXEmptyExpression | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute;
2339
- declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
2340
- declare const isDestructuringPattern: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrayPattern | TSESTree.AssignmentPattern | TSESTree.ObjectPattern | TSESTree.RestElement;
2341
- declare const isTypeDeclaration: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration;
2342
- declare const isLeftHandSideExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.ClassExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.ArrayPattern | TSESTree.ObjectPattern | TSESTree.CallExpression | TSESTree.ObjectExpression | TSESTree.ArrayExpression | TSESTree.Identifier | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression;
2343
- declare const isLeftHandSideExpressionType: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.ClassExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.ArrayPattern | TSESTree.ObjectPattern | TSESTree.CallExpression | TSESTree.ObjectExpression | TSESTree.ArrayExpression | TSESTree.Identifier | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSTypeAssertion;
2344
- declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
2359
+ declare const isFunction: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclarationWithName | TSESTree$1.FunctionDeclarationWithOptionalName | TSESTree$1.FunctionExpression;
2360
+ declare const isFunctionType: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclarationWithName | TSESTree$1.FunctionDeclarationWithOptionalName | TSESTree$1.FunctionExpression | TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunctionNoDeclare | TSESTree$1.TSDeclareFunctionWithDeclare | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignatureComputedName | TSESTree$1.TSMethodSignatureNonComputedName;
2361
+ declare const isClass: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ClassDeclarationWithName | TSESTree$1.ClassDeclarationWithOptionalName | TSESTree$1.ClassExpression;
2362
+ declare const isLoop: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TSESTree$1.ForOfStatement | TSESTree$1.ForStatement | TSESTree$1.WhileStatement;
2363
+ declare const isControlFlow: effect_Predicate.Refinement<TSESTree$1.Node | null | undefined, TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TSESTree$1.ForOfStatement | TSESTree$1.ForStatement | TSESTree$1.IfStatement | TSESTree$1.SwitchStatement | TSESTree$1.WhileStatement>;
2364
+ declare const isConditional: effect_Predicate.Refinement<TSESTree$1.Node | null | undefined, TSESTree$1.ConditionalExpression | TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TSESTree$1.ForOfStatement | TSESTree$1.ForStatement | TSESTree$1.IfStatement | TSESTree$1.LogicalExpression | TSESTree$1.SwitchStatement | TSESTree$1.WhileStatement>;
2365
+ declare const isArrayTupleType: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSArrayType | TSESTree$1.TSTupleType;
2366
+ declare const isProperty: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.PropertyDefinitionComputedName | TSESTree$1.PropertyDefinitionNonComputedName | TSESTree$1.TSIndexSignature | TSESTree$1.TSParameterProperty | TSESTree$1.TSPropertySignatureComputedName | TSESTree$1.TSPropertySignatureNonComputedName;
2367
+ declare const isJSXElement: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.JSXElement;
2368
+ declare const isJSXFragment: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.JSXFragment;
2369
+ declare const isJSX: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.JSXAttribute | TSESTree$1.JSXClosingElement | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXElement | TSESTree$1.JSXEmptyExpression | TSESTree$1.JSXExpressionContainer | TSESTree$1.JSXFragment | TSESTree$1.JSXIdentifier | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXSpreadAttribute | TSESTree$1.JSXSpreadChild | TSESTree$1.JSXText;
2370
+ declare const isJSXTagNameExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.JSXIdentifier | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName;
2371
+ declare const isDestructuringPattern: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrayPattern | TSESTree$1.AssignmentPattern | TSESTree$1.ObjectPattern | TSESTree$1.RestElement;
2372
+ declare const isTypeDeclaration: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
2373
+ declare const isLeftHandSideExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrayExpression | TSESTree$1.ArrayPattern | TSESTree$1.ArrowFunctionExpression | TSESTree$1.CallExpression | TSESTree$1.ClassExpression | TSESTree$1.FunctionExpression | TSESTree$1.Identifier | TSESTree$1.JSXElement | TSESTree$1.JSXFragment | TSESTree$1.BigIntLiteral | TSESTree$1.BooleanLiteral | TSESTree$1.NullLiteral | TSESTree$1.NumberLiteral | TSESTree$1.RegExpLiteral | TSESTree$1.StringLiteral | TSESTree$1.MemberExpressionComputedName | TSESTree$1.MemberExpressionNonComputedName | TSESTree$1.MetaProperty | TSESTree$1.ObjectExpression | TSESTree$1.ObjectPattern | TSESTree$1.SequenceExpression | TSESTree$1.Super | TSESTree$1.TaggedTemplateExpression | TSESTree$1.TemplateLiteral | TSESTree$1.ThisExpression;
2374
+ declare const isLeftHandSideExpressionType: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.ArrayExpression | TSESTree$1.ArrayPattern | TSESTree$1.ArrowFunctionExpression | TSESTree$1.CallExpression | TSESTree$1.ClassExpression | TSESTree$1.FunctionExpression | TSESTree$1.Identifier | TSESTree$1.JSXElement | TSESTree$1.JSXFragment | TSESTree$1.BigIntLiteral | TSESTree$1.BooleanLiteral | TSESTree$1.NullLiteral | TSESTree$1.NumberLiteral | TSESTree$1.RegExpLiteral | TSESTree$1.StringLiteral | TSESTree$1.MemberExpressionComputedName | TSESTree$1.MemberExpressionNonComputedName | TSESTree$1.MetaProperty | TSESTree$1.ObjectExpression | TSESTree$1.ObjectPattern | TSESTree$1.SequenceExpression | TSESTree$1.Super | TSESTree$1.TaggedTemplateExpression | TSESTree$1.TemplateLiteral | TSESTree$1.ThisExpression | TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSTypeAssertion;
2375
+ declare const isTypeExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
2345
2376
 
2346
2377
  declare function isEmptyFunction(node: TSESTreeFunction): boolean;
2347
2378
 
@@ -2350,14 +2381,14 @@ declare function isEmptyFunction(node: TSESTreeFunction): boolean;
2350
2381
  * @param node The node to check.
2351
2382
  * @returns `true` if the node is a function expression or arrow function expression of a class method, `false` otherwise.
2352
2383
  */
2353
- declare const isFunctionOfClassMethod: (node: TSESTree$1.Node) => boolean;
2384
+ declare const isFunctionOfClassMethod: (node: TSESTree.Node) => boolean;
2354
2385
 
2355
2386
  /**
2356
2387
  * Checks if the given node is a function expression or arrow function expression of a class property.
2357
2388
  * @param node The node to check.
2358
2389
  * @returns `true` if the node is a function expression or arrow function expression of a class property, `false` otherwise.
2359
2390
  */
2360
- declare const isFunctionOfClassProperty: (node: TSESTree$1.Node) => boolean;
2391
+ declare const isFunctionOfClassProperty: (node: TSESTree.Node) => boolean;
2361
2392
 
2362
2393
  declare function isFunctionOfImmediatelyInvoked(node: TSESTreeFunction): boolean;
2363
2394
 
@@ -2366,18 +2397,18 @@ declare function isFunctionOfImmediatelyInvoked(node: TSESTreeFunction): boolean
2366
2397
  * @param node The node to check.
2367
2398
  * @returns `true` if the node is a function expression or arrow function expression of a object method, `false` otherwise.
2368
2399
  */
2369
- declare const isFunctionOfObjectMethod: (node: TSESTree$1.Node) => boolean;
2400
+ declare const isFunctionOfObjectMethod: (node: TSESTree.Node) => boolean;
2370
2401
 
2371
- declare function isKeyLiteralLike(node: TSESTree$1.MemberExpression | TSESTree$1.MethodDefinition | TSESTree$1.Property | TSESTree$1.PropertyDefinition, property: TSESTree$1.Node): boolean;
2402
+ declare function isKeyLiteralLike(node: TSESTree.MemberExpression | TSESTree.MethodDefinition | TSESTree.Property | TSESTree.PropertyDefinition, property: TSESTree.Node): boolean;
2372
2403
 
2373
- declare function isMapCallLoose(node: TSESTree$1.Node): node is TSESTree$1.CallExpression;
2404
+ declare function isMapCallLoose(node: TSESTree.Node): node is TSESTree.CallExpression;
2374
2405
 
2375
2406
  /**
2376
2407
  * Check if a node is multiline
2377
2408
  * @param node The AST node to check
2378
2409
  * @returns `true` if the node is multiline
2379
2410
  */
2380
- declare function isMultiLine(node: TSESTree$1.Node): boolean;
2411
+ declare function isMultiLine(node: TSESTree.Node): boolean;
2381
2412
 
2382
2413
  /**
2383
2414
  * Determines whether node equals to another node
@@ -2387,15 +2418,15 @@ declare function isMultiLine(node: TSESTree$1.Node): boolean;
2387
2418
  * @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
2388
2419
  */
2389
2420
  declare const isNodeEqual: {
2390
- (a: TSESTree$1.Node): (b: TSESTree$1.Node) => boolean;
2391
- (a: TSESTree$1.Node, b: TSESTree$1.Node): boolean;
2421
+ (a: TSESTree.Node): (b: TSESTree.Node) => boolean;
2422
+ (a: TSESTree.Node, b: TSESTree.Node): boolean;
2392
2423
  };
2393
2424
 
2394
- declare function isRegExpLiteral(node: TSESTree$1.Node): node is TSESTree$1.RegExpLiteral;
2425
+ declare function isRegExpLiteral(node: TSESTree.Node): node is TSESTree.RegExpLiteral;
2395
2426
 
2396
- declare function isStringLiteral(node: TSESTree$1.Node): node is TSESTree$1.StringLiteral;
2427
+ declare function isStringLiteral(node: TSESTree.Node): node is TSESTree.StringLiteral;
2397
2428
 
2398
- declare function isThisExpression(node: TSESTree$1.Expression): boolean;
2429
+ declare function isThisExpression(node: TSESTree.Expression): boolean;
2399
2430
 
2400
2431
  /**
2401
2432
  * Returns human readable node name for given AST node
@@ -2403,48 +2434,16 @@ declare function isThisExpression(node: TSESTree$1.Expression): boolean;
2403
2434
  * @param getText A function that returns the text of the node in the source code
2404
2435
  * @returns Human readable node name
2405
2436
  */
2406
- declare function toReadableNodeName(node: TSESTree$1.Node, getText: (node: TSESTree$1.Node) => string): string;
2437
+ declare function toReadableNodeName(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
2407
2438
 
2408
2439
  /**
2409
2440
  * Returns human readable node type for given AST node
2410
2441
  * @param node AST node
2411
2442
  * @returns Human readable node type
2412
2443
  */
2413
- declare function toReadableNodeType(node: TSESTree$1.Node): "property" | "RegExp literal" | "Null literal" | "Boolean literal" | "Number literal" | "String literal" | "BigInt literal" | "Symbol literal" | "identifier" | "member expression" | "JSX attribute" | "JSX element" | "JSX fragment" | "JSX identifier" | "JSX text" | "JSX closing element" | "JSX closing fragment" | "JSX empty expression" | "JSX expression container" | "JSX member expression" | "JSX namespaced name" | "JSX opening element" | "JSX opening fragment" | "JSX spread attribute" | "JSX spread child" | "decorator" | "program" | "super" | "accessor property" | "array expression" | "array pattern" | "function expression" | "arrow function expression" | "assignment expression" | "assignment pattern" | "await expression" | "binary expression" | "block statement" | "break statement" | "call expression" | "catch clause" | "chain expression" | "class body" | "class declaration" | "class expression" | "conditional expression" | "continue statement" | "debugger statement" | "while statement" | "do while statement" | "empty statement" | "export all declaration" | "export default declaration" | "export named declaration" | "export specifier" | "expression statement" | "for in statement" | "for of statement" | "for statement" | "function declaration" | "if statement" | "import attribute" | "import declaration" | "import default specifier" | "import expression" | "import namespace specifier" | "import specifier" | "labeled statement" | "logical expression" | "meta property" | "method definition" | "new expression" | "object expression" | "object pattern" | "private identifier" | "property definition" | "rest element" | "return statement" | "sequence expression" | "spread element" | "static block" | "switch case" | "switch statement" | "tagged template expression" | "template element" | "template literal" | "this expression" | "throw statement" | "try statement" | "unary expression" | "update expression" | "variable declaration" | "variable declarator" | "with statement" | "yield expression" | "ts abstract accessor property" | "ts abstract keyword" | "ts abstract method definition" | "ts abstract property definition" | "ts any keyword" | "ts array type" | "ts as expression" | "ts async keyword" | "ts big int keyword" | "ts boolean keyword" | "ts call signature declaration" | "ts class implements" | "ts conditional type" | "ts constructor type" | "ts construct signature declaration" | "ts declare function" | "ts declare keyword" | "ts empty body function expression" | "ts enum body" | "ts enum declaration" | "ts enum member" | "ts export assignment" | "ts export keyword" | "ts external module reference" | "ts function type" | "ts import equals declaration" | "ts import type" | "ts indexed access type" | "ts index signature" | "ts infer type" | "ts instantiation expression" | "ts interface body" | "ts interface declaration" | "ts interface heritage" | "ts intersection type" | "ts intrinsic keyword" | "ts literal type" | "ts mapped type" | "ts method signature" | "ts module block" | "ts module declaration" | "ts named tuple member" | "ts namespace export declaration" | "ts never keyword" | "ts non null expression" | "ts null keyword" | "ts number keyword" | "ts object keyword" | "ts optional type" | "ts parameter property" | "ts private keyword" | "ts property signature" | "ts protected keyword" | "ts public keyword" | "ts qualified name" | "ts readonly keyword" | "ts rest type" | "ts satisfies expression" | "ts static keyword" | "ts string keyword" | "ts symbol keyword" | "ts template literal type" | "ts this type" | "ts tuple type" | "ts type alias declaration" | "ts type annotation" | "ts type assertion" | "ts type literal" | "ts type operator" | "ts type parameter" | "ts type parameter declaration" | "ts type parameter instantiation" | "ts type predicate" | "ts type query" | "ts type reference" | "ts undefined keyword" | "ts union type" | "ts unknown keyword" | "ts void keyword";
2444
+ declare function toReadableNodeType(node: TSESTree.Node): "property" | "RegExp literal" | "Null literal" | "Boolean literal" | "Number literal" | "String literal" | "BigInt literal" | "Symbol literal" | "identifier" | "member expression" | "JSX attribute" | "JSX element" | "JSX fragment" | "JSX identifier" | "JSX text" | "JSX closing element" | "JSX closing fragment" | "JSX empty expression" | "JSX expression container" | "JSX member expression" | "JSX namespaced name" | "JSX opening element" | "JSX opening fragment" | "JSX spread attribute" | "JSX spread child" | "decorator" | "program" | "super" | "accessor property" | "array expression" | "array pattern" | "function expression" | "arrow function expression" | "assignment expression" | "assignment pattern" | "await expression" | "binary expression" | "block statement" | "break statement" | "call expression" | "catch clause" | "chain expression" | "class body" | "class declaration" | "class expression" | "conditional expression" | "continue statement" | "debugger statement" | "while statement" | "do while statement" | "empty statement" | "export all declaration" | "export default declaration" | "export named declaration" | "export specifier" | "expression statement" | "for in statement" | "for of statement" | "for statement" | "function declaration" | "if statement" | "import attribute" | "import declaration" | "import default specifier" | "import expression" | "import namespace specifier" | "import specifier" | "labeled statement" | "logical expression" | "meta property" | "method definition" | "new expression" | "object expression" | "object pattern" | "private identifier" | "property definition" | "rest element" | "return statement" | "sequence expression" | "spread element" | "static block" | "switch case" | "switch statement" | "tagged template expression" | "template element" | "template literal" | "this expression" | "throw statement" | "try statement" | "unary expression" | "update expression" | "variable declaration" | "variable declarator" | "with statement" | "yield expression" | "ts abstract accessor property" | "ts abstract keyword" | "ts abstract method definition" | "ts abstract property definition" | "ts any keyword" | "ts array type" | "ts as expression" | "ts async keyword" | "ts big int keyword" | "ts boolean keyword" | "ts call signature declaration" | "ts class implements" | "ts conditional type" | "ts constructor type" | "ts construct signature declaration" | "ts declare function" | "ts declare keyword" | "ts empty body function expression" | "ts enum body" | "ts enum declaration" | "ts enum member" | "ts export assignment" | "ts export keyword" | "ts external module reference" | "ts function type" | "ts import equals declaration" | "ts import type" | "ts indexed access type" | "ts index signature" | "ts infer type" | "ts instantiation expression" | "ts interface body" | "ts interface declaration" | "ts interface heritage" | "ts intersection type" | "ts intrinsic keyword" | "ts literal type" | "ts mapped type" | "ts method signature" | "ts module block" | "ts module declaration" | "ts named tuple member" | "ts namespace export declaration" | "ts never keyword" | "ts non null expression" | "ts null keyword" | "ts number keyword" | "ts object keyword" | "ts optional type" | "ts parameter property" | "ts private keyword" | "ts property signature" | "ts protected keyword" | "ts public keyword" | "ts qualified name" | "ts readonly keyword" | "ts rest type" | "ts satisfies expression" | "ts static keyword" | "ts string keyword" | "ts symbol keyword" | "ts template literal type" | "ts this type" | "ts tuple type" | "ts type alias declaration" | "ts type annotation" | "ts type assertion" | "ts type literal" | "ts type operator" | "ts type parameter" | "ts type parameter declaration" | "ts type parameter instantiation" | "ts type predicate" | "ts type query" | "ts type reference" | "ts undefined keyword" | "ts union type" | "ts unknown keyword" | "ts void keyword";
2414
2445
  type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
2415
2446
 
2416
- /**
2417
- * Traverses up the AST tree until the predicate returns `true` or the root node is reached
2418
- * @param node The AST node to start traversing from
2419
- * @param predicate The predicate to check each node
2420
- * @returns The first node that matches the predicate or `null` if no node matches
2421
- */
2422
- declare const traverseUp: {
2423
- (node: TSESTree$1.Node, predicate: (node: TSESTree$1.Node) => boolean): O.Option<TSESTree$1.Node>;
2424
- (predicate: (node: TSESTree$1.Node) => boolean): (node: TSESTree$1.Node) => O.Option<TSESTree$1.Node>;
2425
- };
2426
-
2427
- /**
2428
- * Traverses up the AST tree until the predicate returns `true` or the root node is reached
2429
- * @template T
2430
- * @param node The AST node to start traversing from
2431
- * @param predicate The predicate to check each node. **must be a type guard**
2432
- * @returns The first node that matches the predicate or `null` if no node matches
2433
- */
2434
- declare const traverseUpGuard: {
2435
- <T extends TSESTree$1.Node>(node: TSESTree$1.Node, predicate: (node: TSESTree$1.Node) => node is T): O.Option<T>;
2436
- <T extends TSESTree$1.Node>(predicate: (node: TSESTree$1.Node) => node is T): (node: TSESTree$1.Node) => O.Option<T>;
2437
- };
2438
-
2439
- /**
2440
- * Traverses up the AST tree until the predicate returns `true` or the stop node is reached
2441
- * @param node The AST node to start traversing from
2442
- * @param stopNode The AST node to stop traversing at
2443
- * @param predicate The predicate to check each node
2444
- * @returns The first node that matches the predicate or `null` if no node matches
2445
- */
2446
- declare function traverseUpStop(node: TSESTree$1.Node, stopNode: TSESTree$1.Node, predicate: (node: TSESTree$1.Node) => boolean): O.Option<TSESTree$1.Node>;
2447
-
2448
- declare function unwrapTypeExpression(node: TSESTree$1.Node): TSESTree$1.Node;
2447
+ declare function unwrapTypeExpression(node: TSESTree.Node): TSESTree.Node;
2449
2448
 
2450
- export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getIdentifiersFromBinaryExpression, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfImmediatelyInvoked, isFunctionOfObjectMethod, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMultiLine, isNodeEqual, isOneOf, isProperty, isRegExpLiteral, isStringLiteral, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, traverseUp, traverseUpGuard, traverseUpStop, unwrapTypeExpression };
2449
+ export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, findParentNodeGuard, findParentNodeStop, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getIdentifiersFromBinaryExpression, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfImmediatelyInvoked, isFunctionOfObjectMethod, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMultiLine, isNodeEqual, isOneOf, isProperty, isRegExpLiteral, isStringLiteral, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, unwrapTypeExpression };
package/dist/index.js CHANGED
@@ -8,7 +8,37 @@ var typescriptEstree = require('@typescript-eslint/typescript-estree');
8
8
  var types$1 = require('@eslint-react/types');
9
9
  var stringTs = require('string-ts');
10
10
 
11
- // src/function-init-path.ts
11
+ // src/find-parent-node.ts
12
+ var findParentNode = eff.F.dual(2, (node, test) => {
13
+ let parent = node.parent;
14
+ while (parent && parent.type !== types.AST_NODE_TYPES.Program) {
15
+ if (test(parent)) {
16
+ return eff.O.some(parent);
17
+ }
18
+ parent = parent.parent;
19
+ }
20
+ return eff.O.none();
21
+ });
22
+ var findParentNodeGuard = eff.F.dual(2, (node, predicate) => {
23
+ let parent = node.parent;
24
+ while (parent) {
25
+ if (predicate(parent)) {
26
+ return eff.O.some(parent);
27
+ }
28
+ parent = parent.parent;
29
+ }
30
+ return eff.O.none();
31
+ });
32
+ function findParentNodeStop(node, stopNode, predicate) {
33
+ let parent = node.parent;
34
+ while (parent && parent !== stopNode && parent.type !== types.AST_NODE_TYPES.Program) {
35
+ if (predicate(parent)) {
36
+ return eff.O.some(parent);
37
+ }
38
+ parent = parent.parent;
39
+ }
40
+ return eff.O.none();
41
+ }
12
42
  function getFunctionInitPath(node) {
13
43
  const { parent } = node;
14
44
  if (node.type === types.AST_NODE_TYPES.FunctionDeclaration) return eff.O.some([node]);
@@ -70,22 +100,6 @@ function hasCallInFunctionInitPath(callName) {
70
100
  eff.O.filter((p) => p.length > 0),
71
101
  eff.O.exists((nodes) => {
72
102
  return nodes.some(
73
- // TODO: Re-evaluate dot notation callName
74
- // callName.includes(".")
75
- // ? n => {
76
- // const [objectName, propertyName] = callName.split(".");
77
- // return "callee" in n
78
- // && n.callee.type === AST_NODE_TYPES.MemberExpression
79
- // && n.callee.object.type === AST_NODE_TYPES.Identifier
80
- // && n.callee.object.name === objectName
81
- // && n.callee.property.type === AST_NODE_TYPES.Identifier
82
- // && n.callee.property.name === propertyName;
83
- // }
84
- // : n => {
85
- // return "callee" in n
86
- // && n.callee.type === AST_NODE_TYPES.Identifier
87
- // && n.callee.name === callName;
88
- // },
89
103
  (n) => {
90
104
  if (n.type !== types.AST_NODE_TYPES.CallExpression) return false;
91
105
  if (n.callee.type === types.AST_NODE_TYPES.Identifier) return n.callee.name === callName;
@@ -434,20 +448,13 @@ function getNestedIdentifiers(node) {
434
448
  return identifiers;
435
449
  }
436
450
  var getNestedNewExpressions = getNestedExpressionsOfType(typescriptEstree.AST_NODE_TYPES.NewExpression);
437
- var traverseUpGuard = eff.F.dual(2, (node, predicate) => {
438
- const { parent } = node;
439
- if (!parent || parent.type === types.AST_NODE_TYPES.Program) return eff.O.none();
440
- return predicate(parent) ? eff.O.some(parent) : traverseUpGuard(parent, predicate);
441
- });
442
-
443
- // src/get-nested-return-statements.ts
444
451
  function getNestedReturnStatements(node) {
445
452
  const returnStatements = [];
446
- const functionNode = isFunction(node) ? node : eff.O.getOrNull(traverseUpGuard(node, isFunction));
453
+ const functionNode = isFunction(node) ? node : eff.O.getOrNull(findParentNodeGuard(node, isFunction));
447
454
  typescriptEstree.simpleTraverse(node, {
448
455
  enter(node2) {
449
456
  if (node2.type !== types.AST_NODE_TYPES.ReturnStatement) return;
450
- const parentFunction = eff.O.getOrNull(traverseUpGuard(node2, isFunction));
457
+ const parentFunction = eff.O.getOrNull(findParentNodeGuard(node2, isFunction));
451
458
  if (parentFunction !== functionNode) return;
452
459
  returnStatements.push(node2);
453
460
  }
@@ -586,16 +593,6 @@ function toReadableNodeType(node) {
586
593
  if (isJSX(node)) return `JSX ${stringTs.toLowerCase(stringTs.delimiterCase(stringTs.replace(node.type, "JSX", ""), " "))}`;
587
594
  return stringTs.toLowerCase(stringTs.delimiterCase(node.type, " "));
588
595
  }
589
- var traverseUp = eff.F.dual(2, (node, predicate) => {
590
- const { parent } = node;
591
- if (!parent || parent.type === types.AST_NODE_TYPES.Program) return eff.O.none();
592
- return predicate(parent) ? eff.O.some(parent) : traverseUp(parent, predicate);
593
- });
594
- function traverseUpStop(node, stopNode, predicate) {
595
- const { parent } = node;
596
- if (!parent || parent === stopNode || parent.type === types.AST_NODE_TYPES.Program) return eff.O.none();
597
- return predicate(parent) ? eff.O.some(parent) : traverseUpStop(parent, stopNode, predicate);
598
- }
599
596
 
600
597
  // src/unwrap-type-expression.ts
601
598
  function unwrapTypeExpression(node) {
@@ -603,6 +600,9 @@ function unwrapTypeExpression(node) {
603
600
  return node;
604
601
  }
605
602
 
603
+ exports.findParentNode = findParentNode;
604
+ exports.findParentNodeGuard = findParentNodeGuard;
605
+ exports.findParentNodeStop = findParentNodeStop;
606
606
  exports.getClassIdentifier = getClassIdentifier;
607
607
  exports.getFunctionIdentifier = getFunctionIdentifier;
608
608
  exports.getFunctionInitPath = getFunctionInitPath;
@@ -648,7 +648,4 @@ exports.isTypeDeclaration = isTypeDeclaration;
648
648
  exports.isTypeExpression = isTypeExpression;
649
649
  exports.toReadableNodeName = toReadableNodeName;
650
650
  exports.toReadableNodeType = toReadableNodeType;
651
- exports.traverseUp = traverseUp;
652
- exports.traverseUpGuard = traverseUpGuard;
653
- exports.traverseUpStop = traverseUpStop;
654
651
  exports.unwrapTypeExpression = unwrapTypeExpression;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { or, F, O, isString } from '@eslint-react/eff';
1
+ import { F, O, or, isString } from '@eslint-react/eff';
2
2
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
3
3
  import { ASTUtils } from '@typescript-eslint/utils';
4
4
  import { isMatching, P, match } from 'ts-pattern';
@@ -6,7 +6,37 @@ import { AST_NODE_TYPES as AST_NODE_TYPES$1, simpleTraverse } from '@typescript-
6
6
  import { zip } from '@eslint-react/types';
7
7
  import { toLowerCase, delimiterCase, replace } from 'string-ts';
8
8
 
9
- // src/function-init-path.ts
9
+ // src/find-parent-node.ts
10
+ var findParentNode = F.dual(2, (node, test) => {
11
+ let parent = node.parent;
12
+ while (parent && parent.type !== AST_NODE_TYPES.Program) {
13
+ if (test(parent)) {
14
+ return O.some(parent);
15
+ }
16
+ parent = parent.parent;
17
+ }
18
+ return O.none();
19
+ });
20
+ var findParentNodeGuard = F.dual(2, (node, predicate) => {
21
+ let parent = node.parent;
22
+ while (parent) {
23
+ if (predicate(parent)) {
24
+ return O.some(parent);
25
+ }
26
+ parent = parent.parent;
27
+ }
28
+ return O.none();
29
+ });
30
+ function findParentNodeStop(node, stopNode, predicate) {
31
+ let parent = node.parent;
32
+ while (parent && parent !== stopNode && parent.type !== AST_NODE_TYPES.Program) {
33
+ if (predicate(parent)) {
34
+ return O.some(parent);
35
+ }
36
+ parent = parent.parent;
37
+ }
38
+ return O.none();
39
+ }
10
40
  function getFunctionInitPath(node) {
11
41
  const { parent } = node;
12
42
  if (node.type === AST_NODE_TYPES.FunctionDeclaration) return O.some([node]);
@@ -68,22 +98,6 @@ function hasCallInFunctionInitPath(callName) {
68
98
  O.filter((p) => p.length > 0),
69
99
  O.exists((nodes) => {
70
100
  return nodes.some(
71
- // TODO: Re-evaluate dot notation callName
72
- // callName.includes(".")
73
- // ? n => {
74
- // const [objectName, propertyName] = callName.split(".");
75
- // return "callee" in n
76
- // && n.callee.type === AST_NODE_TYPES.MemberExpression
77
- // && n.callee.object.type === AST_NODE_TYPES.Identifier
78
- // && n.callee.object.name === objectName
79
- // && n.callee.property.type === AST_NODE_TYPES.Identifier
80
- // && n.callee.property.name === propertyName;
81
- // }
82
- // : n => {
83
- // return "callee" in n
84
- // && n.callee.type === AST_NODE_TYPES.Identifier
85
- // && n.callee.name === callName;
86
- // },
87
101
  (n) => {
88
102
  if (n.type !== AST_NODE_TYPES.CallExpression) return false;
89
103
  if (n.callee.type === AST_NODE_TYPES.Identifier) return n.callee.name === callName;
@@ -432,20 +446,13 @@ function getNestedIdentifiers(node) {
432
446
  return identifiers;
433
447
  }
434
448
  var getNestedNewExpressions = getNestedExpressionsOfType(AST_NODE_TYPES$1.NewExpression);
435
- var traverseUpGuard = F.dual(2, (node, predicate) => {
436
- const { parent } = node;
437
- if (!parent || parent.type === AST_NODE_TYPES.Program) return O.none();
438
- return predicate(parent) ? O.some(parent) : traverseUpGuard(parent, predicate);
439
- });
440
-
441
- // src/get-nested-return-statements.ts
442
449
  function getNestedReturnStatements(node) {
443
450
  const returnStatements = [];
444
- const functionNode = isFunction(node) ? node : O.getOrNull(traverseUpGuard(node, isFunction));
451
+ const functionNode = isFunction(node) ? node : O.getOrNull(findParentNodeGuard(node, isFunction));
445
452
  simpleTraverse(node, {
446
453
  enter(node2) {
447
454
  if (node2.type !== AST_NODE_TYPES.ReturnStatement) return;
448
- const parentFunction = O.getOrNull(traverseUpGuard(node2, isFunction));
455
+ const parentFunction = O.getOrNull(findParentNodeGuard(node2, isFunction));
449
456
  if (parentFunction !== functionNode) return;
450
457
  returnStatements.push(node2);
451
458
  }
@@ -584,16 +591,6 @@ function toReadableNodeType(node) {
584
591
  if (isJSX(node)) return `JSX ${toLowerCase(delimiterCase(replace(node.type, "JSX", ""), " "))}`;
585
592
  return toLowerCase(delimiterCase(node.type, " "));
586
593
  }
587
- var traverseUp = F.dual(2, (node, predicate) => {
588
- const { parent } = node;
589
- if (!parent || parent.type === AST_NODE_TYPES.Program) return O.none();
590
- return predicate(parent) ? O.some(parent) : traverseUp(parent, predicate);
591
- });
592
- function traverseUpStop(node, stopNode, predicate) {
593
- const { parent } = node;
594
- if (!parent || parent === stopNode || parent.type === AST_NODE_TYPES.Program) return O.none();
595
- return predicate(parent) ? O.some(parent) : traverseUpStop(parent, stopNode, predicate);
596
- }
597
594
 
598
595
  // src/unwrap-type-expression.ts
599
596
  function unwrapTypeExpression(node) {
@@ -601,4 +598,4 @@ function unwrapTypeExpression(node) {
601
598
  return node;
602
599
  }
603
600
 
604
- export { getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getIdentifiersFromBinaryExpression, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfImmediatelyInvoked, isFunctionOfObjectMethod, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMultiLine, isNodeEqual, isOneOf, isProperty, isRegExpLiteral, isStringLiteral, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, traverseUp, traverseUpGuard, traverseUpStop, unwrapTypeExpression };
601
+ export { findParentNode, findParentNodeGuard, findParentNodeStop, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getIdentifiersFromBinaryExpression, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfImmediatelyInvoked, isFunctionOfObjectMethod, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMultiLine, isNodeEqual, isOneOf, isProperty, isRegExpLiteral, isStringLiteral, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, unwrapTypeExpression };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "1.23.2-next.2",
3
+ "version": "1.23.2-next.6",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/rEl1cx/eslint-react",
6
6
  "bugs": {
@@ -33,13 +33,13 @@
33
33
  "./package.json"
34
34
  ],
35
35
  "dependencies": {
36
- "@typescript-eslint/types": "^8.19.0",
37
- "@typescript-eslint/typescript-estree": "^8.19.0",
38
- "@typescript-eslint/utils": "^8.19.0",
36
+ "@typescript-eslint/types": "^8.19.1",
37
+ "@typescript-eslint/typescript-estree": "^8.19.1",
38
+ "@typescript-eslint/utils": "^8.19.1",
39
39
  "string-ts": "^2.2.0",
40
40
  "ts-pattern": "^5.6.0",
41
- "@eslint-react/eff": "1.23.2-next.2",
42
- "@eslint-react/types": "1.23.2-next.2"
41
+ "@eslint-react/eff": "1.23.2-next.6",
42
+ "@eslint-react/types": "1.23.2-next.6"
43
43
  },
44
44
  "devDependencies": {
45
45
  "tsup": "^8.3.5",