@eslint-react/ast 1.28.1-beta.4 → 1.28.1-beta.7

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.js CHANGED
@@ -4,7 +4,6 @@ var eff = require('@eslint-react/eff');
4
4
  var types = require('@typescript-eslint/types');
5
5
  var utils = require('@typescript-eslint/utils');
6
6
  var typescriptEstree = require('@typescript-eslint/typescript-estree');
7
- var tsPattern = require('ts-pattern');
8
7
  var stringTs = require('string-ts');
9
8
 
10
9
  // src/find-parent-node.ts
@@ -266,7 +265,7 @@ function getFunctionIdentifier(node) {
266
265
  return node.parent.key;
267
266
  // class {MaybeComponent = () => {}}
268
267
  // class {MaybeComponent() {}}
269
- case (isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node.parent) && node.parent.value === node && node.parent.key.type === types.AST_NODE_TYPES.Identifier):
268
+ case (isMethodOrProperty(node.parent) && node.parent.value === node && node.parent.key.type === types.AST_NODE_TYPES.Identifier):
270
269
  return node.parent.key;
271
270
  // Follow spec convention for `IsAnonymousFunctionDefinition()` usage.
272
271
  //
@@ -371,8 +370,7 @@ function getNestedExpressionsOfType(type) {
371
370
  return expressions;
372
371
  };
373
372
  }
374
-
375
- // src/get-nested-call-expressions.ts
373
+ var getNestedNewExpressions = getNestedExpressionsOfType(typescriptEstree.AST_NODE_TYPES.NewExpression);
376
374
  var getNestedCallExpressions = getNestedExpressionsOfType(typescriptEstree.AST_NODE_TYPES.CallExpression);
377
375
  function getNestedIdentifiers(node) {
378
376
  const identifiers = [];
@@ -437,7 +435,6 @@ function getNestedIdentifiers(node) {
437
435
  }
438
436
  return identifiers;
439
437
  }
440
- var getNestedNewExpressions = getNestedExpressionsOfType(typescriptEstree.AST_NODE_TYPES.NewExpression);
441
438
  function getNestedReturnStatements(node) {
442
439
  const returnStatements = [];
443
440
  const functionNode = isFunction(node) ? node : findParentNode(node, isFunction);
@@ -468,9 +465,6 @@ function getTopLevelIdentifier(node) {
468
465
  function isEmptyFunction(node) {
469
466
  return node.body.type === types.AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
470
467
  }
471
- function isKeyLiteralLike(node, property) {
472
- return tsPattern.match(property).with({ type: types.AST_NODE_TYPES.Literal }, eff.constTrue).with({ type: types.AST_NODE_TYPES.TemplateLiteral, expressions: [] }, eff.constTrue).with({ type: types.AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(eff.constFalse);
473
- }
474
468
  function isKindOfLiteral(node, kind) {
475
469
  if (node.type !== types.AST_NODE_TYPES.Literal) return false;
476
470
  switch (kind) {
@@ -613,7 +607,6 @@ exports.isJSX = isJSX;
613
607
  exports.isJSXElement = isJSXElement;
614
608
  exports.isJSXFragment = isJSXFragment;
615
609
  exports.isJSXTagNameExpression = isJSXTagNameExpression;
616
- exports.isKeyLiteralLike = isKeyLiteralLike;
617
610
  exports.isKindOfLiteral = isKindOfLiteral;
618
611
  exports.isLeftHandSideExpression = isLeftHandSideExpression;
619
612
  exports.isLeftHandSideExpressionType = isLeftHandSideExpressionType;
package/dist/index.mjs CHANGED
@@ -1,8 +1,7 @@
1
- import { or, dual, _, constTrue, constFalse } from '@eslint-react/eff';
1
+ import { or, dual, _ } from '@eslint-react/eff';
2
2
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
3
3
  import { ASTUtils } from '@typescript-eslint/utils';
4
4
  import { AST_NODE_TYPES as AST_NODE_TYPES$1, simpleTraverse } from '@typescript-eslint/typescript-estree';
5
- import { match } from 'ts-pattern';
6
5
  import { toLowerCase, delimiterCase, replace } from 'string-ts';
7
6
 
8
7
  // src/find-parent-node.ts
@@ -264,7 +263,7 @@ function getFunctionIdentifier(node) {
264
263
  return node.parent.key;
265
264
  // class {MaybeComponent = () => {}}
266
265
  // class {MaybeComponent() {}}
267
- case (isOneOf([AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition])(node.parent) && node.parent.value === node && node.parent.key.type === AST_NODE_TYPES.Identifier):
266
+ case (isMethodOrProperty(node.parent) && node.parent.value === node && node.parent.key.type === AST_NODE_TYPES.Identifier):
268
267
  return node.parent.key;
269
268
  // Follow spec convention for `IsAnonymousFunctionDefinition()` usage.
270
269
  //
@@ -369,8 +368,7 @@ function getNestedExpressionsOfType(type) {
369
368
  return expressions;
370
369
  };
371
370
  }
372
-
373
- // src/get-nested-call-expressions.ts
371
+ var getNestedNewExpressions = getNestedExpressionsOfType(AST_NODE_TYPES$1.NewExpression);
374
372
  var getNestedCallExpressions = getNestedExpressionsOfType(AST_NODE_TYPES$1.CallExpression);
375
373
  function getNestedIdentifiers(node) {
376
374
  const identifiers = [];
@@ -435,7 +433,6 @@ function getNestedIdentifiers(node) {
435
433
  }
436
434
  return identifiers;
437
435
  }
438
- var getNestedNewExpressions = getNestedExpressionsOfType(AST_NODE_TYPES$1.NewExpression);
439
436
  function getNestedReturnStatements(node) {
440
437
  const returnStatements = [];
441
438
  const functionNode = isFunction(node) ? node : findParentNode(node, isFunction);
@@ -466,9 +463,6 @@ function getTopLevelIdentifier(node) {
466
463
  function isEmptyFunction(node) {
467
464
  return node.body.type === AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
468
465
  }
469
- function isKeyLiteralLike(node, property) {
470
- return match(property).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({ type: AST_NODE_TYPES.TemplateLiteral, expressions: [] }, constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(constFalse);
471
- }
472
466
  function isKindOfLiteral(node, kind) {
473
467
  if (node.type !== AST_NODE_TYPES.Literal) return false;
474
468
  switch (kind) {
@@ -585,4 +579,4 @@ function toReadableNodeType(node) {
585
579
  return toLowerCase(delimiterCase(node.type, " "));
586
580
  }
587
581
 
588
- export { findParentNode, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isKindOfLiteral, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTsAssertionExpression, isTsOnlyExpression, isTypeDeclaration, toReadableNodeName, toReadableNodeType };
582
+ export { findParentNode, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKindOfLiteral, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTsAssertionExpression, isTsOnlyExpression, isTypeDeclaration, toReadableNodeName, toReadableNodeType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "1.28.1-beta.4",
3
+ "version": "1.28.1-beta.7",
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.25.0",
41
41
  "string-ts": "^2.2.1",
42
42
  "ts-pattern": "^5.6.2",
43
- "@eslint-react/eff": "1.28.1-beta.4"
43
+ "@eslint-react/eff": "1.28.1-beta.7"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsup": "^8.4.0",