/** * Validate No Any Unknown Executor * * Validates that `any` and `unknown` TypeScript keywords are not used. * Uses LINE-BASED detection (not method-based) for git diff filtering. * * ============================================================================ * VIOLATIONS (BAD) - These patterns are flagged: * ============================================================================ * * - const x: any = ... * - function foo(arg: any): any { } * - const data = response as any; * - type T = any; * - const x: unknown = ... * - function foo(arg: unknown): unknown { } * * ============================================================================ * MODES (LINE-BASED) * ============================================================================ * - OFF: Skip validation entirely * - MODIFIED_CODE: Flag any/unknown on changed lines (lines in diff hunks) * - MODIFIED_FILES: Flag ALL any/unknown in files that were modified * * ============================================================================ * ESCAPE HATCH * ============================================================================ * Add comment above the violation: * // webpieces-disable no-any-unknown -- [your justification] * const x: any = ...; */ import type { ExecutorContext } from '@nx/devkit'; export type NoAnyUnknownMode = 'OFF' | 'MODIFIED_CODE' | 'MODIFIED_FILES'; export interface ValidateNoAnyUnknownOptions { mode?: NoAnyUnknownMode; disableAllowed?: boolean; ignoreModifiedUntilEpoch?: number; } export interface ExecutorResult { success: boolean; } export default function runExecutor(options: ValidateNoAnyUnknownOptions, context: ExecutorContext): Promise;