@eslint-react/ast 2.0.0-next.1 → 2.0.0-next.10

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
@@ -7,6 +7,8 @@ declare function isArrayMapCall(node: TSESTree.Node, loose?: boolean): node is T
7
7
 
8
8
  declare function getArrayMethodCallbackIndexParamPosition(methodName: string): number;
9
9
 
10
+ declare function getArrayPatternElementNameAt(node: TSESTree.Identifier, at: number): string | true | undefined;
11
+
10
12
  type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
11
13
  type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
12
14
  type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
@@ -147,6 +149,7 @@ declare function getFunctionInitPath(node: TSESTreeFunction): FunctionInitPath |
147
149
  declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
148
150
 
149
151
  declare function isEmptyFunction(node: TSESTreeFunction): boolean;
152
+ declare function isImmediatelyInvokedFunction(node: TSESTreeFunction): boolean;
150
153
 
151
154
  /**
152
155
  * Find the parent node that satisfies the test function
@@ -272,6 +275,8 @@ declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | _, oper
272
275
 
273
276
  declare function getPropertyName(node: TSESTree.Node): string | _;
274
277
 
278
+ declare function isThenCall(node: TSESTree.CallExpression): boolean;
279
+
275
280
  declare function toDelimiterCaseType(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
276
281
  /**
277
282
  * Returns human readable node name for given AST node
@@ -281,4 +286,4 @@ declare function toDelimiterCaseType(node: TSESTree.Node, delimiter?: string): "
281
286
  */
282
287
  declare function toString(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
283
288
 
284
- export { type FunctionInitPath, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeMethodOrProperty, type TSESTreeProperty, type TSESTreeTypeAssertionExpression, type TSESTreeTypeDeclaration, type TSESTreeTypeExpression, findParentNode, getArrayMethodCallbackIndexParamPosition, getClassId, getFunctionId, getFunctionInitPath, getJSExpression, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toDelimiterCaseType, toString };
289
+ export { type FunctionInitPath, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeMethodOrProperty, type TSESTreeProperty, type TSESTreeTypeAssertionExpression, type TSESTreeTypeDeclaration, type TSESTreeTypeExpression, findParentNode, getArrayMethodCallbackIndexParamPosition, getArrayPatternElementNameAt, getClassId, getFunctionId, getFunctionInitPath, getJSExpression, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isImmediatelyInvokedFunction, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThenCall, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toDelimiterCaseType, toString };
package/dist/index.js CHANGED
@@ -38,6 +38,13 @@ var indexParamPosition = /* @__PURE__ */ new Map([
38
38
  function getArrayMethodCallbackIndexParamPosition(methodName) {
39
39
  return indexParamPosition.get(methodName) ?? -1;
40
40
  }
41
+ function getArrayPatternElementNameAt(node, at) {
42
+ const { parent } = node;
43
+ if (!("id" in parent) || parent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
44
+ const element = parent.id.elements[at];
45
+ if (element?.type !== AST_NODE_TYPES.Identifier) return _;
46
+ return element.name;
47
+ }
41
48
  function getClassId(node) {
42
49
  if (node.id != null) return node.id;
43
50
  if (node.parent.type === AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES.Identifier) {
@@ -271,6 +278,9 @@ function hasCallInFunctionInitPath(callName, initPath) {
271
278
  function isEmptyFunction(node) {
272
279
  return node.body.type === AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
273
280
  }
281
+ function isImmediatelyInvokedFunction(node) {
282
+ return node.type !== AST_NODE_TYPES.FunctionDeclaration && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
283
+ }
274
284
  function findParentNode(node, test) {
275
285
  if (node == null) return _;
276
286
  let parent = node.parent;
@@ -550,6 +560,9 @@ function getPropertyName(node) {
550
560
  }
551
561
  return _;
552
562
  }
563
+ function isThenCall(node) {
564
+ return node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "then";
565
+ }
553
566
  function getLiteralValueType(input) {
554
567
  if (input === null) return "null";
555
568
  return typeof input;
@@ -586,4 +599,4 @@ function toString(node, getText) {
586
599
  }
587
600
  }
588
601
 
589
- export { findParentNode, getArrayMethodCallbackIndexParamPosition, getClassId, getFunctionId, getFunctionInitPath, getJSExpression, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toDelimiterCaseType, toString };
602
+ export { findParentNode, getArrayMethodCallbackIndexParamPosition, getArrayPatternElementNameAt, getClassId, getFunctionId, getFunctionInitPath, getJSExpression, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isImmediatelyInvokedFunction, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThenCall, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toDelimiterCaseType, toString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0-next.10",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -27,12 +27,12 @@
27
27
  "./package.json"
28
28
  ],
29
29
  "dependencies": {
30
- "@typescript-eslint/types": "^8.30.1",
31
- "@typescript-eslint/typescript-estree": "^8.30.1",
32
- "@typescript-eslint/utils": "^8.30.1",
30
+ "@typescript-eslint/types": "^8.31.1",
31
+ "@typescript-eslint/typescript-estree": "^8.31.1",
32
+ "@typescript-eslint/utils": "^8.31.1",
33
33
  "string-ts": "^2.2.1",
34
34
  "ts-pattern": "^5.7.0",
35
- "@eslint-react/eff": "2.0.0-next.1"
35
+ "@eslint-react/eff": "2.0.0-next.10"
36
36
  },
37
37
  "devDependencies": {
38
38
  "tsup": "^8.4.0",