/** * @file Vérifie que chaque fichier JavaScript du dépôt commence par son en-tête JSDoc `/** @file … *\/`. * * Attention : seule la présence de l'en-tête est contrôlée ; son contenu suit le gabarit de website/AGENTS.md. * @see website/AGENTS.md */ import assert from "node:assert/strict"; import { readdir, readFile } from "node:fs/promises"; import { join } from "node:path"; import { test } from "node:test"; const ROOTS = ["website/src", "services", "scripts", "tests", "e2e"]; const ROOT_FILES = ["server.mjs", "vite.config.js", "eslint.config.js", "playwright.config.js", "playwright.cards.config.js", "playwright.production.config.js"]; const SOURCE = /\.(js|jsx|mjs)$/; async function sourceFiles() { const files = [...ROOT_FILES]; for (const root of ROOTS) { const entries = await readdir(root, { recursive: true }); files.push(...entries.filter((entry) => SOURCE.test(entry) && !entry.includes("node_modules")).map((entry) => join(root, entry))); } return files; } test("every JavaScript file starts with a JSDoc @file header", async () => { const missing = []; for (const file of await sourceFiles()) { const source = await readFile(file, "utf8"); if (!/^\/\*\*\n \* @file \S/.test(source)) missing.push(file); } assert.deepEqual(missing, [], "Start these files with /** @file … */ (template: website/AGENTS.md)"); });