@eslint-react/ast 5.24.10 → 5.25.0
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 +23 -5
- package/dist/index.js +9 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/types";
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/tree.d.ts
|
|
3
3
|
/** Union of function-like node types. */
|
|
4
4
|
type TSESTreeFunction = TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression;
|
|
5
5
|
/** Union of class-like node types. */
|
|
@@ -19,6 +19,8 @@ type TSESTreeDirective = TSESTree.ExpressionStatement & {
|
|
|
19
19
|
};
|
|
20
20
|
/** Union of TypeScript type expression node types. */
|
|
21
21
|
type TSESTreeTypeExpression = TSESTree.TSAsExpression | TSESTree.TSTypeAssertion | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSInstantiationExpression;
|
|
22
|
+
/** Node type `T` with TypeScript type expressions excluded — the static result shape of `Extract.unwrap`. */
|
|
23
|
+
type TSESTreeUnwrapped<T extends TSESTree.Node> = Exclude<T, TSESTreeTypeExpression | TSESTree.ChainExpression>;
|
|
22
24
|
declare namespace check_d_exports {
|
|
23
25
|
export { is, isCallExpression, isClass, isConditional, isDirective, isExpression, isFunction, isIdentifier, isJSX, isJSXElement, isJSXElementOrFragment, isJSXExpressionContainer, isJSXFragment, isJSXSpreadAttribute, isJSXTagNameExpression, isMemberExpression, isObjectExpression, isOneOf, isProperty, isPropertyOrMethod, isReturnStatement, isTypeAssertionExpression, isTypeExpression };
|
|
24
26
|
}
|
|
@@ -102,9 +104,10 @@ declare namespace extract_d_exports {
|
|
|
102
104
|
/**
|
|
103
105
|
* Recursively unwrap TypeScript type expressions and chain expressions to get the underlying expression.
|
|
104
106
|
* @param node The node to unwrap.
|
|
105
|
-
* @returns The innermost non-type-expression node.
|
|
107
|
+
* @returns The innermost non-type-expression node — a reference into the original tree, never a copy.
|
|
106
108
|
*/
|
|
107
|
-
declare function unwrap(node: TSESTree.
|
|
109
|
+
declare function unwrap(node: TSESTreeTypeExpression | TSESTree.ChainExpression): TSESTreeUnwrapped<TSESTree.Expression>;
|
|
110
|
+
declare function unwrap<T extends TSESTree.Node>(node: T): TSESTreeUnwrapped<T>;
|
|
108
111
|
/**
|
|
109
112
|
* Find a property by name in a list of object literal properties, recursing into spread object expressions.
|
|
110
113
|
* @param properties The object literal properties to search.
|
|
@@ -149,7 +152,7 @@ declare function getPropertyName(property: TSESTree.Property, effort?: "min" | "
|
|
|
149
152
|
*/
|
|
150
153
|
declare function getFullyQualifiedName(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
151
154
|
declare namespace traverse_d_exports {
|
|
152
|
-
export { findEnclosingTryBlock, findParent };
|
|
155
|
+
export { findEnclosingTryBlock, findParent, hasEnclosingTryBlock, hasParent };
|
|
153
156
|
}
|
|
154
157
|
type Predicate<T extends TSESTree.Node> = (node: TSESTree.Node) => node is T;
|
|
155
158
|
type NodePredicate = (node: TSESTree.Node) => boolean;
|
|
@@ -162,11 +165,26 @@ type NodePredicate = (node: TSESTree.Node) => boolean;
|
|
|
162
165
|
*/
|
|
163
166
|
declare function findParent<T extends TSESTree.Node>(node: TSESTree.Node | null, test: Predicate<T>, stop?: NodePredicate): T | null;
|
|
164
167
|
declare function findParent(node: TSESTree.Node | null, test: NodePredicate, stop?: NodePredicate): TSESTree.Node | null;
|
|
168
|
+
/**
|
|
169
|
+
* Check whether `node` has an ancestor matching a predicate.
|
|
170
|
+
* @param node The starting node for the upward search.
|
|
171
|
+
* @param test The predicate a candidate ancestor must satisfy.
|
|
172
|
+
* @param stop An optional predicate that aborts the search when it returns `true`.
|
|
173
|
+
* @returns `true` when a matching ancestor exists.
|
|
174
|
+
*/
|
|
175
|
+
declare function hasParent<T extends TSESTree.Node>(node: TSESTree.Node | null, test: Predicate<T>, stop?: NodePredicate): boolean;
|
|
176
|
+
declare function hasParent(node: TSESTree.Node | null, test: NodePredicate, stop?: NodePredicate): boolean;
|
|
165
177
|
/**
|
|
166
178
|
* Find the nearest `TryStatement` whose `try` block (not `catch`/`finally`) encloses the given node.
|
|
167
179
|
* @param node The node to check.
|
|
168
180
|
* @returns The enclosing `TryStatement`, or `null` when none is found.
|
|
169
181
|
*/
|
|
170
182
|
declare function findEnclosingTryBlock(node: TSESTree.Node): TSESTree.TryStatement | null;
|
|
183
|
+
/**
|
|
184
|
+
* Check whether the given node is enclosed by the `try` block (not `catch`/`finally`) of a `TryStatement`.
|
|
185
|
+
* @param node The node to check.
|
|
186
|
+
* @returns `true` when an enclosing `try` block exists.
|
|
187
|
+
*/
|
|
188
|
+
declare function hasEnclosingTryBlock(node: TSESTree.Node): boolean;
|
|
171
189
|
//#endregion
|
|
172
|
-
export { check_d_exports as Check, compare_d_exports as Compare, extract_d_exports as Extract, type TSESTreeClass, type TSESTreeDirective, type TSESTreeFunction, type TSESTreeJSX, type TSESTreeJSXAttributeLike, type TSESTreeJSXElementLike, type TSESTreeMethodOrPropertyDefinition, type TSESTreeTypeExpression, traverse_d_exports as Traverse };
|
|
190
|
+
export { check_d_exports as Check, compare_d_exports as Compare, extract_d_exports as Extract, type TSESTreeClass, type TSESTreeDirective, type TSESTreeFunction, type TSESTreeJSX, type TSESTreeJSXAttributeLike, type TSESTreeJSXElementLike, type TSESTreeMethodOrPropertyDefinition, type TSESTreeTypeExpression, type TSESTreeUnwrapped, traverse_d_exports as Traverse };
|
package/dist/index.js
CHANGED
|
@@ -371,7 +371,9 @@ const isEqual = dual(2, (a, b) => {
|
|
|
371
371
|
//#region src/traverse.ts
|
|
372
372
|
var traverse_exports = /* @__PURE__ */ __exportAll({
|
|
373
373
|
findEnclosingTryBlock: () => findEnclosingTryBlock,
|
|
374
|
-
findParent: () => findParent
|
|
374
|
+
findParent: () => findParent,
|
|
375
|
+
hasEnclosingTryBlock: () => hasEnclosingTryBlock,
|
|
376
|
+
hasParent: () => hasParent
|
|
375
377
|
});
|
|
376
378
|
function findParent(node, test, stop) {
|
|
377
379
|
if (node == null) return null;
|
|
@@ -384,11 +386,17 @@ function findParent(node, test, stop) {
|
|
|
384
386
|
}
|
|
385
387
|
return null;
|
|
386
388
|
}
|
|
389
|
+
function hasParent(node, test, stop) {
|
|
390
|
+
return findParent(node, test, stop) != null;
|
|
391
|
+
}
|
|
387
392
|
function findEnclosingTryBlock(node) {
|
|
388
393
|
const parent = node.parent;
|
|
389
394
|
if (parent == null || parent.type === AST_NODE_TYPES.Program) return null;
|
|
390
395
|
if (parent.type === AST_NODE_TYPES.TryStatement && node === parent.block) return parent;
|
|
391
396
|
return findEnclosingTryBlock(parent);
|
|
392
397
|
}
|
|
398
|
+
function hasEnclosingTryBlock(node) {
|
|
399
|
+
return findEnclosingTryBlock(node) != null;
|
|
400
|
+
}
|
|
393
401
|
//#endregion
|
|
394
402
|
export { check_exports as Check, compare_exports as Compare, extract_exports as Extract, traverse_exports as Traverse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.25.0",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@local/eff": "0.0.0",
|
|
39
39
|
"@local/testkit": "0.0.0",
|
|
40
40
|
"eslint": "^10.12.0",
|
|
41
|
-
"tsdown": "^0.23.
|
|
41
|
+
"tsdown": "^0.23.1",
|
|
42
42
|
"typescript": "6.0.3",
|
|
43
43
|
"vitest": "^5.0.3"
|
|
44
44
|
},
|