sokko-g/tests/function-docs.test.mjs
Shinuwa 2f3c371d7b
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 24m10s
Validate and deploy Sokko G / deploy (push) Successful in 19s
Stop new code from skipping its JSDoc or SassDoc, and tell agents to fix old gaps as they go
A ratchet test fails on any new exported function without a JSDoc block and
keeps the list of the 496 older ones only shrinking. Every Sass sheet must now
start with its role header, not only the listed ones. The root, website, styles
and tests AGENTS.md files say to document new declarations at once and to
complete an undocumented one whenever it is modified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 16:34:47 +01:00

25 lines
1.4 KiB
JavaScript

/**
* @file Cliquet de la JSDoc des fonctions exportées : aucune nouvelle fonction exportée sans bloc `/** … *\/`, et la liste
* des anciennes fonctions encore sans commentaire ne fait que raccourcir.
*
* Attention : une fonction documentée doit sortir de tests/fixtures/undocumented-exports.json dans la même modification
* (`node tests/helpers/exported-functions.mjs --write`). Ne jamais y ajouter une fonction nouvelle : la documenter.
* @see website/AGENTS.md
*/
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { test } from "node:test";
import { BASELINE_PATH, undocumentedExports } from "./helpers/exported-functions.mjs";
test("new exported functions come with a JSDoc block", async () => {
const known = new Set(JSON.parse(await readFile(BASELINE_PATH, "utf8")));
const added = (await undocumentedExports()).filter((entry) => !known.has(entry));
assert.deepEqual(added, [], "Document these exported functions with a /** … */ block (see website/AGENTS.md)");
});
test("the list of undocumented exports only shrinks", async () => {
const current = new Set(await undocumentedExports());
const stale = JSON.parse(await readFile(BASELINE_PATH, "utf8")).filter((entry) => !current.has(entry));
assert.deepEqual(stale, [], `Remove these documented, renamed or deleted functions from ${BASELINE_PATH}: node tests/helpers/exported-functions.mjs --write`);
});