@eslint-react/ast 1.43.2-next.2 → 1.45.0-beta.3

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
@@ -265,6 +265,22 @@ declare const isNodeEqual: {
265
265
  (a: TSESTree.Node, b: TSESTree.Node): boolean;
266
266
  };
267
267
 
268
+ /**
269
+ * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
270
+ * @param node The AST node
271
+ * @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
272
+ */
273
+ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | _): node is TSESTree.MemberExpression;
274
+
275
+ /**
276
+ * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
277
+ * @param node The AST node
278
+ * @param operator The operator used in the comparison
279
+ * @param value The string literal value to compare against
280
+ * @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
281
+ */
282
+ declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | _, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
283
+
268
284
  declare function isThisExpression(node: TSESTree.Expression): boolean;
269
285
 
270
286
  /**
@@ -283,4 +299,4 @@ declare function toReadableNodeName(node: TSESTree.Node, getText: (node: TSESTre
283
299
  declare function toReadableNodeType(node: TSESTree.Node): "property" | "RegExp literal" | "string literal" | "number literal" | "bigint literal" | "boolean literal" | "symbol literal" | "undefined literal" | "object literal" | "function literal" | "null 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";
284
300
  type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
285
301
 
286
- export { type FunctionInitPath, type ReadableNodeType, 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, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, 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, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType };
302
+ export { type FunctionInitPath, type ReadableNodeType, 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, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, 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, toReadableNodeName, toReadableNodeType };
package/dist/index.d.ts CHANGED
@@ -265,6 +265,22 @@ declare const isNodeEqual: {
265
265
  (a: TSESTree.Node, b: TSESTree.Node): boolean;
266
266
  };
267
267
 
268
+ /**
269
+ * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
270
+ * @param node The AST node
271
+ * @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
272
+ */
273
+ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | _): node is TSESTree.MemberExpression;
274
+
275
+ /**
276
+ * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
277
+ * @param node The AST node
278
+ * @param operator The operator used in the comparison
279
+ * @param value The string literal value to compare against
280
+ * @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
281
+ */
282
+ declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | _, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
283
+
268
284
  declare function isThisExpression(node: TSESTree.Expression): boolean;
269
285
 
270
286
  /**
@@ -283,4 +299,4 @@ declare function toReadableNodeName(node: TSESTree.Node, getText: (node: TSESTre
283
299
  declare function toReadableNodeType(node: TSESTree.Node): "property" | "RegExp literal" | "string literal" | "number literal" | "bigint literal" | "boolean literal" | "symbol literal" | "undefined literal" | "object literal" | "function literal" | "null 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";
284
300
  type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
285
301
 
286
- export { type FunctionInitPath, type ReadableNodeType, 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, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, 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, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType };
302
+ export { type FunctionInitPath, type ReadableNodeType, 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, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, 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, toReadableNodeName, toReadableNodeType };
package/dist/index.js CHANGED
@@ -555,6 +555,21 @@ var isNodeEqual = eff.dual(2, (a, b) => {
555
555
  return false;
556
556
  }
557
557
  });
558
+ function isProcessEnvNodeEnv(node) {
559
+ return node != null && node.type === types.AST_NODE_TYPES.MemberExpression && node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === types.AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === "NODE_ENV";
560
+ }
561
+ function isProcessEnvNodeEnvCompare(node, operator, value) {
562
+ if (node == null) return false;
563
+ if (node.type !== types.AST_NODE_TYPES.BinaryExpression) return false;
564
+ if (node.operator !== operator) return false;
565
+ if (isProcessEnvNodeEnv(node.left) && isLiteral(node.right, "string")) {
566
+ return node.right.value === value;
567
+ }
568
+ if (isLiteral(node.left, "string") && isProcessEnvNodeEnv(node.right)) {
569
+ return node.left.value === value;
570
+ }
571
+ return false;
572
+ }
558
573
  function isThisExpression(node) {
559
574
  return getEcmaExpression(node).type === types.AST_NODE_TYPES.ThisExpression;
560
575
  }
@@ -633,6 +648,8 @@ exports.isMethodOrProperty = isMethodOrProperty;
633
648
  exports.isMultiLine = isMultiLine;
634
649
  exports.isNodeEqual = isNodeEqual;
635
650
  exports.isOneOf = isOneOf;
651
+ exports.isProcessEnvNodeEnv = isProcessEnvNodeEnv;
652
+ exports.isProcessEnvNodeEnvCompare = isProcessEnvNodeEnvCompare;
636
653
  exports.isProperty = isProperty;
637
654
  exports.isThisExpression = isThisExpression;
638
655
  exports.isTypeAssertionExpression = isTypeAssertionExpression;
package/dist/index.mjs CHANGED
@@ -553,6 +553,21 @@ var isNodeEqual = dual(2, (a, b) => {
553
553
  return false;
554
554
  }
555
555
  });
556
+ function isProcessEnvNodeEnv(node) {
557
+ return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === "NODE_ENV";
558
+ }
559
+ function isProcessEnvNodeEnvCompare(node, operator, value) {
560
+ if (node == null) return false;
561
+ if (node.type !== AST_NODE_TYPES.BinaryExpression) return false;
562
+ if (node.operator !== operator) return false;
563
+ if (isProcessEnvNodeEnv(node.left) && isLiteral(node.right, "string")) {
564
+ return node.right.value === value;
565
+ }
566
+ if (isLiteral(node.left, "string") && isProcessEnvNodeEnv(node.right)) {
567
+ return node.left.value === value;
568
+ }
569
+ return false;
570
+ }
556
571
  function isThisExpression(node) {
557
572
  return getEcmaExpression(node).type === AST_NODE_TYPES.ThisExpression;
558
573
  }
@@ -592,4 +607,4 @@ function toReadableNodeType(node) {
592
607
  return toLowerCase(delimiterCase(node.type, " "));
593
608
  }
594
609
 
595
- export { findParentNode, getArrayMethodCallbackIndexParamPosition, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, 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, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType };
610
+ export { findParentNode, getArrayMethodCallbackIndexParamPosition, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, 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, toReadableNodeName, toReadableNodeType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "1.43.2-next.2",
3
+ "version": "1.45.0-beta.3",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -40,7 +40,7 @@
40
40
  "@typescript-eslint/utils": "^8.29.1",
41
41
  "string-ts": "^2.2.1",
42
42
  "ts-pattern": "^5.7.0",
43
- "@eslint-react/eff": "1.43.2-next.2"
43
+ "@eslint-react/eff": "1.45.0-beta.3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsup": "^8.4.0",