import { type AstNode } from './util'; /** * ESLint rule definition shape used by `require-top-level-computed-signals`. */ export interface DbxWebRequireTopLevelComputedSignalsRuleDefinition { readonly meta: { readonly type: 'problem'; readonly fixable: 'code'; readonly docs: { readonly description: string; readonly recommended: boolean; }; readonly messages: { readonly conditionalSignalRead: string; }; readonly schema: readonly object[]; }; create(context: AstNode): Record void>; } /** * ESLint rule that requires every signal read inside a `computed(() => { ... })` * callback to appear in an unconditional, top-level position rather than * inside a branching path (if/else, ternary, short-circuit, switch case, * loop body, catch handler). * * Angular `computed` re-tracks its dependencies on every run, so a signal * read that only happens inside one branch is not registered as a dependency * when the other branch executes. When that signal subsequently changes the * computed does not recompute and the value goes stale. Reading every signal * up front — before any branching — keeps the dependency set stable. * * To avoid false positives on plain methods and utility functions, the rule * only flags calls whose name can be statically traced back to a signal * factory: * * - `this.()` is flagged when `` is a class property initialized * with one of `signal`, `computed`, `input`, `input.required`, `model`, * `model.required`, `linkedSignal` (from `@angular/core`), or `toSignal` * (from `@angular/core/rxjs-interop`). * - `()` (bare identifier) is flagged when `` is a module-level * `const` initialized with one of those factories. * * Everything else — calls with arguments, chained property accesses on * services, calls on local loop variables, calls on globals — is left * alone. Cross-class signal tracking (e.g. `this.someService.someSignal()`) * is intentionally out of scope: it would require type analysis to * distinguish signal getters from plain getter methods, and the rule * prefers a clean report set over partial coverage. * * Only `computed` identifiers imported from `@angular/core` are considered. * Nested function expressions (callbacks passed to `.map` / `.filter` etc.) * are not inspected because Angular does not synchronously track signals * read inside them. * * Auto-fix: for each flagged callback, the fix inserts one * `const = this.();` (or `const = ();` * for module-scope captures) at the top of the callback body and replaces * every flagged call with ``. The local name is the signal name * with the trailing `Signal` suffix removed when present (`xSignal` → `x`). * If that name would shadow an existing local binding in the callback, the * fix is skipped for that signal to avoid generating a syntax error. * Expression-body callbacks (`computed(() => …)`) are converted to block * bodies as part of the fix; the previous expression becomes the `return` * value. */ export declare const DBX_WEB_REQUIRE_TOP_LEVEL_COMPUTED_SIGNALS_RULE: DbxWebRequireTopLevelComputedSignalsRuleDefinition;