/** * Validate No Destructure Executor * * Validates that destructuring patterns are not used in TypeScript code. * Uses LINE-BASED detection (not method-based) for git diff filtering. * * ============================================================================ * VIOLATIONS (BAD) - These patterns are flagged: * ============================================================================ * * - const { x, y } = obj — object destructuring in variable declarations * - const [a, b] = fn() — array destructuring (except Promise.all) * - for (const { email } of items) — object destructuring in for-of loops * - for (const [a, b] of items) — array destructuring in for-of (except Object.entries) * - const { page = 0 } = opts — destructuring with defaults * - const { done: streamDone } = obj — destructuring with renaming * - function foo({ x, y }: Type) — function parameter destructuring * * ============================================================================ * ALLOWED (skip — NOT violations) * ============================================================================ * * - const [a, b] = await Promise.all([...]) — Promise.all array destructuring * - for (const [key, value] of Object.entries(obj)) — Object.entries in for-of * - const { extracted, ...rest } = obj — rest operator separation * - Lines with // webpieces-disable no-destructure -- [reason] (only when disableAllowed: true) * * ============================================================================ * MODES (LINE-BASED) * ============================================================================ * - OFF: Skip validation entirely * - MODIFIED_CODE: Flag destructuring on changed lines (lines in diff hunks) * - MODIFIED_FILES: Flag ALL destructuring in files that were modified * * ============================================================================ * ESCAPE HATCH * ============================================================================ * Add comment above the violation: * // webpieces-disable no-destructure -- [your justification] * const { x, y } = obj; */ import type { ExecutorContext } from '@nx/devkit'; export type NoDestructureMode = 'OFF' | 'MODIFIED_CODE' | 'MODIFIED_FILES'; export interface ValidateNoDestructureOptions { mode?: NoDestructureMode; disableAllowed?: boolean; ignoreModifiedUntilEpoch?: number; } export interface ExecutorResult { success: boolean; } export default function runExecutor(options: ValidateNoDestructureOptions, context: ExecutorContext): Promise;