Repository navigation
Expand file tree
/
Copy pathchecks.test.mjs
More file actions
1048 lines (996 loc) · 55.8 KB
/
Copy pathchecks.test.mjs
File metadata and controls
1048 lines (996 loc) · 55.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env node
/**
* Fixture suite for the checks added in batch B. Run: node site/checks.test.mjs
*
* Every check gets a known-bad fixture it must reject and a known-good one it
* must accept. A check that passes while measuring nothing is the failure mode
* this file exists to prevent, so "rejects" asserts on the message too.
*/
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import {
checkActiveIsSettled,
checkAddedDate,
checkAttributionConsistency,
checkCategoryReadmeRows,
checkCategorySets,
checkCountTables,
checkDeprecationReason,
checkEngineFields,
checkEntryUrl,
checkEvidenceDates,
checkFieldTypes,
checkFormatVocabulary,
evidenceDates,
markdownAnchors,
checkLicenseVocabulary,
checkLicenceGuide,
checkLineEndings,
checkRepoFiles,
checkEntryCount,
checkEntryText,
checkMarkdownLinks,
categoryFormOptions,
hasEmoji,
checkMaintenance,
checkNonCommercialEvidence,
maintenanceFromRepo,
checkPublisherConsistency,
checkSpdxConsistency,
checkStacks,
checkTagsRestatePublisher,
checkTaxonomyValues,
checkTitleMatchesName,
checkValueAliases,
checkValueSpellings,
checkAiGuide,
checkAttributionWaiver,
checkAiTag,
checkCreditPlaceholders,
checkLimits,
checkKnownKeys,
checkEntryBasics,
checkFeatured,
checkPreviewVocabulary,
checkComparisonLicences,
closestKnownKey,
} from "./checks.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const vocab = JSON.parse(
fs.readFileSync(path.join(__dirname, "license-vocabulary.json"), "utf8")
);
const spdxAllowed = new Set(
JSON.parse(fs.readFileSync(path.join(__dirname, "spdx-allowed.json"), "utf8"))
);
let passed = 0;
const failures = [];
// A test that throws (rather than failing an assertion) ends the run. Report
// what had already failed and where the run stopped, so one crash does not
// hide the failures before it.
let lastLabel = "(none yet)";
process.on("uncaughtException", (err) => {
console.error(`checks.test crashed after ${passed} passing assertions; the last one was "${lastLabel}".`);
for (const f of failures) console.error(` - ${f}`);
console.error(err && err.stack ? err.stack : err);
process.exit(1);
});
/** The V-rule names the assertions cover, so the summary counts them instead of restating a number. */
const checksSeen = new Set();
const note = (label) => {
lastLabel = label;
const v = String(label).match(/^V\d+/);
if (v) checksSeen.add(v[0]);
};
function rejects(label, errors, needle) {
note(label);
if (!errors.length) {
failures.push(`${label}: expected an error, got none`);
return;
}
if (needle && !errors.some((e) => e.includes(needle))) {
failures.push(
`${label}: error did not mention "${needle}"; got: ${errors.join(" | ")}`
);
return;
}
passed += 1;
}
// Sections (#203): each self-contained block runs as one. A section that
// throws is reported as a failure and the run goes on, so one crash does not
// hide the rest. TEST_ONLY=<words> runs only the sections whose name contains
// them (the few assertions outside any section still run).
const ONLY = String(process.env.TEST_ONLY || "").toLowerCase();
let sectionsRun = 0;
async function section(name, fn) {
if (ONLY && !name.toLowerCase().includes(ONLY)) return;
sectionsRun += 1;
try {
await fn();
} catch (err) {
const where = err && err.stack ? err.stack.split("\n").slice(0, 3).join(" | ") : String(err);
failures.push(`section "${name}" threw: ${where}`);
}
}
function eq(label, actual, expected) {
note(label);
if (actual === expected) passed += 1;
else failures.push(`${label}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`);
}
function accepts(label, errors) {
note(label);
if (errors.length) {
failures.push(`${label}: expected no error, got: ${errors.join(" | ")}`);
return;
}
passed += 1;
}
const TODAY = "2026-09-22";
const EV = (d) => `\n## Evidence\n\n- Live page (${d}): "CC0"\n`;
/* V1 -------------------------------------------------------------------- */
rejects(
"V1 rejects an undocumented license value",
checkLicenseVocabulary("bad.md", { license: "CC-BY 4.0" }, vocab),
"not in site/license-vocabulary.json"
);
rejects(
"V1 rejects the OFL near-miss",
checkLicenseVocabulary("bad.md", { license: "OFL" }, vocab),
"OFL"
);
accepts(
"V1 accepts a documented license value",
checkLicenseVocabulary("ok.md", { license: "SIL OFL" }, vocab)
);
/* V2 / V3 --------------------------------------------------------------- */
rejects(
"V3 rejects a fillable but absent license_spdx",
checkSpdxConsistency("bad.md", { license: "MIT" }, vocab, spdxAllowed),
"license_spdx is absent"
);
rejects(
"V2 rejects a license_spdx that contradicts the license",
checkSpdxConsistency(
"bad.md",
{ license: "CC0", license_spdx: "MIT" },
vocab,
spdxAllowed
),
'license_spdx is "MIT"'
);
rejects(
"V2 rejects an SPDX id invented for a license that has none",
checkSpdxConsistency(
"bad.md",
{ license: "custom", license_spdx: "MIT" },
vocab,
spdxAllowed
),
"must not carry license_spdx"
);
rejects(
"V2 rejects guessing -only for a bare GPL value",
checkSpdxConsistency(
"bad.md",
{ license: "GPL-3.0", license_spdx: "GPL-3.0-only" },
vocab,
spdxAllowed
),
"deprecated the bare identifier"
);
accepts(
"V2/V3 accept a correct pairing",
checkSpdxConsistency(
"ok.md",
{ license: "CC0", license_spdx: "CC0-1.0" },
vocab,
spdxAllowed
)
);
accepts(
"V3 accepts an absent SPDX on an ambiguous license",
checkSpdxConsistency("ok.md", { license: "GPL-3.0" }, vocab, spdxAllowed)
);
/* V4 -------------------------------------------------------------------- */
rejects(
"V4 rejects an attribution license silently marked not-required",
checkAttributionConsistency(
"bad.md",
{ license: "CC-BY-4.0", attribution_required: false },
"# X\n\nNo waiver stated.\n",
vocab
),
"no \"- Attribution waived:\" line"
);
accepts(
"V4 accepts the same entry once the waiver is stated",
checkAttributionConsistency(
"ok.md",
{ license: "CC-BY-4.0", attribution_required: false },
"# X\n\n## Notes\n\n- Attribution waived: publisher offers an opt-out\n",
vocab
)
);
accepts(
"V4 does not fire on OFL, whose obligation is a notice not a credit",
checkAttributionConsistency(
"ok.md",
{ license: "SIL OFL", attribution_required: false },
"# X\n",
vocab
)
);
/* V8 / V10 -------------------------------------------------------------- */
for (const date of ["2025-13-01", "2026-02-30", "2025-02-29", "1900-02-29", "2026-04-31"]) {
rejects(
`V8 rejects impossible Evidence date ${date}`,
checkEvidenceDates("bad.md", { verified: "2026-01-01" }, `# X${EV(date)}`, TODAY),
`Evidence date ${date} is not a real YYYY-MM-DD date`
);
}
rejects(
"V8 rejects an impossible date even alongside valid Evidence",
checkEvidenceDates("bad.md", { verified: "2026-09-20" }, `# X${EV("2026-02-30")}\n- Rechecked 2026-09-20.\n`, TODAY),
"Evidence date 2026-02-30 is not a real YYYY-MM-DD date"
);
accepts(
"V8 accepts real leap-day Evidence",
checkEvidenceDates("ok.md", { verified: "2000-02-29" }, `# X${EV("2000-02-29")}`, TODAY)
);
rejects(
"V8 rejects a verified date newer than its newest Evidence date",
checkEvidenceDates(
"bad.md",
{ verified: "2026-09-22" },
`# X${EV("2026-07-19")}`,
TODAY
),
"newer than its newest Evidence date"
);
rejects(
"V8 rejects an Evidence date in the future",
checkEvidenceDates(
"bad.md",
{ verified: "2026-09-22" },
`# X${EV("2027-01-01")}`,
TODAY
),
"is in the future"
);
rejects(
"V10 rejects an Evidence section with no date",
checkEvidenceDates(
"bad.md",
{ verified: "2026-09-22" },
'# X\n\n## Evidence\n\n- Live page: "CC0"\n',
TODAY
),
"carries no YYYY-MM-DD date"
);
accepts(
"V8 accepts verified equal to the Evidence date",
checkEvidenceDates(
"ok.md",
{ verified: "2026-07-19" },
`# X${EV("2026-07-19")}`,
TODAY
)
);
accepts(
"V8 accepts verified older than the Evidence date",
checkEvidenceDates(
"ok.md",
{ verified: "2026-07-19" },
`# X${EV("2026-08-24")}`,
TODAY
)
);
/* V9 -------------------------------------------------------------------- */
rejects(
"V9 rejects a deprecated entry with no stated reason",
checkDeprecationReason(
"bad.md",
{ status: "deprecated" },
"# X\n\nThe site is gone.\n",
vocab
),
"needs a \"- Deprecated:\" line"
);
accepts(
"V9 accepts a deprecated entry that states one",
checkDeprecationReason(
"ok.md",
{ status: "deprecated" },
"# X\n\n## Notes\n\n- Deprecated: the site is gone\n",
vocab
)
);
accepts(
"V9 does not fire on an active entry",
checkDeprecationReason("ok.md", { status: "active" }, "# X\n", vocab)
);
/* V7 -------------------------------------------------------------------- */
rejects(
"V7 rejects a generic host used as a publisher",
checkPublisherConsistency([
{ rel: "bad.md", meta: { publisher: "GitHub", url: "https://github.com/a/b" } },
]),
"is a generic host"
);
rejects(
"V7 rejects two publishers claiming one domain",
checkPublisherConsistency([
{ rel: "a.md", meta: { publisher: "Alpha", url: "https://example.com/a" } },
{ rel: "b.md", meta: { publisher: "Beta", url: "https://example.com/b" } },
]),
"conflicting publisher values"
);
accepts(
"V7 accepts one publisher across a domain, with a sibling entry unset",
checkPublisherConsistency([
{ rel: "a.md", meta: { publisher: "Blender Studio", url: "https://www.blender.org/a" } },
{ rel: "b.md", meta: { publisher: "Blender Studio", url: "https://www.blender.org/b" } },
{ rel: "c.md", meta: { url: "https://www.blender.org/c" } },
])
);
rejects(
"V7 rejects OpenGameArt as a publisher, since it is the host",
checkPublisherConsistency([
{ rel: "bad.md", meta: { publisher: "OpenGameArt", url: "https://opengameart.org/content/x" } },
]),
"is a generic host"
);
rejects(
"V7 rejects Google Fonts as a publisher, since it distributes rather than holds the rights",
checkPublisherConsistency([
{ rel: "bad.md", meta: { publisher: "Google Fonts", url: "https://fonts.google.com/specimen/X" } },
]),
"is a generic host"
);
accepts(
"V7 allows different artists on opengameart.org, which hosts many publishers",
checkPublisherConsistency([
{ rel: "a.md", meta: { publisher: "ansimuz", url: "https://opengameart.org/content/a" } },
{ rel: "b.md", meta: { publisher: "Sylly", url: "https://opengameart.org/content/b" } },
])
);
accepts(
"V7 does not fire across github.com, which hosts many publishers",
checkPublisherConsistency([
{ rel: "a.md", meta: { publisher: "Alpha", url: "https://github.com/a/x" } },
{ rel: "b.md", meta: { publisher: "Beta", url: "https://github.com/b/y" } },
])
);
/* V6 -------------------------------------------------------------------- */
const goodReadme = [
"[](x)",
"**[Browse 3 sources](x)**",
"| **2D** | 2 | Sprites | [`catalog/2d/`](catalog/2d/) |",
"| **Video** | 1 | Clips | [`catalog/video/`](catalog/video/) |",
].join("\n");
rejects(
"V6 rejects a category count that drifted",
checkCountTables({ "2d": 5, video: 1 }, [
{ name: "README.md", text: goodReadme, pathFragment: "catalog/CAT/" },
]),
'lists 2 entries for "2d" but the catalog has 5'
);
rejects(
"V6 rejects a stale sources badge",
checkCountTables({ "2d": 2, video: 2 }, [
{ name: "README.md", text: goodReadme, pathFragment: "catalog/CAT/" },
]),
"sources badge says 3 but the catalog has 4"
);
rejects(
"V6 rejects a category missing from the table entirely",
checkCountTables({ "2d": 2, video: 1, audio: 1 }, [
{ name: "README.md", text: goodReadme, pathFragment: "catalog/CAT/" },
]),
'no category count row for "audio"'
);
accepts(
"V6 accepts tables that match",
checkCountTables({ "2d": 2, video: 1 }, [
{ name: "README.md", text: goodReadme, pathFragment: "catalog/CAT/" },
])
);
rejects(
"V6 rejects a stale 'searches all N entries'",
checkCountTables({ "2d": 2, video: 1 }, [
{ name: "README.md", text: `${goodReadme}\nThe site searches all 2 entries.`, pathFragment: "catalog/CAT/" },
]),
'"searches all 2 entries" but the catalog has 3'
);
/* V11 ------------------------------------------------------------------- */
const readme = [
"| ID | Name | License | Status |",
"| [tiled](tiled.md) | Tiled | GPL-3.0 | active |",
"| [kenney](kenney.md) | Kenney | CC0 | active |",
"| [lpc](lpc.md) | LPC | varies (SA) | active |",
].join("\n");
rejects(
"V11 reports a category README with entries but no catalog table",
checkCategoryReadmeRows("tools", "# Tools\n\nNo table here.\n", [
{ rel: "catalog/tools/a.md", meta: { license: "MIT" } },
]),
"has no catalog table"
);
accepts(
"V11 ignores a comparison table that leads with the entry link",
checkCategoryReadmeRows(
"3d",
[
"| If you need | Take | Licence |",
"| A default | [ambientcg](ambientcg.md) - seamless | **CC0** |",
"",
"| ID | Name | License | Commercial | Status |",
"| [ambientcg](ambientcg.md) | ambientCG | CC0 | yes | active |",
].join("\n"),
[{ rel: "catalog/3d/ambientcg.md", meta: { license: "CC0" } }]
)
);
rejects(
"V11 still catches drift in the listing when a link-first comparison table exists",
checkCategoryReadmeRows(
"3d",
[
"| If you need | Take | Licence |",
"| A default | [ambientcg](ambientcg.md) - seamless | **CC0** |",
"",
"| ID | Name | License | Commercial | Status |",
"| [ambientcg](ambientcg.md) | ambientCG | MIT | yes | active |",
].join("\n"),
[{ rel: "catalog/3d/ambientcg.md", meta: { license: "CC0" } }]
),
'does not carry its license "CC0"'
);
rejects(
"V11 rejects a README row whose license contradicts the frontmatter",
checkCategoryReadmeRows("tools", readme, [
{ rel: "catalog/tools/tiled.md", meta: { license: "GPL-2.0-or-later" } },
]),
'does not carry its license "GPL-2.0-or-later"'
);
accepts(
"V11 accepts a row that matches",
checkCategoryReadmeRows("tools", readme, [
{ rel: "catalog/tools/kenney.md", meta: { license: "CC0" } },
])
);
accepts(
"V11 keeps annotated cells legal, since the footnote carries a warning",
checkCategoryReadmeRows("tools", readme, [
{ rel: "catalog/tools/lpc.md", meta: { license: "varies" } },
])
);
accepts(
"V11 tolerates a trailing footnote marker",
checkCategoryReadmeRows(
"tools",
[
"| ID | Name | License | Status |",
"| [a](a.md) | A | CC0* | active |",
"| [b](b.md) | B | CC-BY? | active |",
].join("\n"),
[
{ rel: "catalog/tools/a.md", meta: { license: "CC0" } },
{ rel: "catalog/tools/b.md", meta: { license: "CC-BY" } },
]
)
);
accepts(
"V11 ignores a comparison table that links an entry from a prose cell",
checkCategoryReadmeRows(
"tools",
[
"| If you want | Take | Over | Because |",
"| A retro SFX fast | [jsfxr](jsfxr.md) | sfxr | Browser, no install |",
"| ID | Name | License | Status |",
"| [jsfxr](jsfxr.md) | jsfxr | Unlicense | active |",
].join("\n"),
[{ rel: "catalog/tools/jsfxr.md", meta: { license: "Unlicense" } }]
)
);
rejects(
"V11 still catches the catalog row when a comparison table is present",
checkCategoryReadmeRows(
"tools",
[
"| If you want | Take | Over | Because |",
"| A retro SFX fast | [jsfxr](jsfxr.md) | sfxr | Browser, no install |",
"",
"| ID | Name | License | Status |",
"| [jsfxr](jsfxr.md) | jsfxr | public-domain | active |",
].join("\n"),
[{ rel: "catalog/tools/jsfxr.md", meta: { license: "Unlicense" } }]
),
'does not carry its license "Unlicense"'
);
rejects(
"V11 checks every listing table, not only the first",
checkCategoryReadmeRows(
"tools",
[
"## Editors",
"| ID | Name | License | Status |",
"| [tiled](tiled.md) | Tiled | GPL-2.0-or-later | active |",
"",
"## Godot 4 add-ons",
"| ID | Name | License | Status |",
"| [godot-mod-loader](godot-mod-loader.md) | Godot Mod Loader | MIT | active |",
].join("\n"),
[
{ rel: "catalog/tools/tiled.md", meta: { license: "GPL-2.0-or-later" } },
{ rel: "catalog/tools/godot-mod-loader.md", meta: { license: "CC0" } },
]
),
'row for "godot-mod-loader" does not carry its license "CC0"'
);
accepts(
"V11 stays quiet when the entry has no row (validate.mjs reports that)",
checkCategoryReadmeRows("tools", readme, [
{ rel: "catalog/tools/absent.md", meta: { license: "MIT" } },
])
);
/* V12 ------------------------------------------------------------------- */
rejects(
"V12 rejects an undocumented camera_perspective",
checkTaxonomyValues("bad.md", { camera_perspective: "isometric" }),
'camera_perspective "isometric" is not one of'
);
rejects(
"V12 rejects a grid_dimensions that is not WxH",
checkTaxonomyValues("bad.md", { grid_dimensions: "16px" }),
"is not WxH in pixels"
);
rejects(
"V12 rejects hardware_tags that is not a list",
checkTaxonomyValues("bad.md", { hardware_tags: "steam_deck" }),
"must be a list"
);
accepts(
"V12 accepts the documented values",
checkTaxonomyValues("ok.md", {
camera_perspective: "isometric_3_4",
grid_dimensions: "16x16",
hardware_tags: ["steam_deck"],
})
);
accepts("V12 stays quiet when the optional fields are absent", checkTaxonomyValues("ok.md", {}));
/* V13 ------------------------------------------------------------------- */
rejects(
"V13 rejects a format spelt two ways across entries",
checkValueSpellings([
{ rel: "a.md", meta: { formats: ["PNG", "glTF"] } },
{ rel: "b.md", meta: { formats: ["png"] } },
]),
'formats spells one value several ways: "PNG" (a.md), "png" (b.md)'
);
rejects(
"V13 rejects a subcategory that differs only by punctuation",
checkValueSpellings([
{ rel: "a.md", meta: { subcategories: ["field-recordings"] } },
{ rel: "b.md", meta: { subcategories: ["field_recordings"] } },
]),
"subcategories spells one value several ways"
);
rejects(
"V13 rejects a singular beside its plural",
checkValueSpellings([
{ rel: "a.md", meta: { subcategories: ["character"] } },
{ rel: "b.md", meta: { subcategories: ["characters"] } },
]),
'subcategories spells one value several ways: "character" (a.md), "characters" (b.md)'
);
rejects(
"V13 rejects a tag beside its plural",
checkValueSpellings([
{ rel: "a.md", meta: { tags: ["button"] } },
{ rel: "b.md", meta: { tags: ["buttons"] } },
]),
"tags spells one value several ways"
);
accepts(
"V13 accepts one spelling used many times",
checkValueSpellings([
{ rel: "a.md", meta: { formats: ["PNG"], subcategories: ["characters", "sfx"] } },
{ rel: "b.md", meta: { formats: ["PNG"], subcategories: ["characters", "glass"] } },
])
);
/* V14 ------------------------------------------------------------------- */
rejects(
"V14 rejects an active entry with unknown attribution",
checkActiveIsSettled("bad.md", { status: "active", license: "custom", commercial: true, attribution_required: "unknown" }),
"is active but attribution_required is unknown"
);
rejects(
"V14 rejects an active entry with an unknown licence",
checkActiveIsSettled("bad.md", { status: "active", license: "unknown", commercial: true, attribution_required: false }),
"is active but license is unknown"
);
accepts(
"V14 accepts unknowns on a needs-review entry",
checkActiveIsSettled("ok.md", { status: "needs-review", license: "unknown", commercial: "unknown", attribution_required: "unknown" })
);
accepts(
"V14 accepts a settled active entry",
checkActiveIsSettled("ok.md", { status: "active", license: "MIT", commercial: true, attribution_required: false })
);
/* V15 ------------------------------------------------------------------- */
const stackEntries = new Map([
["catalog/2d/good.md", { id: "good", status: "active" }],
["catalog/2d/old.md", { id: "old", status: "deprecated" }],
]);
const stackText = (pick, meta = {}) =>
`---\nid: ${meta.id || "s1"}\ntitle: T\ntask: A task.\nwalked: ${meta.walked || "2026-09-01"}\n---\n\nLead.\n\n${meta.section || "## Art"}\n\n${pick}\n`;
const goodPick = "- **Tiles:** [Good](../catalog/2d/good.md). Sixteen tiles.";
const oneStack = (text, rel = "stacks/s1.md") => checkStacks([{ rel, text }], stackEntries, ["MIT"], TODAY);
accepts("V15 accepts a good stack", oneStack(stackText(goodPick)));
rejects("V15 rejects a pick that is not an entry", oneStack(stackText("- **Tiles:** [Nope](../catalog/2d/nope.md). Why.")), 'stacks/s1.md:12: pick "../catalog/2d/nope.md" is not a catalog entry');
rejects("V15 rejects a deprecated pick", oneStack(stackText("- **Tiles:** [Old](../catalog/2d/old.md). Why.")), 'stacks/s1.md:12: pick "old" is deprecated');
rejects("V15 rejects a malformed pick line", oneStack(stackText("- Tiles: Good. Why.")), "stacks/s1.md:12: a pick line is");
rejects("V15 rejects an id that is not the filename", oneStack(stackText(goodPick), "stacks/other.md"), 'id "s1" does not match the filename');
rejects("V15 rejects a duplicate id", checkStacks([{ rel: "stacks/s1.md", text: stackText(goodPick) }, { rel: "stacks/s1.md", text: stackText(goodPick) }], stackEntries, [], TODAY), 'duplicate stack id "s1"');
rejects("V15 rejects a licence in a why sentence", oneStack(stackText("- **Tiles:** [Good](../catalog/2d/good.md). A MIT pack.")), 'names a licence ("MIT")');
rejects("V15 rejects a walked date in the future", oneStack(stackText(goodPick, { walked: "2099-01-01" })), "walked 2099-01-01 is in the future");
rejects("V15 rejects an unknown section", oneStack(stackText(goodPick, { section: "## Levels" })), 'section "Levels" is not one of');
/* V8: evidence dates are prose dates, and real ------------------------- */
const V8_META = { verified: "2026-09-01" };
accepts(
"V8 ignores a date inside a link target",
checkEvidenceDates("ok.md", V8_META, "\n## Evidence\n\n- [Notes](https://x.test/releases/2026-09-20-notes) (2026-09-01): \"CC0\"\n", TODAY)
);
accepts(
"V8 ignores a date inside a bare URL",
checkEvidenceDates("ok.md", V8_META, "\n## Evidence\n\n- Live page (2026-09-01): https://x.test/2099-01-01/post\n", TODAY)
);
rejects(
"V8 still sees a bumped verified behind a URL date",
checkEvidenceDates("bad.md", { verified: "2026-09-20" }, "\n## Evidence\n\n- Live page (2026-09-01): https://x.test/2026-09-20/\n", TODAY),
"newer than its newest Evidence date 2026-09-01"
);
rejects(
"V8 rejects an impossible Evidence date",
checkEvidenceDates("bad.md", { verified: "2026-02-01" }, EV("2026-02-30"), TODAY),
"2026-02-30 is not a real YYYY-MM-DD date"
);
eq(
"evidenceDates reads prose dates only",
evidenceDates("- [a](https://x/2020-01-01) (2026-01-02) and <https://y/2021-01-01> 2026-01-03").join(","),
"2026-01-02,2026-01-03"
);
/* V16: url scheme ------------------------------------------------------ */
rejects("V16 rejects javascript:", checkEntryUrl("bad.md", { url: "javascript:alert(1)" }), "must be https://");
rejects("V16 rejects data:", checkEntryUrl("bad.md", { url: "data:text/html,<script>x</script>" }), "must be https://");
rejects("V16 rejects a relative url", checkEntryUrl("bad.md", { url: "/downloads" }), "is not an absolute URL");
accepts("V16 accepts https", checkEntryUrl("ok.md", { url: "https://kenney.nl/assets" }));
rejects("V16 rejects localhost", checkEntryUrl("bad.md", { url: "http://localhost:8080/x" }), "must be a public site");
rejects("V16 rejects an IPv4 literal", checkEntryUrl("bad.md", { url: "http://169.254.169.254/latest" }), "must be a public site");
rejects("V16 rejects an IPv6 literal", checkEntryUrl("bad.md", { url: "http://[::1]/" }), "must be a public site");
rejects("V16 rejects .local", checkEntryUrl("bad.md", { url: "https://nas.local/files" }), "must be a public site");
accepts("V16 accepts a digit-led host", checkEntryUrl("ok.md", { url: "https://3dtexel.com/" }));
accepts("V16 accepts http where a source has no https", checkEntryUrl("ok.md", { url: "http://www.makehumancommunity.org/" }));
/* V17: category sets --------------------------------------------------- */
accepts(
"V17 accepts matching sets",
checkCategorySets({ dirs: ["2d", "3d"], configured: ["3d", "2d"], formOptions: ["2d", "3d"] })
);
rejects(
"V17 rejects a folder missing from config",
checkCategorySets({ dirs: ["2d", "video"], configured: ["2d"], formOptions: null }),
"catalog/video/ is not in site/config.json"
);
rejects(
"V17 rejects a config category with no folder",
checkCategorySets({ dirs: ["2d"], configured: ["2d", "vfx"], formOptions: null }),
'category "vfx" has no catalog/vfx/ folder'
);
rejects(
"V17 rejects an issue form missing a category",
checkCategorySets({ dirs: ["2d", "video"], configured: ["2d", "video"], formOptions: ["2d"] }),
'leave out "video"'
);
/* V18: markdown anchors ------------------------------------------------ */
const anchors = markdownAnchors(
"# Top\n\n## Choosing a pixel tileset\n\n## Notes\n\n## Notes\n\n```\n## Not a heading\n```\n\n### Fonts & `OFL` [link](x.md)\n\n<a id=\"custom\"></a>\n"
);
eq("V18 slugs a heading", anchors.has("choosing-a-pixel-tileset"), true);
eq("V18 numbers a repeated heading", anchors.has("notes") && anchors.has("notes-1"), true);
eq("V18 skips fenced code", anchors.has("not-a-heading"), false);
eq("V18 drops punctuation and link syntax", anchors.has("fonts--ofl-link"), true);
eq("V18 reads explicit ids", anchors.has("custom"), true);
/* V13: -es and -ies plurals -------------------------------------------- */
const rec = (rel, subcategories) => ({ rel, meta: { subcategories } });
rejects(
"V13 joins an -es plural to its singular",
checkValueSpellings([rec("a.md", ["base-mesh"]), rec("b.md", ["base-meshes"])], ["subcategories"]),
'"base-mesh" (a.md), "base-meshes" (b.md)'
);
rejects(
"V13 joins an -ies plural to its singular",
checkValueSpellings([rec("a.md", ["category"]), rec("b.md", ["categories"])], ["subcategories"]),
"spells one value several ways"
);
accepts(
"V13 does not strip -es from a word that is not a sibilant plural",
checkValueSpellings([rec("a.md", ["shade"]), rec("b.md", ["shades"]), rec("c.md", ["shad"])], ["subcategories"]).filter((e) => e.includes('"shad"'))
);
accepts(
"V13 leaves an -ies word alone when no singular is in use",
checkValueSpellings([rec("a.md", ["movies"]), rec("b.md", ["movie"])], ["subcategories"]).filter((e) => e.includes("movy"))
);
/* V19: retired spellings ----------------------------------------------- */
const aliases = JSON.parse(fs.readFileSync(path.join(__dirname, "value-aliases.json"), "utf8"));
rejects("V19 rejects a retired subcategory", checkValueAliases("bad.md", { subcategories: ["tiles"] }, aliases), 'use "tileset"');
rejects("V19 rejects a retired format", checkValueAliases("bad.md", { formats: ["JPEG"] }, aliases), 'use "JPG"');
rejects("V19 rejects a licence as a subcategory", checkValueAliases("bad.md", { subcategories: ["public-domain"] }, aliases), "a licence, not a kind of content");
rejects("V19 rejects an internal review tag", checkValueAliases("bad.md", { tags: ["r04"] }, aliases), "internal review marker");
accepts("V19 lets a tag use a word retired only as a subcategory", checkValueAliases("ok.md", { tags: ["tiles", "gui"] }, aliases));
rejects("V19 rejects a tag that restates the licence", checkValueAliases("bad.md", { tags: ["cc0"] }, aliases), 'tags must not carry "cc0"');
accepts("V19 keeps a tag that only mentions a licence word", checkValueAliases("ok.md", { tags: ["odbl-adjacent", "free-tier"] }, aliases));
/* Licence families: every licence in exactly one Licence-filter group ---- */
await section("Licence families: every licence in exactly one Licence-filter group", async () => {
const fams = Object.entries(vocab.families).filter(([k]) => !k.startsWith("_"));
const homeless = Object.keys(vocab.licenses).filter((l) => fams.filter(([, f]) => f.licenses.includes(l)).length !== 1);
accepts("every licence value sits in exactly one family", homeless);
const unknown = fams.flatMap(([, f]) => f.licenses).filter((l) => !(l in vocab.licenses));
accepts("families name only licence values the vocabulary has", unknown);
});
/* V22: maintenance ------------------------------------------------------ */
rejects("V22 rejects an unknown maintenance value", checkMaintenance("bad.md", { maintenance: "dead" }), 'maintenance "dead" is not one of archived | inactive');
accepts("V22 accepts archived", checkMaintenance("ok.md", { maintenance: "archived" }));
accepts("V22 leaves the field optional", checkMaintenance("ok.md", {}));
await section("block at line 773", async () => {
const now = Date.parse("2026-09-26T00:00:00Z");
const same = (label, actual, expected) => (actual === expected ? accepts(label, []) : accepts(label, [`got ${actual}, want ${expected}`]));
same("an archived repo is archived", maintenanceFromRepo({ archived: true, pushed_at: "2026-09-01T00:00:00Z" }, now), "archived");
same("no push in over three years is inactive", maintenanceFromRepo({ archived: false, pushed_at: "2023-01-01T00:00:00Z" }, now), "inactive");
same("a recent push is neither", maintenanceFromRepo({ archived: false, pushed_at: "2025-01-01T00:00:00Z" }, now), null);
});
/* V23: engine fields ---------------------------------------------------- */
rejects("V23 rejects an unknown engine_lock", checkEngineFields("bad.md", { engine_lock: "unity" }), 'engine_lock "unity" is not one of unreal');
rejects("V23 rejects a malformed ue_versions", checkEngineFields("bad.md", { ue_versions: "UE5" }), 'ue_versions "UE5" is not X.Y, X.Y-X.Y or X.Y+');
rejects("V23 rejects a backwards range", checkEngineFields("bad.md", { ue_versions: "5.8-5.4" }), 'ue_versions "5.8-5.4" runs backwards');
accepts("V23 accepts a range", checkEngineFields("ok.md", { engine_lock: "unreal", ue_versions: "5.4-5.8" }));
accepts("V23 accepts an open range", checkEngineFields("ok.md", { ue_versions: "5.6+" }));
accepts("V23 accepts a single version", checkEngineFields("ok.md", { ue_versions: "5.8" }));
accepts("V23 compares minor versions numerically", checkEngineFields("ok.md", { ue_versions: "5.9-5.10" }));
accepts("V23 leaves both fields optional", checkEngineFields("ok.md", {}));
rejects("V23 rejects a GPL Unreal plugin", checkEngineFields("bad.md", { license: "GPL-3.0-only", formats: ["unreal-plugin"] }), "forbids combining the engine with GPL/LGPL code");
accepts("V23 allows a GPL standalone tool", checkEngineFields("ok.md", { license: "GPL-3.0-only", formats: ["desktop-app"] }));
/* V21: tag restating the publisher ------------------------------------- */
rejects("V21 rejects the publisher as a tag", checkTagsRestatePublisher("bad.md", { publisher: "Blender Studio", tags: ["blender-studio", "open-movie"] }), 'tag "blender-studio" restates publisher');
accepts("V21 allows another publisher's name as a tag", checkTagsRestatePublisher("ok.md", { publisher: "Envato", tags: ["kenney-style"] }));
accepts("V21 ignores an entry with no publisher", checkTagsRestatePublisher("ok.md", { tags: ["kenney"] }));
/* V20: closed format list ---------------------------------------------- */
const formatVocab = JSON.parse(fs.readFileSync(path.join(__dirname, "format-vocabulary.json"), "utf8"));
rejects("V20 rejects a format missing from the vocabulary", checkFormatVocabulary("bad.md", { formats: ["glTF KHR_draco"] }, formatVocab), 'formats "glTF KHR_draco" is not in site/format-vocabulary.json');
rejects("V20 is case-sensitive", checkFormatVocabulary("bad.md", { formats: ["png"] }, formatVocab), 'formats "png"');
accepts("V20 accepts listed formats", checkFormatVocabulary("ok.md", { formats: ["PNG", "glTF", "GLB"] }, formatVocab));
accepts(
"V20 vocabulary lists every format a filter group names",
Object.values(formatVocab.groups).flatMap((g) => g.formats).filter((f) => !formatVocab.formats.includes(f))
);
accepts(
"V20 vocabulary carries no retired spelling",
formatVocab.formats.filter((f) => Object.prototype.hasOwnProperty.call(aliases.formats, f))
);
/* V24: field types (#79) ------------------------------------------------ */
rejects("V24 rejects tags that parsed as text", checkFieldTypes("bad.md", { tags: "[a, b] # note" }), "tags must be a list");
rejects("V24 rejects a subcategories string", checkFieldTypes("bad.md", { subcategories: "models" }), "subcategories must be a list");
rejects("V24 rejects a quoted boolean", checkFieldTypes("bad.md", { commercial: "true" }), "write commercial: true without quotes");
rejects("V24 rejects a quoted attribution_required", checkFieldTypes("bad.md", { attribution_required: "false" }), "write attribution_required: false without quotes");
rejects("V24 rejects an unknown commercial word", checkFieldTypes("bad.md", { commercial: "maybe" }), 'commercial "maybe" is not true|false|varies|unknown');
accepts("V24 accepts lists and booleans", checkFieldTypes("ok.md", { tags: ["a"], subcategories: ["b"], formats: ["PNG"], commercial: true, attribution_required: false }));
accepts("V24 accepts the literal words", checkFieldTypes("ok.md", { commercial: "varies", attribution_required: "unknown" }));
accepts("V24 leaves missing fields to the required check", checkFieldTypes("ok.md", {}));
/* V26: added date (#90) ------------------------------------------------- */
rejects("V26 rejects a non-date", checkAddedDate("bad.md", { added: "July" }, TODAY), 'added "July" is not a real YYYY-MM-DD date');
rejects("V26 rejects a future date", checkAddedDate("bad.md", { added: "2027-01-01" }, TODAY), "added 2027-01-01 is in the future");
accepts("V26 accepts a past date", checkAddedDate("ok.md", { added: "2026-07-19" }, TODAY));
accepts("V26 leaves a missing field to the required check", checkAddedDate("ok.md", {}, TODAY));
/* V25: heading matches name (#95) --------------------------------------- */
rejects("V25 rejects a heading that differs from name", checkTitleMatchesName("bad.md", { name: "KayKit (Kay Lousberg)" }, "\n# KayKit\n\nText"), 'heading "# KayKit" differs from name "KayKit (Kay Lousberg)"');
rejects("V25 rejects a body with no heading", checkTitleMatchesName("bad.md", { name: "X" }, "Just text"), "has no \"# X\" heading");
accepts("V25 accepts a matching heading", checkTitleMatchesName("ok.md", { name: "KayKit (Kay Lousberg)" }, "\n# KayKit (Kay Lousberg)\n\n## Notes"));
accepts("V25 ignores a missing name", checkTitleMatchesName("ok.md", {}, "# Anything"));
/* Thumbnails: the manifest, the files and the gate must agree ------------- */
import { checkPreviewField, checkThumbManifest } from "./checks.mjs";
await section("block at line 836", async () => {
const okEntry = { id: "a", license: "CC0", status: "active", url: "https://a.itch.io/x" };
const manifest = { thumbs: { a: { fetched: "2026-10-01", license: "CC0", hash: "h", width: 640, height: 400, source: "https://a.itch.io/x", image: "https://i/a.png" } } };
accepts("thumbs manifest: file and record agree", checkThumbManifest(manifest, new Map([["a", okEntry]]), ["a.webp"]));
accepts("thumbs manifest: nothing at all", checkThumbManifest(null, new Map([["a", okEntry]]), []));
rejects("thumbs manifest: file without record", checkThumbManifest({ thumbs: {} }, new Map([["a", okEntry]]), ["a.webp"]), "site/public/thumbs/a.webp has no record in site/thumbs.json");
rejects("thumbs manifest: record without file", checkThumbManifest(manifest, new Map([["a", okEntry]]), []), 'site/thumbs.json has "a" but site/public/thumbs/a.webp is missing');
rejects("thumbs manifest: record for unknown entry", checkThumbManifest(manifest, new Map(), ["a.webp"]), 'site/thumbs.json has "a" but no catalog entry has that id');
rejects("thumbs manifest: rejects a thumbnail whose entry is no longer eligible", checkThumbManifest(manifest, new Map([["a", { ...okEntry, license: "custom" }]]), ["a.webp"]), 'thumbnail for "a" must be removed: licence custom is not in the preview allowlist (run node site/thumbs.mjs)');
accepts("thumbs manifest: licence drift between two allowed licences is not an error", checkThumbManifest(manifest, new Map([["a", { ...okEntry, license: "MIT" }]]), ["a.webp"]));
rejects("thumbs manifest: stray file", checkThumbManifest(manifest, new Map([["a", okEntry]]), ["a.webp", "notes.txt"]), "site/public/thumbs/notes.txt is not a <id>.webp thumbnail");
});
accepts("preview field: absent", checkPreviewField("ok.md", {}));
accepts("preview field: none", checkPreviewField("ok.md", { preview: "none" }));
accepts("preview field: https url", checkPreviewField("ok.md", { preview: "https://a/b.png" }));
rejects("preview field: http refused", checkPreviewField("bad.md", { preview: "http://a/b.png" }), 'bad.md preview must be "none" or an https:// image URL');
rejects("preview field: loopback refused", checkPreviewField("bad.md", { preview: "https://127.0.0.1/a.png" }), "bad.md preview must be an https:// image URL on a public host");
rejects("preview field: an unparseable https url is refused, not thrown", checkPreviewField("bad.md", { preview: "https://exa%zzmple.com/a.png" }), "bad.md preview must be an https:// image URL on a public host");
rejects("preview field: bad port refused", checkPreviewField("bad.md", { preview: "https://a.test:99999/x.png" }), "bad.md preview must be an https:// image URL on a public host");
rejects("preview field: an unclosed IPv6 bracket is refused, not thrown", checkPreviewField("bad.md", { preview: "https://[bad" }), "bad.md preview must be an https:// image URL on a public host");
rejects("preview field: credentials in the URL refused", checkPreviewField("bad.md", { preview: "https://u:p@a.example/b.png" }), "bad.md preview must be an https:// image URL on a public host");
rejects("preview field: word refused", checkPreviewField("bad.md", { preview: "yes" }), 'bad.md preview must be "none" or an https:// image URL');
/* V30: line endings ------------------------------------------------------ */
accepts("V30 accepts LF-only text", checkLineEndings("ok.md", "---\nid: a\n---\n\nBody\n"));
rejects("V30 rejects CRLF and names the first line", checkLineEndings("bad.md", "---\nid: a\r\n---\n"), "bad.md:2 has a CR line ending");
rejects("V30 rejects a lone CR", checkLineEndings("bad.md", "one\rtwo\n"), "bad.md:1 has a CR line ending");
/* repository files: binaries and symlinks (#229, symlinks) ---------------- */
accepts("repo files: text and allowed binaries pass", checkRepoFiles([{ rel: "catalog/2d/a.md" }, { rel: "site/public/fonts/x.woff2" }, { rel: "docs/images/readme/hero.png" }]));
rejects("repo files: a binary at any depth is refused", checkRepoFiles([{ rel: "catalog/2d/dist/pack.zip" }]), "binary asset file: catalog/2d/dist/pack.zip");
rejects("repo files: a binary in a dot folder is refused", checkRepoFiles([{ rel: ".github/foo.ZIP" }]), "binary asset file: .github/foo.ZIP");
rejects("repo files: a symlink is refused", checkRepoFiles([{ rel: "site/public/leak.txt", symlink: true }]), "symlink in the repository: site/public/leak.txt");
accepts("repo files: a dot in a folder name is not an extension", checkRepoFiles([{ rel: "docs/v1.png/README" }]));
/* V31: non-commercial entries quote the restriction ----------------------- */
accepts("V31 ignores commercial: true", checkNonCommercialEvidence("ok.md", { status: "active", commercial: true }, "## Evidence\n\n- Live page (2026-01-01): \"free\"\n"));
accepts("V31 ignores needs-review", checkNonCommercialEvidence("ok.md", { status: "needs-review", commercial: false }, "## Evidence\n\n- Live page (2026-01-01): \"free\"\n"));
accepts("V31 accepts a quoted restriction", checkNonCommercialEvidence("ok.md", { status: "active", commercial: false }, "## Evidence\n\n- Live About (2026-01-01): \"as long as you don't use these commercially\"\n"));
rejects("V31 rejects an unquoted restriction", checkNonCommercialEvidence("bad.md", { status: "active", commercial: false }, "## Evidence\n\n- Live page (2026-01-01): \"free download\"\n"), "bad.md is active with commercial: false but no Evidence line mentions the commercial restriction");
/* V1: per-entry basics (validate.mjs) --------------------------------------- */
await section("V1: per-entry basics (validate.mjs)", async () => {
const good = {
id: "foo", name: "Foo", url: "https://a.example/", category: "2d", subcategories: ["sprites"], license: "CC0",
commercial: true, attribution_required: false, formats: ["PNG"], tags: ["pixel"], added: "2026-01-01",
verified: "2026-02-01", status: "active",
};
const ev = "## Evidence\n\n- License page (2026-02-01): \"CC0\"\n";
const ctx = { stem: "foo", dirName: "2d", categories: new Set(["2d", "3d"]), readmeText: "| [Foo](foo.md) |", today: "2026-03-01" };
const basics = (meta, over = {}, body = ev) => checkEntryBasics("catalog/2d/foo.md", { ...good, ...meta }, body, { ...ctx, ...over });
accepts("V1 accepts a complete entry", basics({}));
rejects("V1 rejects a missing required key", basics({ tags: [] }), "missing/empty: tags");
rejects("V1 rejects whitespace as empty", basics({ name: " " }), "missing/empty: name");
rejects("V1 rejects an id that is not the filename", basics({ id: "bar" }), 'id "bar" does not match filename');
rejects("V1 rejects an id that is not kebab-case", basics({ id: "Foo_Bar" }, { stem: "Foo_Bar", readmeText: "(Foo_Bar.md)" }), "must be short kebab-case");
rejects("V1 rejects a category that is not the directory", basics({ category: "3d" }), 'category "3d" does not match directory');
rejects("V1 rejects an unknown category", basics({ category: "music" }, { dirName: "music" }), 'category "music" is not a catalog/ directory');
rejects("V1 rejects a capitalised status", basics({ status: "Active" }), 'status "Active" is not active|needs-review|deprecated');
rejects("V1 rejects an unknown status", basics({ status: "retired" }), 'status "retired" is not');
rejects("V1 rejects a credit requirement with no credit line", basics({ attribution_required: true }), "attribution_required true needs attribution_string");
rejects("V1 rejects a blank credit line", basics({ attribution_required: true, attribution_string: " " }), "needs attribution_string");
accepts("V1 accepts a credit requirement with a credit line", basics({ attribution_required: true, attribution_string: "Foo by Bar" }));
rejects("V1 rejects an impossible verified date", basics({ verified: "2026-02-30" }), 'verified "2026-02-30" is not a real YYYY-MM-DD date');
rejects("V1 rejects a verified date in the future", basics({ verified: "2026-03-02" }), "verified 2026-03-02 is in the future");
accepts("V1 accepts verified on the latest allowed day", basics({ verified: "2026-03-01" }));
rejects("V1 rejects an active entry without Evidence", basics({}, {}, "No evidence here.\n"), "active entry missing ## Evidence");
rejects("V1 rejects active Evidence with no date", basics({}, {}, "## Evidence\n\n- License page: \"CC0\"\n"), "active Evidence section has no YYYY-MM-DD date");
accepts("V1 accepts a needs-review entry without Evidence", basics({ status: "needs-review" }, {}, "Pending.\n"));
rejects("V1 rejects an entry missing from its README", basics({}, { readmeText: "| [Other](other.md) |" }), "not listed in category README.md");
rejects("V1 rejects a missing category README", basics({}, { readmeText: null }), "category README.md missing");
accepts("V1 featured ids that resolve", checkFeatured(["foo", { id: "bar", need: "x" }], new Set(["foo", "bar"])));
rejects("V1 featured id that does not resolve", checkFeatured([{ id: "nope" }], new Set(["foo"])), 'featured id "nope" does not resolve');
rejects("V1 featured item without an id", checkFeatured([{ need: "x" }], new Set(["foo"])), 'featured id "undefined" does not resolve');
});
/* V11: comparison tables with a Licence column ------------------------------ */
await section("V11: comparison tables with a Licence column", async () => {
const metas = new Map([
["catalog/3d/ambientcg.md", { license: "CC0" }],
["catalog/environment/poly-haven.md", { license: "CC0" }],
["catalog/characters/rocketbox.md", { license: "MIT" }],
["catalog/3d/sharetextures.md", { license: "custom" }],
["catalog/3d/ccby.md", { license: "CC-BY" }],
]);
const table = (rows) => ["| If you need | Take | Licence |", "| --- | --- | --- |", ...rows].join("\n");
accepts("V11 accepts matching comparison rows, bold and notes included", checkComparisonLicences("3d", table([
"| A | [ambientcg](ambientcg.md): materials | **CC0** |",
"| B | [poly-haven](../environment/poly-haven.md) | **CC0** exports |",
"| C | [rb](../characters/rocketbox.md) | MIT, keep the notice |",
"| D | [st](sharetextures.md) | custom |",
]), metas));
rejects("V11 rejects a comparison row with a different licence", checkComparisonLicences("3d", table(["| A | [st](sharetextures.md) | **CC0** |"]), metas), 'comparison row says "CC0" but catalog/3d/sharetextures.md has license "custom"');
rejects("V11 a longer licence does not pass for a shorter one", checkComparisonLicences("3d", table(["| A | [x](ccby.md) | CC-BY-4.0 |"]), metas), 'has license "CC-BY"');
accepts("V11 ignores links right of the Licence column", checkComparisonLicences("3d", ["| Take | Licence | Notes |", "| --- | --- | --- |", "| [a](ambientcg.md) | CC0 | see [st](sharetextures.md) |"].join("\n"), metas));
accepts("V11 ignores tables without a Licence column", checkComparisonLicences("3d", ["| Take | Notes |", "| --- | --- |", "| [st](sharetextures.md) | CC0 |"].join("\n"), metas));
accepts("V11 leaves the ID listing to checkCategoryReadmeRows", checkComparisonLicences("3d", ["| ID | Licence |", "| --- | --- |", "| [st](sharetextures.md) | CC0 |"].join("\n"), metas));
});
/* V34: preview allowlist agrees with the vocabulary ------------------------ */
accepts("V34 the real allowlist matches the real vocabulary", checkPreviewVocabulary(vocab));
rejects("V34 rejects an allowlisted licence missing from the vocabulary", checkPreviewVocabulary({ licenses: {} }, ["CC-BY-SA-4.0"], () => true), '"CC-BY-SA-4.0", which is not in site/license-vocabulary.json');
rejects("V34 rejects a required licence the caption would not credit", checkPreviewVocabulary({ licenses: { "OGA-BY-3.0": { attribution: "required" } } }, ["OGA-BY-3.0"], () => false), "would lack the creator credit");
rejects("V34 rejects a credit on a licence that does not ask for one", checkPreviewVocabulary({ licenses: { MIT: { attribution: "notice" } } }, ["MIT"], () => true), "carry a credit the licence does not ask for");
/* V38: a waived credit on a BY licence is quoted --------------------------- */
await section("V38: a waived credit on a BY licence is quoted", async () => {
const v = { licenses: { "CC-BY-4.0": { attribution: "required" }, MIT: { attribution: "notice" } } };
const meta = { license: "CC-BY-4.0", attribution_required: false };
accepts("V38 accepts a dated waiver quote", checkAttributionWaiver("ok.md", meta, "## Evidence\n\n- Page (2026-11-03): \"You do NOT have to credit me.\"\n", v));
accepts("V38 ignores required credit", checkAttributionWaiver("ok.md", { ...meta, attribution_required: true }, "", v));
accepts("V38 ignores a licence that does not require credit", checkAttributionWaiver("ok.md", { license: "MIT", attribution_required: false }, "", v));
rejects("V38 rejects a waiver stated only in Notes", checkAttributionWaiver("bad.md", meta, "## Notes\n\n- Attribution waived\n\n## Evidence\n\n- Page (2026-08-24): \"CC BY 4.0\"\n", v), "quote the rights holder's waiver");
rejects("V38 rejects an undated waiver line", checkAttributionWaiver("bad.md", meta, "## Evidence\n\n- Page: \"credit is optional\"\n", v), "quote the rights holder's waiver");
});
/* V37: AI-generated content stays tagged and listed ------------------------ */
accepts("V37 accepts a tagged entry", checkAiTag("ok.md", { tags: ["ai-generated"] }, "Some sounds are AI-generated."));
accepts("V37 ignores a denial", checkAiTag("ok.md", { tags: [] }, "itch metadata: No generative AI was used. The audio is not AI-generated."));
accepts("V37 ignores a mention that is not a claim", checkAiTag("ok.md", { tags: [] }, "Built for AI-generated pixel art that is off-grid."));
rejects("V37 rejects an untagged claim", checkAiTag("bad.md", { tags: ["loops"] }, "- Some library sounds are AI-generated and labelled."), "has no ai-generated tag");
rejects("V37 rejects a partly-AI claim", checkAiTag("bad.md", {}, "The pack is partly AI-generated."), "has no ai-generated tag");
accepts("V37 accepts a guide that links every tagged entry", checkAiGuide("- [S](../catalog/audio/s.md)", ["catalog/audio/s.md"]));
rejects("V37 rejects a guide missing a tagged entry", checkAiGuide("nothing", ["catalog/audio/s.md"]), "does not link catalog/audio/s.md");
/* V36: limits is one short plain line ------------------------------------- */
accepts("V36 accepts a short plain line", checkLimits("ok.md", { limits: "Tree packs are Unreal-only; no standalone redistribution" }));
accepts("V36 ignores a missing field", checkLimits("ok.md", {}));
rejects("V36 rejects a non-string", checkLimits("bad.md", { limits: true }), "must be a quoted line of text");
rejects("V36 rejects a long line", checkLimits("bad.md", { limits: "x".repeat(121) }), "over 120");
rejects("V36 rejects markdown", checkLimits("bad.md", { limits: "See [the notes](x) for more" }), "plain text");
rejects("V36 rejects a closing full stop", checkLimits("bad.md", { limits: "Unreal-only in practice." }), "ends with punctuation");
rejects("V36 rejects a near-empty line", checkLimits("bad.md", { limits: "no" }), "too short");
/* V35: credit-line placeholders use {name} ---------------------------------- */
accepts("V35 accepts {field} placeholders", checkCreditPlaceholders("ok.md", { attribution_string: '"{title}" by Kevin MacLeod ({MM/YYYY})' }));
accepts("V35 accepts an address in angle brackets", checkCreditPlaceholders("ok.md", { attribution_string: "EzSpriteSheet <z64.me>" }));
accepts("V35 ignores a missing line", checkCreditPlaceholders("ok.md", {}));
rejects("V35 rejects square brackets", checkCreditPlaceholders("bad.md", { attribution_string: "[Font name] by X" }), 'marks "[Font name]" with square brackets');
rejects("V35 rejects angle-bracket fields", checkCreditPlaceholders("bad.md", { attribution_string: "@fontsource/<family>" }), "angle brackets");
rejects("V35 rejects a bare date pattern", checkCreditPlaceholders("bad.md", { attribution_string: "Data MM/YYYY" }), "a date pattern");
rejects("V35 rejects a parenthesised description", checkCreditPlaceholders("bad.md", { attribution_string: "By X (sound page URL)" }), "a parenthesised description");
rejects("V35 rejects an unmatched brace", checkCreditPlaceholders("bad.md", { attribution_string: "By {artist" }), "unmatched or nested brace");
/* V33: no unknown frontmatter keys ------------------------------------------ */
accepts("V33 accepts the documented keys", checkKnownKeys("ok.md", { id: "a", engine_lock: "unreal", attribution_string: "x", preview: "none" }));
rejects("V33 rejects a hyphenated key and names the real one", checkKnownKeys("bad.md", { "engine-lock": "unreal" }), 'unknown frontmatter key "engine-lock" (did you mean "engine_lock"?)');
rejects("V33 rejects a misspelt key and names the real one", checkKnownKeys("bad.md", { attribution_strng: "x" }), 'did you mean "attribution_string"?');
rejects("V33 rejects an unrelated key without a guess", checkKnownKeys("bad.md", { colour: "red" }), 'unknown frontmatter key "colour"; the allowed keys');
eq("V33 closestKnownKey normalises case and hyphens", closestKnownKey("License-SPDX"), "license_spdx");
eq("V33 closestKnownKey gives up on distant words", closestKnownKey("zzzzzz"), null);
/* V32: the licence guide covers the vocabulary ---------------------------- */
accepts("V32 accepts a guide naming every value", checkLicenceGuide({ licenses: { MIT: {}, "CC-BY": {} } }, "| **MIT** | yes |\n| **CC-BY** | yes |"));
rejects("V32 rejects a missing value", checkLicenceGuide({ licenses: { MIT: {}, ISC: {} } }, "| **MIT** | yes |"), 'does not mention the licence value "ISC"');
rejects("V32 a longer value does not count for its prefix", checkLicenceGuide({ licenses: { "CC-BY": {} } }, "| **CC-BY-4.0** | yes |"), 'does not mention the licence value "CC-BY"');
/* validate's file-level checks, moved here to be tested (#224) ----------- */
await section("validate's file-level checks, moved here to be tested (#224)", async () => {
const { parseFrontmatter } = await import("./lib/frontmatter.mjs");
const { EXTERNAL_SCHEME_RE, ANY_SCHEME_RE } = await import("./lib/shared.mjs");
const { markdownAnchors: anchors } = await import("./checks.mjs");
eq("emoji: the (c), (r) and tm signs are not emoji", hasEmoji("© ® ™"), false);
eq("emoji: an emoji is", hasEmoji("ship it \u{1F680}"), true);
const good = "---\nid: a\n---\n\nBody\twith a tab\n";