/** * cli:eslint-validator — validate.ts * Validation structurelle (Zod) + verification que le repertoire existe * Ne fait PAS d'analyse de fichiers — c'est le role de execute.ts */ import { existsSync, statSync } from 'node:fs' import { ESLintInputSchema, type ESLintInput, type ValidationResult } from './types' export function validate(raw: unknown): ValidationResult { const blockers: string[] = [] const warnings: string[] = [] // ─── Validation structurelle (Zod) ─── const parsed = ESLintInputSchema.safeParse(raw) if (!parsed.success) { for (const issue of parsed.error.issues) { blockers.push(`[${issue.path.join('.')}] ${issue.message}`) } return { valid: false, blockers, warnings } } const data = parsed.data // ─── R1: Le repertoire source doit exister ─── if (!existsSync(data.src)) { blockers.push(`Source directory not found: ${data.src}`) return { valid: false, blockers, warnings } } // ─── R2: Le chemin doit pointer vers un repertoire ─── const stat = statSync(data.src) if (!stat.isDirectory()) { blockers.push(`Path is not a directory: ${data.src}`) return { valid: false, blockers, warnings } } return { valid: true, data, blockers, warnings, } }