Headers: - Every JavaScript file (sources, front, scripts, tests) starts with a /** @file … */ header, in the three levels used by sokko-g: a short description for simple files; Utilisé par / Attention / @see for shared modules; a full header (context, entry points, callers, dependencies, pitfalls) for index.js, the music queue, the web server, the storage manager and the jukebox page script. - No @author, @version or @since: git already knows. - test/fileHeaders.test.js fails `npm run check` when a header is missing or a central file's header is incomplete. Stylesheet (no visual change, checked by comparing every element's computed styles in Chromium at 1280, 800 and 400 px, hover included): - Role header and section comments. - Transparent shades derive from the colour variables with color-mix() instead of copied rgba() values; new tokens for repeated values (text, text on accent, accent gradient, white veils, shadow). - Native nesting for buttons, the live indicator, upload rows and home cards; drop the unused .hero__visual--large and redundant rules. - Utility classes move to the end so they win over components. The library list's u-mt-1, which never applied (.list reset it), is removed to keep the layout as it was. Docs: CONTRIBUTING.md describes the language, header and stylesheet conventions; CLAUDE.md points to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.4 KiB
JavaScript
68 lines
2.4 KiB
JavaScript
/**
|
|
* @file Vérifie que chaque fichier JavaScript et la feuille de style commencent par leur en-tête, et que
|
|
* les fichiers centraux ont un en-tête complet.
|
|
*
|
|
* Attention : le test ne lit que la présence des rubriques ; leur contenu reste à écrire avec soin.
|
|
* @see CONTRIBUTING.md#en-têtes-de-fichiers
|
|
*/
|
|
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const JS_ROOTS = ["index.js", "deployCommands.js", "src", "public/scripts", "scripts", "test"];
|
|
// Fichiers centraux : en-tête complet exigé. Un fichier qui le devient s'ajoute ici.
|
|
const CENTRAL_FILES = [
|
|
"index.js",
|
|
"public/scripts/jukebox.js",
|
|
"src/music/queue.js",
|
|
"src/web/server.js",
|
|
"src/web/storage/storageManager.js",
|
|
];
|
|
const LONG_FILE_LINES = 300;
|
|
|
|
function collectJavaScriptFiles(entry) {
|
|
const absolutePath = path.join(ROOT, entry);
|
|
if (fs.statSync(absolutePath).isFile()) {
|
|
return entry.endsWith(".js") ? [entry] : [];
|
|
}
|
|
return fs
|
|
.readdirSync(absolutePath)
|
|
.flatMap((child) => collectJavaScriptFiles(path.posix.join(entry, child)));
|
|
}
|
|
|
|
function header(content) {
|
|
const end = content.indexOf("*/");
|
|
return end === -1 ? "" : content.slice(0, end);
|
|
}
|
|
|
|
const jsFiles = JS_ROOTS.flatMap(collectJavaScriptFiles);
|
|
|
|
test("every JavaScript file starts with a @file header", () => {
|
|
const missing = jsFiles.filter((file) => {
|
|
const content = fs.readFileSync(path.join(ROOT, file), "utf8");
|
|
return !content.startsWith("/**\n * @file ");
|
|
});
|
|
assert.deepEqual(missing, []);
|
|
});
|
|
|
|
test("central and long files have a complete header", () => {
|
|
const long = jsFiles.filter(
|
|
(file) =>
|
|
!file.startsWith("test/") &&
|
|
fs.readFileSync(path.join(ROOT, file), "utf8").split("\n").length > LONG_FILE_LINES
|
|
);
|
|
const incomplete = [...new Set([...CENTRAL_FILES, ...long])].filter((file) => {
|
|
const text = header(fs.readFileSync(path.join(ROOT, file), "utf8"));
|
|
return !["Contexte :", "Utilisé par :", "@see "].every((rubric) => text.includes(rubric));
|
|
});
|
|
assert.deepEqual(incomplete, []);
|
|
});
|
|
|
|
test("the stylesheet starts with its role", () => {
|
|
const content = fs.readFileSync(path.join(ROOT, "public/style/styles.css"), "utf8");
|
|
assert.ok(content.startsWith("/*\n * Rôle : "));
|
|
});
|