@eslint-react/ast 2.0.0-next.20 → 2.0.0-next.200
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.ts +189 -204
- package/dist/index.js +591 -551
- package/package.json +8 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/types";
|
|
2
|
+
import { unit } from "@eslint-react/eff";
|
|
3
|
+
import { TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
|
|
4
4
|
|
|
5
|
+
//#region src/array-index.d.ts
|
|
6
|
+
declare function getArrayMethodCallbackIndexParamPosition(methodName: string): number;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/array-method.d.ts
|
|
5
9
|
declare function isArrayFromCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
6
10
|
declare function isArrayMapCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/node-equal.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* Determines whether node equals to another node
|
|
15
|
+
* @param a node to compare
|
|
16
|
+
* @param b node to compare
|
|
17
|
+
* @returns `true` if node equal
|
|
18
|
+
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
19
|
+
*/
|
|
20
|
+
declare const isNodeEqual: {
|
|
21
|
+
(a: TSESTree.Node): (b: TSESTree.Node) => boolean;
|
|
22
|
+
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/node-format.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
declare function toDelimiterFormat(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
|
|
30
|
+
/**
|
|
31
|
+
* Incomplete but sufficient stringification of AST nodes for common use cases
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
declare function toStringFormat(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/node-is.d.ts
|
|
38
|
+
declare const is: <NodeType extends TSESTree.AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
39
|
+
type: NodeType;
|
|
40
|
+
}>;
|
|
41
|
+
declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
42
|
+
type: NodeTypes[number];
|
|
43
|
+
}>;
|
|
44
|
+
declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
|
|
45
|
+
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;
|
|
46
|
+
declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
|
|
47
|
+
declare const isMethodOrProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
|
|
48
|
+
declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
|
|
49
|
+
declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
|
|
50
|
+
declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
|
|
51
|
+
declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
|
|
52
|
+
declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXAttribute | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXElement | TSESTree.JSXEmptyExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXFragment | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXText;
|
|
53
|
+
declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
|
|
54
|
+
declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
55
|
+
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/node-types.d.ts
|
|
10
58
|
type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
|
|
11
59
|
type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
|
|
12
60
|
type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
|
|
@@ -15,149 +63,36 @@ type TSESTreeLoop = TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TS
|
|
|
15
63
|
type TSESTreeArrayTupleType = TSESTree$1.TSArrayType | TSESTree$1.TSTupleType;
|
|
16
64
|
type TSESTreeProperty = TSESTree$1.PropertyDefinition | TSESTree$1.TSIndexSignature | TSESTree$1.TSParameterProperty | TSESTree$1.TSPropertySignature;
|
|
17
65
|
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;
|
|
66
|
+
type TSESTreeJSXAttributeLike = TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute;
|
|
18
67
|
type TSESTreeDestructuringPattern = TSESTree$1.ArrayPattern | TSESTree$1.AssignmentPattern | TSESTree$1.ObjectPattern | TSESTree$1.RestElement;
|
|
19
68
|
type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
|
|
20
69
|
type TSESTreeTypeExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion | TSESTree$1.TSInstantiationExpression;
|
|
21
70
|
type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* @param node - The node to get the expression from
|
|
28
|
-
* @returns The inner expression
|
|
29
|
-
*/
|
|
30
|
-
declare function getJSExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
|
|
31
|
-
declare function isThisExpression(node: TSESTree.Expression): boolean;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Gets the static name of a function AST node. For function declarations it is
|
|
35
|
-
* easy. For anonymous function expressions it is much harder. If you search for
|
|
36
|
-
* `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places
|
|
37
|
-
* where JS gives anonymous function expressions names. We roughly detect the
|
|
38
|
-
* same AST nodes with some exceptions to better fit our use case.
|
|
39
|
-
*/
|
|
40
|
-
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | _;
|
|
41
|
-
|
|
42
|
-
type FunctionInitPath =
|
|
43
|
-
/**
|
|
44
|
-
* function Comp() { return <div />; }
|
|
45
|
-
*/
|
|
46
|
-
readonly [TSESTree.FunctionDeclaration]
|
|
47
|
-
/**
|
|
48
|
-
* const Comp = () => <div />;
|
|
49
|
-
* const Comp = function () { return <div />; };
|
|
50
|
-
*/
|
|
51
|
-
| readonly [
|
|
52
|
-
TSESTree.VariableDeclaration,
|
|
53
|
-
TSESTree.VariableDeclarator,
|
|
54
|
-
TSESTreeFunction
|
|
55
|
-
]
|
|
56
|
-
/**
|
|
57
|
-
* const Comp = React.memo(() => <div />);
|
|
58
|
-
* const Comp = React.forwardRef(() => <div />);
|
|
59
|
-
*/
|
|
60
|
-
| readonly [
|
|
61
|
-
TSESTree.VariableDeclaration,
|
|
62
|
-
TSESTree.VariableDeclarator,
|
|
63
|
-
TSESTree.CallExpression,
|
|
64
|
-
TSESTreeFunction
|
|
65
|
-
]
|
|
66
|
-
/**
|
|
67
|
-
* const Comp = React.memo(React.forwardRef(() => <div />));
|
|
68
|
-
*/
|
|
69
|
-
| readonly [
|
|
70
|
-
TSESTree.VariableDeclaration,
|
|
71
|
-
TSESTree.VariableDeclarator,
|
|
72
|
-
TSESTree.CallExpression,
|
|
73
|
-
TSESTree.CallExpression,
|
|
74
|
-
TSESTreeFunction
|
|
75
|
-
]
|
|
76
|
-
/**
|
|
77
|
-
* const Comps = {
|
|
78
|
-
* TopNav() { return <div />; },
|
|
79
|
-
* SidPanel: () => <div />,
|
|
80
|
-
* }
|
|
81
|
-
*/
|
|
82
|
-
| readonly [
|
|
83
|
-
TSESTree.VariableDeclaration,
|
|
84
|
-
TSESTree.VariableDeclarator,
|
|
85
|
-
TSESTree.ObjectExpression,
|
|
86
|
-
TSESTree.Property,
|
|
87
|
-
TSESTreeFunction
|
|
88
|
-
]
|
|
89
|
-
/**
|
|
90
|
-
* const Comps = {
|
|
91
|
-
* TopNav: React.memo(() => <div />),
|
|
92
|
-
* SidPanel: React.forwardRef(() => <div />),
|
|
93
|
-
* }
|
|
94
|
-
*/
|
|
95
|
-
| readonly [
|
|
96
|
-
TSESTree.VariableDeclaration,
|
|
97
|
-
TSESTree.VariableDeclarator,
|
|
98
|
-
TSESTree.ObjectExpression,
|
|
99
|
-
TSESTree.Property,
|
|
100
|
-
TSESTree.CallExpression,
|
|
101
|
-
TSESTreeFunction
|
|
102
|
-
]
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/class-id.d.ts
|
|
73
|
+
declare function getClassId(node: TSESTreeClass): TSESTree.Identifier | unit;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/expression-base.d.ts
|
|
103
76
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
77
|
+
* Unwraps any type expressions to get the underlying JavaScript expression node.
|
|
78
|
+
* Recursively processes nodes until a non-type expression is found.
|
|
79
|
+
*
|
|
80
|
+
* @param node - The AST node to unwrap
|
|
81
|
+
* @returns The underlying JavaScript expression node
|
|
108
82
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
TSESTree.ObjectExpression,
|
|
113
|
-
TSESTree.Property,
|
|
114
|
-
TSESTree.CallExpression,
|
|
115
|
-
TSESTree.CallExpression,
|
|
116
|
-
TSESTreeFunction
|
|
117
|
-
]
|
|
83
|
+
declare function getUnderlyingExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/expression-is.d.ts
|
|
118
86
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
87
|
+
* Checks if the given expression is a 'this' expression.
|
|
88
|
+
* Unwraps any type expressions before checking.
|
|
89
|
+
*
|
|
90
|
+
* @param node - The expression node to check
|
|
91
|
+
* @returns true if the expression is a ThisExpression, false otherwise
|
|
122
92
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
TSESTree.MethodDefinition,
|
|
127
|
-
TSESTreeFunction
|
|
128
|
-
]
|
|
129
|
-
/**
|
|
130
|
-
* class Comp {
|
|
131
|
-
* TopNav = () => <div />;
|
|
132
|
-
* }
|
|
133
|
-
*/
|
|
134
|
-
| readonly [
|
|
135
|
-
TSESTree.ClassDeclaration,
|
|
136
|
-
TSESTree.ClassBody,
|
|
137
|
-
TSESTree.PropertyDefinition,
|
|
138
|
-
TSESTreeFunction
|
|
139
|
-
];
|
|
140
|
-
declare function getFunctionInitPath(node: TSESTreeFunction): FunctionInitPath | _;
|
|
141
|
-
declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
142
|
-
|
|
143
|
-
declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
144
|
-
declare function isImmediatelyInvokedFunction(node: TSESTreeFunction): boolean;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Find the parent node that satisfies the test function
|
|
148
|
-
* @param node The AST node
|
|
149
|
-
* @param test The test function
|
|
150
|
-
* @returns The parent node that satisfies the test function or `_` if not found
|
|
151
|
-
*/
|
|
152
|
-
declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | _, test: (n: TSESTree.Node) => n is A): A | _;
|
|
153
|
-
/**
|
|
154
|
-
* Find the parent node that satisfies the test function or `_` if not found
|
|
155
|
-
* @param node The AST node
|
|
156
|
-
* @param test The test function
|
|
157
|
-
* @returns The parent node that satisfies the test function
|
|
158
|
-
*/
|
|
159
|
-
declare function findParentNode(node: TSESTree.Node | _, test: (node: TSESTree.Node) => boolean): TSESTree.Node | _;
|
|
160
|
-
|
|
93
|
+
declare function isThisExpression(node: TSESTree.Expression): boolean;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/expression-nested.d.ts
|
|
161
96
|
/**
|
|
162
97
|
* Get all nested identifiers in a expression like node
|
|
163
98
|
* @param node The node to get the nested identifiers from
|
|
@@ -177,7 +112,7 @@ declare function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTr
|
|
|
177
112
|
* node, and it will return an array of all nested expressions of type T.
|
|
178
113
|
*/
|
|
179
114
|
declare function getNestedExpressionsOfType<TNodeType extends AST_NODE_TYPES>(type: TNodeType): (node: TSESTree.Node) => Extract<TSESTree.Node, {
|
|
180
|
-
|
|
115
|
+
type: TNodeType;
|
|
181
116
|
}>[];
|
|
182
117
|
/**
|
|
183
118
|
* Get all nested new expressions in an expression like node
|
|
@@ -191,91 +126,141 @@ declare const getNestedNewExpressions: (node: TSESTree.Node) => TSESTree.NewExpr
|
|
|
191
126
|
* @returns All nested call expressions
|
|
192
127
|
*/
|
|
193
128
|
declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallExpression[];
|
|
194
|
-
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/function-id.d.ts
|
|
195
131
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
132
|
+
* Gets the static name of a function AST node. For function declarations it is
|
|
133
|
+
* easy. For anonymous function expressions it is much harder. If you search for
|
|
134
|
+
* `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places
|
|
135
|
+
* where JS gives anonymous function expressions names. We roughly detect the
|
|
136
|
+
* same AST nodes with some exceptions to better fit our use case.
|
|
199
137
|
*/
|
|
200
|
-
declare function
|
|
138
|
+
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | unit;
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/function-init-path.d.ts
|
|
201
141
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* @returns boolean
|
|
142
|
+
* Represents various AST paths for React component function declarations.
|
|
143
|
+
* Each tuple type represents a specific component definition pattern.
|
|
205
144
|
*/
|
|
206
|
-
|
|
207
|
-
|
|
145
|
+
type FunctionInitPath = readonly [TSESTree.FunctionDeclaration] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.ClassDeclaration, TSESTree.ClassBody, TSESTree.MethodDefinition, TSESTreeFunction] | readonly [TSESTree.ClassDeclaration, TSESTree.ClassBody, TSESTree.PropertyDefinition, TSESTreeFunction];
|
|
146
|
+
/**
|
|
147
|
+
* Identifies the initialization path of a function node in the AST.
|
|
148
|
+
* Determines what kind of component declaration pattern the function belongs to.
|
|
149
|
+
*
|
|
150
|
+
* @param node - The function node to analyze
|
|
151
|
+
* @returns The function initialization path or unit if not identifiable
|
|
152
|
+
*/
|
|
153
|
+
declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
|
|
154
|
+
/**
|
|
155
|
+
* Checks if a specific function call exists in the function initialization path.
|
|
156
|
+
* Useful for detecting HOCs like React.memo, React.forwardRef, etc.
|
|
157
|
+
*
|
|
158
|
+
* @param callName - The name of the call to check for (e.g., "memo", "forwardRef")
|
|
159
|
+
* @param initPath - The function initialization path to search in
|
|
160
|
+
* @returns True if the call exists in the path, false otherwise
|
|
161
|
+
*/
|
|
162
|
+
declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/function-is.d.ts
|
|
165
|
+
declare function isFunctionEmpty(node: TSESTreeFunction): boolean;
|
|
166
|
+
declare function isFunctionImmediatelyInvoked(node: TSESTreeFunction): boolean;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/literal.d.ts
|
|
208
169
|
declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
|
|
209
170
|
declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
|
|
210
171
|
declare function isLiteral(node: TSESTree.Node, type: "null"): node is TSESTree.NullLiteral;
|
|
211
172
|
declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTree.NumberLiteral;
|
|
212
173
|
declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
|
|
213
174
|
declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* Determines whether node equals to another node
|
|
217
|
-
* @param a node to compare
|
|
218
|
-
* @param b node to compare
|
|
219
|
-
* @returns `true` if node equal
|
|
220
|
-
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
221
|
-
*/
|
|
222
|
-
declare const isNodeEqual: {
|
|
223
|
-
(a: TSESTree.Node): (b: TSESTree.Node) => boolean;
|
|
224
|
-
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
225
|
-
};
|
|
226
|
-
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/misc.d.ts
|
|
227
177
|
/**
|
|
228
|
-
*
|
|
178
|
+
* Check if a node is multiline
|
|
179
|
+
* @param node The AST node to check
|
|
180
|
+
* @returns `true` if the node is multiline
|
|
229
181
|
*/
|
|
230
|
-
declare function
|
|
182
|
+
declare function isMultiLine(node: TSESTree.Node): boolean;
|
|
231
183
|
/**
|
|
232
|
-
*
|
|
184
|
+
* Check if a node is a line break
|
|
185
|
+
* @param node The AST node to check
|
|
186
|
+
* @returns boolean
|
|
233
187
|
*/
|
|
234
|
-
declare function
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
declare const
|
|
255
|
-
declare const
|
|
256
|
-
declare const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
260
|
-
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
261
|
-
|
|
188
|
+
declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/node-selectors.d.ts
|
|
191
|
+
type ImplicitReturnArrowFunctionExpression = TSESTree$1.ArrowFunctionExpression & {
|
|
192
|
+
body: TSESTree$1.Expression;
|
|
193
|
+
};
|
|
194
|
+
type ObjectDestructuringVariableDeclarator = TSESTree$1.VariableDeclarator & {
|
|
195
|
+
id: TSESTree$1.ObjectPattern;
|
|
196
|
+
init: TSESTree$1.Identifier;
|
|
197
|
+
};
|
|
198
|
+
type DisplayNameAssignmentExpression = TSESTree$1.AssignmentExpression & {
|
|
199
|
+
type: "AssignmentExpression";
|
|
200
|
+
left: TSESTree$1.MemberExpression & {
|
|
201
|
+
property: TSESTree$1.Identifier & {
|
|
202
|
+
name: "displayName";
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
operator: "=";
|
|
206
|
+
right: TSESTree$1.Literal;
|
|
207
|
+
};
|
|
208
|
+
declare const SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
|
|
209
|
+
declare const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: string;
|
|
210
|
+
declare const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION: string;
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/process-env-node-env.d.ts
|
|
262
213
|
/**
|
|
263
214
|
* Check if the given node is a member expression that accesses `process.env.NODE_ENV`
|
|
264
215
|
* @param node The AST node
|
|
265
216
|
* @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
|
|
266
217
|
*/
|
|
267
|
-
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null |
|
|
218
|
+
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
|
|
268
219
|
/**
|
|
269
|
-
* Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
|
|
220
|
+
* Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal.
|
|
270
221
|
* @param node The AST node
|
|
271
222
|
* @param operator The operator used in the comparison
|
|
272
223
|
* @param value The string literal value to compare against
|
|
273
224
|
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
274
225
|
*/
|
|
275
|
-
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null |
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
226
|
+
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/promise-then.d.ts
|
|
279
229
|
declare function isThenCall(node: TSESTree.CallExpression): boolean;
|
|
280
|
-
|
|
281
|
-
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/property-name.d.ts
|
|
232
|
+
declare function getPropertyName(node: TSESTree.Node): string | unit;
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/traverse-up.d.ts
|
|
235
|
+
/**
|
|
236
|
+
* Find the parent node that satisfies the test function
|
|
237
|
+
* @param node The AST node
|
|
238
|
+
* @param test The test function
|
|
239
|
+
* @returns The parent node that satisfies the test function or `_` if not found
|
|
240
|
+
*/
|
|
241
|
+
declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | unit, test: (n: TSESTree.Node) => n is A): A | unit;
|
|
242
|
+
/**
|
|
243
|
+
* Find the parent node that satisfies the test function or `_` if not found
|
|
244
|
+
* @param node The AST node
|
|
245
|
+
* @param test The test function
|
|
246
|
+
* @returns The parent node that satisfies the test function
|
|
247
|
+
*/
|
|
248
|
+
declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/vitest-mock.d.ts
|
|
251
|
+
/**
|
|
252
|
+
* Checks if the given node is a `vi.mock`.
|
|
253
|
+
* @param node The node to check
|
|
254
|
+
* @returns `true` if the node is a `vi.mock`, otherwise `false`.
|
|
255
|
+
* @internal
|
|
256
|
+
*/
|
|
257
|
+
declare function isViMock(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
|
|
258
|
+
/**
|
|
259
|
+
* Checks if the given node is a `vi.mock` callback.
|
|
260
|
+
* @param node The node to check
|
|
261
|
+
* @returns `true` if the node is a `vi.mock` callback, otherwise `false`.
|
|
262
|
+
* @internal
|
|
263
|
+
*/
|
|
264
|
+
declare function isViMockCallback(node: TSESTree.Node | null | unit): boolean;
|
|
265
|
+
//#endregion
|
|
266
|
+
export { DisplayNameAssignmentExpression, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParentNode, getArrayMethodCallbackIndexParamPosition, getClassId, getFunctionId, getFunctionInitPath, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isClass, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThenCall, isThisExpression, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback, toDelimiterFormat, toStringFormat };
|