ast.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * Find a return statement in the current node
  3. *
  4. * @param {ASTNode} node The AST node being checked
  5. * @returns {ASTNode | false}
  6. */
  7. export function findReturnStatement(node: ASTNode): ASTNode | false;
  8. /**
  9. * Get properties for a given AST node
  10. * @param {ASTNode} node The AST node being checked.
  11. * @returns {Array} Properties array.
  12. */
  13. export function getComponentProperties(node: ASTNode): any[];
  14. /**
  15. * Gets the first node in a line from the initial node, excluding whitespace.
  16. * @param {Object} context The node to check
  17. * @param {ASTNode} node The node to check
  18. * @return {ASTNode} the first node in the line
  19. */
  20. export function getFirstNodeInLine(context: any, node: ASTNode): ASTNode;
  21. /**
  22. * Retrieve the name of a key node
  23. * @param {Context} context The AST node with the key.
  24. * @param {any} node The AST node with the key.
  25. * @return {string | undefined} the name of the key
  26. */
  27. export function getKeyValue(context: Context, node: any): string | undefined;
  28. /**
  29. * Get properties name
  30. * @param {Object} node - Property.
  31. * @returns {string} Property name.
  32. */
  33. export function getPropertyName(node: any): string;
  34. /**
  35. * Get node with property's name
  36. * @param {Object} node - Property.
  37. * @returns {Object} Property name node.
  38. */
  39. export function getPropertyNameNode(node: any): any;
  40. /**
  41. * Check if we are in a class constructor
  42. * @param {Context} context
  43. * @param {ASTNode} node The AST node being checked.
  44. * @return {boolean}
  45. */
  46. export function inConstructor(context: Context, node: ASTNode): boolean;
  47. /**
  48. * Checks if a node is being assigned a value: props.bar = 'bar'
  49. * @param {ASTNode} node The AST node being checked.
  50. * @returns {boolean}
  51. */
  52. export function isAssignmentLHS(node: ASTNode): boolean;
  53. /**
  54. * Matcher used to check whether given node is a `CallExpression`
  55. * @param {ASTNode} node The AST node
  56. * @returns {boolean} True if node is a `CallExpression`, false if not
  57. */
  58. export function isCallExpression(node: ASTNode): boolean;
  59. /**
  60. * Checks if the node is a class.
  61. * @param {ASTNode} node The node to check
  62. * @return {boolean} true if it's a class
  63. */
  64. export function isClass(node: ASTNode): boolean;
  65. /**
  66. * Checks if the node is a function.
  67. * @param {ASTNode} node The node to check
  68. * @return {boolean} true if it's a function
  69. */
  70. export function isFunction(node: ASTNode): boolean;
  71. /**
  72. * Checks if node is a function declaration or expression or arrow function.
  73. * @param {ASTNode} node The node to check
  74. * @return {boolean} true if it's a function-like
  75. */
  76. export function isFunctionLike(node: ASTNode): boolean;
  77. /**
  78. * Checks if the node is a function or arrow function expression.
  79. * @param {ASTNode} node The node to check
  80. * @return {boolean} true if it's a function-like expression
  81. */
  82. export function isFunctionLikeExpression(node: ASTNode): boolean;
  83. /**
  84. * Checks if the node is the first in its line, excluding whitespace.
  85. * @param {Object} context The node to check
  86. * @param {ASTNode} node The node to check
  87. * @return {boolean} true if it's the first node in its line
  88. */
  89. export function isNodeFirstInLine(context: any, node: ASTNode): boolean;
  90. /**
  91. * Checks if a node is surrounded by parenthesis.
  92. *
  93. * @param {object} context - Context from the rule
  94. * @param {ASTNode} node - Node to be checked
  95. * @returns {boolean}
  96. */
  97. export function isParenthesized(context: object, node: ASTNode): boolean;
  98. export function isTSAsExpression(node: any): boolean;
  99. export function isTSFunctionType(node: any): boolean;
  100. export function isTSInterfaceDeclaration(node: any): boolean;
  101. export function isTSInterfaceHeritage(node: any): boolean;
  102. export function isTSIntersectionType(node: any): boolean;
  103. export function isTSParenthesizedType(node: any): boolean;
  104. export function isTSTypeAliasDeclaration(node: any): boolean;
  105. export function isTSTypeAnnotation(node: any): boolean;
  106. export function isTSTypeDeclaration(node: any): boolean;
  107. export function isTSTypeLiteral(node: any): boolean;
  108. export function isTSTypeParameterInstantiation(node: any): boolean;
  109. export function isTSTypeQuery(node: any): boolean;
  110. export function isTSTypeReference(node: any): boolean;
  111. /**
  112. * Wrapper for estraverse.traverse
  113. *
  114. * @param {ASTNode} ASTnode The AST node being checked
  115. * @param {Object} visitor Visitor Object for estraverse
  116. */
  117. export function traverse(ASTnode: ASTNode, visitor: any): void;
  118. /**
  119. * Helper function for traversing "returns" (return statements or the
  120. * returned expression in the case of an arrow function) of a function
  121. *
  122. * @param {ASTNode} ASTNode The AST node being checked
  123. * @param {Context} context The context of `ASTNode`.
  124. * @param {(returnValue: ASTNode, breakTraverse: () => void) => void} onReturn
  125. * Function to execute for each returnStatement found
  126. * @returns {undefined}
  127. */
  128. export function traverseReturns(ASTNode: ASTNode, context: Context, onReturn: (returnValue: ASTNode, breakTraverse: () => void) => void): undefined;
  129. /**
  130. * Extracts the expression node that is wrapped inside a TS type assertion
  131. *
  132. * @param {ASTNode} node - potential TS node
  133. * @returns {ASTNode} - unwrapped expression node
  134. */
  135. export function unwrapTSAsExpression(node: ASTNode): ASTNode;
  136. //# sourceMappingURL=ast.d.ts.map