@eslint-react/ast 3.0.0 → 4.0.0-beta.1

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
@@ -34,6 +34,7 @@ type TSESTreeProperty = TSESTree$1.PropertyDefinition | TSESTree$1.TSIndexSignat
34
34
  * Represents all JSX-related nodes in TSESTree
35
35
  */
36
36
  type TSESTreeJSX = TSESTree$1.JSXAttribute | TSESTree$1.JSXChild | TSESTree$1.JSXClosingElement | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXEmptyExpression | TSESTree$1.JSXIdentifierToken | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXSpreadAttribute | TSESTree$1.JSXTagNameExpression | TSESTree$1.JSXTextToken;
37
+ type TSESTreeJSXElementLike = TSESTree$1.JSXElement | TSESTree$1.JSXFragment;
37
38
  /**
38
39
  * Represents JSX attribute-like nodes (attributes and spread attributes)
39
40
  */
@@ -348,6 +349,10 @@ declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is
348
349
  * @returns True if the node is a JSX fragment
349
350
  */
350
351
  declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
352
+ /**
353
+ * Check if a node is a JSX element or JSX fragment
354
+ */
355
+ declare const isJSXElementLike: (data: TSESTree.Node | null | undefined) => data is TSESTree.JSXElement | TSESTree.JSXFragment;
351
356
  /**
352
357
  * Check if a node is a JSX tag name expression (identifier, member expression, or namespaced name)
353
358
  * @param node The node to check
@@ -448,14 +453,14 @@ declare const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION: string;
448
453
  * @param test The test function
449
454
  * @returns The parent node that satisfies the test function or `null` if not found
450
455
  */
451
- declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | null, test: (n: TSESTree.Node) => n is A): A | null;
456
+ declare function findParent<A extends TSESTree.Node>(node: TSESTree.Node | null, test: (n: TSESTree.Node) => n is A): A | null;
452
457
  /**
453
458
  * Find the parent node that satisfies the test function or `null` if not found
454
459
  * @param node The AST node
455
460
  * @param test The test function
456
461
  * @returns The parent node that satisfies the test function
457
462
  */
458
- declare function findParentNode(node: TSESTree.Node | null, test: (node: TSESTree.Node) => boolean): TSESTree.Node | null;
463
+ declare function findParent(node: TSESTree.Node | null, test: (node: TSESTree.Node) => boolean): TSESTree.Node | null;
459
464
  //#endregion
460
465
  //#region src/node-unwrap.d.ts
461
466
  /**
@@ -516,4 +521,4 @@ declare function getPropertyName(node: TSESTree.Node): string | null;
516
521
  */
517
522
  declare function findProperty(properties: TSESTree.ObjectLiteralElement[], name: string): TSESTree.Property | null;
518
523
  //#endregion
519
- export { DirectiveKind, DisplayNameAssignmentExpression, FunctionID, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeDirective, TSESTreeDirectiveLike, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParentNode, findProperty, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getRootIdentifier, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback };
524
+ export { DirectiveKind, DisplayNameAssignmentExpression, FunctionID, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeDirective, TSESTreeDirectiveLike, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeJSXElementLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParent, findProperty, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getRootIdentifier, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXElementLike, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback };
package/dist/index.js CHANGED
@@ -267,6 +267,10 @@ const isJSXElement = is(AST_NODE_TYPES.JSXElement);
267
267
  */
268
268
  const isJSXFragment = is(AST_NODE_TYPES.JSXFragment);
269
269
  /**
270
+ * Check if a node is a JSX element or JSX fragment
271
+ */
272
+ const isJSXElementLike = or(isJSXElement, isJSXFragment);
273
+ /**
270
274
  * Check if a node is a JSX tag name expression (identifier, member expression, or namespaced name)
271
275
  * @param node The node to check
272
276
  * @returns True if the node is a JSX tag name expression
@@ -374,7 +378,7 @@ function isThisExpressionLoose(node) {
374
378
 
375
379
  //#endregion
376
380
  //#region src/node-traverse.ts
377
- function findParentNode(node, test) {
381
+ function findParent(node, test) {
378
382
  if (node == null) return null;
379
383
  let parent = node.parent;
380
384
  while (parent != null && parent.type !== AST_NODE_TYPES.Program) {
@@ -475,10 +479,10 @@ function getNestedIdentifiers(node) {
475
479
  */
476
480
  function getNestedReturnStatements(node) {
477
481
  const statements = [];
478
- const boundaryNode = isFunction(node) ? node : findParentNode(node, isFunction);
482
+ const boundaryNode = isFunction(node) ? node : findParent(node, isFunction);
479
483
  simpleTraverse(node, { enter(node) {
480
484
  if (node.type !== AST_NODE_TYPES.ReturnStatement) return;
481
- if (findParentNode(node, isFunction) !== boundaryNode) return;
485
+ if (findParent(node, isFunction) !== boundaryNode) return;
482
486
  statements.push(node);
483
487
  } });
484
488
  return statements;
@@ -966,4 +970,4 @@ function findProperty(properties, name) {
966
970
  }
967
971
 
968
972
  //#endregion
969
- export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, findParentNode, findProperty, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getRootIdentifier, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback };
973
+ export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, findParent, findProperty, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getRootIdentifier, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXElementLike, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "3.0.0",
3
+ "version": "4.0.0-beta.1",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -30,13 +30,13 @@
30
30
  "./package.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@typescript-eslint/types": "^8.57.0",
34
- "@typescript-eslint/typescript-estree": "^8.57.0",
35
- "@typescript-eslint/utils": "^8.57.0",
33
+ "@typescript-eslint/types": "^8.57.2",
34
+ "@typescript-eslint/typescript-estree": "^8.57.2",
35
+ "@typescript-eslint/utils": "^8.57.2",
36
36
  "string-ts": "^2.3.1"
37
37
  },
38
38
  "devDependencies": {
39
- "tsdown": "^0.21.2",
39
+ "tsdown": "^0.21.4",
40
40
  "@local/configs": "0.0.0",
41
41
  "@local/eff": "3.0.0-beta.72"
42
42
  },