@eslint-react/ast 5.18.0 → 5.18.2

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 CHANGED
@@ -132,7 +132,7 @@ declare function getFullyQualifiedName(node: TSESTree.Node, getText: (node: TSES
132
132
  */
133
133
  declare function getIdentifierAt(node: TSESTree.Expression | TSESTree.PrivateIdentifier, position: number): TSESTree.Identifier | null;
134
134
  declare namespace traverse_d_exports {
135
- export { findParent };
135
+ export { findEnclosingTryBlock, findParent };
136
136
  }
137
137
  type Predicate<T extends TSESTree.Node> = (node: TSESTree.Node) => node is T;
138
138
  type NodePredicate = (node: TSESTree.Node) => boolean;
@@ -145,5 +145,11 @@ type NodePredicate = (node: TSESTree.Node) => boolean;
145
145
  */
146
146
  declare function findParent<T extends TSESTree.Node>(node: TSESTree.Node | null, test: Predicate<T>, stop?: NodePredicate): T | null;
147
147
  declare function findParent(node: TSESTree.Node | null, test: NodePredicate, stop?: NodePredicate): TSESTree.Node | null;
148
+ /**
149
+ * Finds the nearest TryStatement whose `try` block (not catch/finally) encloses the given node.
150
+ * @param node The node to check.
151
+ * @returns The enclosing TryStatement, or null if none is found.
152
+ */
153
+ declare function findEnclosingTryBlock(node: TSESTree.Node): TSESTree.TryStatement | null;
148
154
  //#endregion
149
155
  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 };
package/dist/index.js CHANGED
@@ -796,7 +796,10 @@ const isEqual = dual(2, (a, b) => {
796
796
 
797
797
  //#endregion
798
798
  //#region src/traverse.ts
799
- var traverse_exports = /* @__PURE__ */ __exportAll({ findParent: () => findParent });
799
+ var traverse_exports = /* @__PURE__ */ __exportAll({
800
+ findEnclosingTryBlock: () => findEnclosingTryBlock,
801
+ findParent: () => findParent
802
+ });
800
803
  function findParent(node, test, stop) {
801
804
  if (node == null) return null;
802
805
  let current = node.parent;
@@ -808,6 +811,17 @@ function findParent(node, test, stop) {
808
811
  }
809
812
  return null;
810
813
  }
814
+ /**
815
+ * Finds the nearest TryStatement whose `try` block (not catch/finally) encloses the given node.
816
+ * @param node The node to check.
817
+ * @returns The enclosing TryStatement, or null if none is found.
818
+ */
819
+ function findEnclosingTryBlock(node) {
820
+ const parent = node.parent;
821
+ if (parent == null || parent.type === AST_NODE_TYPES.Program) return null;
822
+ if (parent.type === AST_NODE_TYPES.TryStatement && node === parent.block) return parent;
823
+ return findEnclosingTryBlock(parent);
824
+ }
811
825
 
812
826
  //#endregion
813
827
  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.18.0",
3
+ "version": "5.18.2",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -36,13 +36,13 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@typescript-eslint/parser": "^8.65.0",
39
- "eslint": "^10.7.0",
40
- "tsdown": "^0.22.13",
39
+ "eslint": "^10.8.0",
40
+ "tsdown": "^0.22.14",
41
41
  "typescript": "6.0.3",
42
42
  "vitest": "^4.1.10",
43
43
  "@local/eff": "0.0.0",
44
- "@local/configs": "0.0.0",
45
- "@local/testkit": "0.0.0"
44
+ "@local/testkit": "0.0.0",
45
+ "@local/configs": "0.0.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "eslint": "*",