Skip to content

⬅️ Back to Table of Contents

📄 isStartOfArrowFunctionBody

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 4

📚 Table of Contents

🛠️ File Location:

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

📦 Imports

Name Source
TSESLint @typescript-eslint/utils
TSESTree @typescript-eslint/utils
AST_NODE_TYPES @typescript-eslint/utils
isParenthesized ./astUtils

Functions

isStartOfArrowFunctionBody(node: TSESTree.Node, sourceCode: TSESLint.SourceCode): boolean

Parameters:

  • node TSESTree.Node
  • sourceCode TSESLint.SourceCode

Returns: boolean

Calls:

  • isParenthesized (from ./astUtils)
Code
export function isStartOfArrowFunctionBody(
  node: TSESTree.Node,
  sourceCode: TSESLint.SourceCode,
): boolean {
  let current: TSESTree.Node = node;
  while (true) {
    if (isParenthesized(current, sourceCode)) {
      return false;
    }
    const { parent } = current;
    if (parent == null) {
      return false;
    }
    if (
      parent.type === AST_NODE_TYPES.ArrowFunctionExpression &&
      parent.body === current
    ) {
      return true;
    }
    if (parent.range[0] !== current.range[0]) {
      return false;
    }
    current = parent;
  }
}

Generated by Syntax Scribe