Skip to content

⬅️ Back to Table of Contents

📄 ReferenceTracker

📊 Analysis Summary

Metric Count
📦 Imports 1
📊 Variables & Constants 5
📐 Interfaces 4
📑 Type Aliases 6

📚 Table of Contents

🛠️ File Location:

📂 packages/utils/src/ast-utils/eslint-utils/ReferenceTracker.ts

📦 Imports

Name Source
TSESTree ../../ts-estree

Variables & Constants

Name Type Kind Value Exported
ReferenceTrackerREAD any const eslintUtils.ReferenceTracker.READ
ReferenceTrackerCALL any const eslintUtils.ReferenceTracker.CALL
ReferenceTrackerCONSTRUCT any const eslintUtils.ReferenceTracker.CONSTRUCT
ReferenceTrackerESM any const eslintUtils.ReferenceTracker.ESM
ReferenceTracker ReferenceTrackerStatic const eslintUtils.ReferenceTracker as ReferenceTrackerStatic

Interfaces

ReferenceTracker

Interface Code
interface ReferenceTracker {
  /**
   * Iterate the references that the given `traceMap` determined.
   * This method starts to search from `require()` expression.
   *
   * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iteratecjsreferences}
   */
  iterateCjsReferences<T>(
    traceMap: ReferenceTracker.TraceMap<T>,
  ): IterableIterator<ReferenceTracker.FoundReference<T>>;

  /**
   * Iterate the references that the given `traceMap` determined.
   * This method starts to search from `import`/`export` declarations.
   *
   * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateesmreferences}
   */
  iterateEsmReferences<T>(
    traceMap: ReferenceTracker.TraceMap<T>,
  ): IterableIterator<ReferenceTracker.FoundReference<T>>;

  /**
   * Iterate the references that the given `traceMap` determined.
   * This method starts to search from global variables.
   *
   * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateglobalreferences}
   */
  iterateGlobalReferences<T>(
    traceMap: ReferenceTracker.TraceMap<T>,
  ): IterableIterator<ReferenceTracker.FoundReference<T>>;
}

ReferenceTrackerStatic

Interface Code
interface ReferenceTrackerStatic {
  readonly CALL: typeof ReferenceTrackerCALL;
  readonly CONSTRUCT: typeof ReferenceTrackerCONSTRUCT;
  readonly ESM: typeof ReferenceTrackerESM;

  new (
    globalScope: TSESLint.Scope.Scope,
    options?: {
      /**
       * The name list of Global Object. Optional. Default is `["global", "globalThis", "self", "window"]`.
       */
      globalObjectNames?: readonly string[];
      /**
       * The mode which determines how the `tracker.iterateEsmReferences()` method scans CommonJS modules.
       * If this is `"strict"`, the method binds CommonJS modules to the default export. Otherwise, the method binds
       * CommonJS modules to both the default export and named exports. Optional. Default is `"strict"`.
       */
      mode?: 'legacy' | 'strict';
    },
  ): ReferenceTracker;

  readonly READ: typeof ReferenceTrackerREAD;
}

Properties

Name Type Optional Description
CALL typeof ReferenceTrackerCALL not shown
CONSTRUCT typeof ReferenceTrackerCONSTRUCT not shown
ESM typeof ReferenceTrackerESM not shown
READ typeof ReferenceTrackerREAD not shown

TraceMapElement<T>

Interface Code
export interface TraceMapElement<T> {
    [key: string]: TraceMapElement<T>;
    [ReferenceTrackerCALL]?: T;
    [ReferenceTrackerCONSTRUCT]?: T;
    [ReferenceTrackerESM]?: true;
    [ReferenceTrackerREAD]?: T;
  }

Properties

Name Type Optional Description
[ReferenceTrackerCALL] T not shown
[ReferenceTrackerCONSTRUCT] T not shown
[ReferenceTrackerESM] true not shown
[ReferenceTrackerREAD] T not shown

FoundReference<T = any>

Interface Code
export interface FoundReference<T = any> {
    info: T;
    node: TSESTree.Node;
    path: readonly string[];
    type: ReferenceType;
  }

Properties

Name Type Optional Description
info T not shown
node TSESTree.Node not shown
path readonly string[] not shown
type ReferenceType not shown

Type Aliases

READ

type READ = ReferenceTrackerStatic['READ'];

CALL

type CALL = ReferenceTrackerStatic['CALL'];

CONSTRUCT

type CONSTRUCT = ReferenceTrackerStatic['CONSTRUCT'];

ESM

type ESM = ReferenceTrackerStatic['ESM'];

ReferenceType

type ReferenceType = symbol;

TraceMap<T = any>

type TraceMap<T = any> = Record<string, TraceMapElement<T>>;

Generated by Syntax Scribe