Skip to content

⬅️ Back to Table of Contents

📄 isStartOfExpressionStatement

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 2

📚 Table of Contents

🛠️ File Location:

📂 packages/eslint-plugin/src/util/isStartOfExpressionStatement.ts

📦 Imports

Name Source
TSESTree @typescript-eslint/utils
AST_NODE_TYPES @typescript-eslint/utils

Functions

isStartOfExpressionStatement(node: TSESTree.Node): boolean

Tests if a node appears at the beginning of an ancestor ExpressionStatement node.

Parameters:

  • node any: The node to check.

Returns: undefined Whether the node appears at the beginning of an ancestor ExpressionStatement node.

Raw JSDoc
/**
 * Tests if a node appears at the beginning of an ancestor ExpressionStatement node.
 * @param node The node to check.
 * @returns Whether the node appears at the beginning of an ancestor ExpressionStatement node.
 */
Code
export function isStartOfExpressionStatement(node: TSESTree.Node): boolean {
  const start = node.range[0];
  let ancestor: TSESTree.Node | undefined = node;

  while ((ancestor = ancestor.parent) && ancestor.range[0] === start) {
    if (ancestor.type === AST_NODE_TYPES.ExpressionStatement) {
      return true;
    }
  }
  return false;
}

Generated by Syntax Scribe