paperlint 20.1.0 → 20.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.github/workflows/ci.yml +7 -0
  3. package/CLAUDE.md +2 -2
  4. package/CONTRIBUTING.md +2 -2
  5. package/{action.harness.mjs → action.test.mjs} +147 -138
  6. package/dist/domain/paper-layout.d.ts +18 -6
  7. package/dist/domain/paper-layout.d.ts.map +1 -1
  8. package/dist/domain/paper-layout.js +44 -38
  9. package/dist/domain/paper-layout.js.map +1 -1
  10. package/dist/eslint-rules/papers.js +1 -1
  11. package/dist/folder-layout-hook.js +1 -1
  12. package/dist/latex-log.d.ts +1 -1
  13. package/dist/latex-log.js +1 -1
  14. package/dist/latex-loop.d.ts +1 -1
  15. package/dist/latex-loop.js +1 -1
  16. package/dist/lib/paper-config.d.ts +3 -3
  17. package/dist/lib/paper-config.js +3 -3
  18. package/docs/e2e.md +9 -9
  19. package/docs/install.md +11 -11
  20. package/docs/rules/paper/allowed-files-only.md +31 -28
  21. package/docs/testing.md +3 -4
  22. package/eslint-rules/{install-path-literals.harness.mjs → install-path-literals.test.mjs} +14 -13
  23. package/eslint-rules/{latex-language.harness.mjs → latex-language-rules.test.mjs} +61 -51
  24. package/eslint-rules/{paper-stages.harness.mjs → paper-stages-rule.test.mjs} +66 -69
  25. package/eslint-rules/{papers.harness.mjs → papers.test.mjs} +41 -30
  26. package/eslint-rules/papers.ts +1 -1
  27. package/eslint-rules/{pdf-last-page-balance.harness.mjs → pdf-last-page-balance.test.mjs} +27 -15
  28. package/eslint-rules/{temp-root-realpath.harness.mjs → temp-root-realpath.test.mjs} +24 -24
  29. package/eslint-rules/{tex-build.harness.mjs → tex-build.test.mjs} +292 -271
  30. package/eslint.config.mjs +15 -2
  31. package/fixtures/pdf-facts/README.md +1 -1
  32. package/fixtures/render-paper/build-clean.sh +1 -1
  33. package/fixtures/toolchain-mirror/install-tl +1 -1
  34. package/lib/{agent-cli-version.harness.mjs → agent-cli-version.test.mjs} +17 -18
  35. package/lib/{paper-config.harness.mjs → paper-config.test.mjs} +21 -20
  36. package/lib/paper-config.ts +3 -3
  37. package/lib/{skill-trigger-cases.harness.mjs → skill-trigger-cases-carrier.test.mjs} +78 -115
  38. package/package.json +3 -3
  39. package/presets/acm-acmsmall.jsonc +1 -1
  40. package/scripts/check-workflow.test.ts +368 -0
  41. package/scripts/check.ts +2 -2
  42. package/scripts/eslint-file-length.mjs +9 -9
  43. package/scripts/eslint-report-guard.mjs +1 -1
  44. package/scripts/eslint-report-guard.test.mjs +1 -1
  45. package/scripts/harness-api.test.ts +7 -46
  46. package/scripts/{rules-see-files.harness.mjs → rules-see-files-rule.test.mjs} +10 -6
  47. package/scripts/rules-see-files.mjs +1 -1
  48. package/skills/paper-pipeline/{paper-pipeline.harness.mjs → paper-pipeline.test.mjs} +45 -46
  49. package/skills/paper-pipeline/scripts/{consumer.harness.mjs → consumer-paths.test.mjs} +66 -59
  50. package/skills/paper-pipeline/scripts/consumer.mjs +3 -3
  51. package/skills/paper-pipeline/scripts/{extract-ref-facts.harness.mjs → extract-ref-facts-cli.test.mjs} +29 -31
  52. package/skills/paper-pipeline/scripts/fixtures/real-bib/refs.bib +1 -1
  53. package/skills/paper-pipeline/scripts/{generated-code.harness.mjs → generated-code-fixtures.test.mjs} +39 -46
  54. package/skills/render-paper/{extract-pdf-facts.harness.ts → extract-pdf-facts.test.ts} +20 -13
  55. package/skills/render-paper/{render-paper.harness.mjs → render-paper.test.mjs} +41 -40
  56. package/src/adapters/pdfjs/fill.test.ts +1 -1
  57. package/src/{build-engine.harness.mjs → build-engine-prepare.test.mjs} +98 -81
  58. package/src/{build.harness.mjs → build-fake-tex.test.mjs} +61 -28
  59. package/src/{cli.harness.mjs → cli-e2e.test.mjs} +109 -103
  60. package/src/cli.test.ts +2 -2
  61. package/src/{doctor.harness.mjs → doctor-install.test.mjs} +28 -29
  62. package/src/domain/paper-layout.test.ts +89 -49
  63. package/src/domain/paper-layout.ts +61 -42
  64. package/src/{engine.harness.mjs → engine.test.mjs} +120 -106
  65. package/src/facts-file.test.ts +1 -1
  66. package/src/folder-layout-hook.test.ts +1 -1
  67. package/src/folder-layout-hook.ts +1 -1
  68. package/src/folder-layout-rule.test.ts +1 -1
  69. package/src/{hooks-settings.harness.ts → hooks-settings.test.ts} +161 -146
  70. package/src/latex-log.test.ts +395 -0
  71. package/src/latex-log.ts +1 -1
  72. package/src/latex-loop.test.ts +553 -0
  73. package/src/latex-loop.ts +1 -1
  74. package/src/layout-docs.test.ts +47 -0
  75. package/src/{link-skills.harness.ts → link-skills-fs.test.ts} +26 -26
  76. package/src/{new-paper.harness.mjs → new-paper-scaffold.test.mjs} +31 -19
  77. package/src/{pdf-facts.harness.ts → pdf-facts-tables.test.ts} +28 -22
  78. package/src/{pdf-geometry.harness.ts → pdf-geometry.test.ts} +93 -75
  79. package/src/{rules-config.harness.ts → rules-config.test.ts} +41 -31
  80. package/src/{structure.harness.ts → structure.test.ts} +12 -10
  81. package/src/{tex-requirements.harness.ts → tex-requirements-tables.test.ts} +106 -85
  82. package/src/{toolchain.harness.mjs → toolchain-mirror.test.mjs} +204 -186
  83. package/scripts/check.harness.ts +0 -343
  84. package/scripts/harness-api.frozen.json +0 -41
  85. package/src/latex-log.harness.ts +0 -382
  86. package/src/latex-loop.harness.ts +0 -515
@@ -7,9 +7,8 @@
7
7
  * doctor has exactly the same property — it will print a cheerful list of checkmarks and never
8
8
  * notice a mismatch. That is, the check for a silent failure can itself fail silently, and only
9
9
  * this file can tell the two apart.
10
- *
11
- * Run: npx vigiles test src/doctor.harness.mjs
12
10
  */
11
+ import { expect, it } from "vitest";
13
12
  import { PAPERS_DIR_FIELD } from "../lib/paper-config.ts";
14
13
  import {
15
14
  mkdtempSync,
@@ -21,14 +20,18 @@ import {
21
20
  import { tmpdir } from "node:os";
22
21
  import { dirname, join } from "node:path";
23
22
  import { fileURLToPath } from "node:url";
24
- import { createChecker } from "../lib/check.ts";
25
23
 
26
24
  const HERE = dirname(fileURLToPath(import.meta.url));
27
25
  const { doctor, detectPapers, PROGRAMS, found } = await import(
28
26
  join(HERE, "doctor.ts")
29
27
  );
30
28
 
31
- const check = createChecker();
29
+ // A failed check is recorded and the rest of the test keeps running.
30
+ const check = (label, cond, detail) => {
31
+ expect
32
+ .soft(cond, detail === undefined ? label : `${label}\n${String(detail)}`)
33
+ .toBeTruthy();
34
+ };
32
35
 
33
36
  /** A consumer on disk: a papers directory, and maybe a declaration in the root paperlint.json. */
34
37
  function consumer({ papersDir, declared, makeDir = true }) {
@@ -70,7 +73,7 @@ const runDoctor = (
70
73
  };
71
74
 
72
75
  // ── I. A CONSISTENT INSTALL IS SILENT ───────────────────────────────────────────────────────
73
- {
76
+ it("I. A CONSISTENT INSTALL IS SILENT", () => {
74
77
  const dir = consumer({ papersDir: "papers", declared: "papers" });
75
78
  const r = runDoctor(dir, { cliPapers: "papers" });
76
79
  check("a consistent install — exit ZERO", r.code === 0);
@@ -79,12 +82,12 @@ const runDoctor = (
79
82
  /linted\s+papers$/m.test(r.out),
80
83
  );
81
84
  rmSync(dir, { recursive: true, force: true });
82
- }
85
+ });
83
86
 
84
87
  // ── II. THE VERY DEFECT: THE PAPERS LIVE SOMEWHERE THE SETTINGS DO NOT NAME ─────────────────
85
88
  // The install that motivated doctor (issue #33): nothing declared, so lint and the hooks both
86
89
  // watch `papers/`, while the papers are in another directory.
87
- {
90
+ it("II. THE VERY DEFECT: THE PAPERS LIVE SOMEWHERE THE SETTINGS DO NOT NAME", () => {
88
91
  const dir = consumer({ papersDir: "writing/drafts" });
89
92
  const r = runDoctor(dir, { cliPapers: "papers" });
90
93
  check(
@@ -100,11 +103,11 @@ const runDoctor = (
100
103
  /papers look like they live in: writing\/drafts/.test(r.out),
101
104
  );
102
105
  rmSync(dir, { recursive: true, force: true });
103
- }
106
+ });
104
107
 
105
108
  // ── II-bis. NO paperlint.json — EVERY DEFAULT, AND THAT IS A VALID PROJECT ─────────────────
106
109
  // The CLI and the hooks both take `papers` when nothing is declared, so they cannot disagree.
107
- {
110
+ it("II-bis. NO paperlint.json — EVERY DEFAULT, AND THAT IS A VALID PROJECT", () => {
108
111
  const dir = consumer({ papersDir: "papers" });
109
112
  const r = runDoctor(dir, { cliPapers: "papers" });
110
113
  check("no paperlint.json — exit ZERO", r.code === 0);
@@ -115,10 +118,10 @@ const runDoctor = (
115
118
  ),
116
119
  );
117
120
  rmSync(dir, { recursive: true, force: true });
118
- }
121
+ });
119
122
 
120
123
  // ── II-quater. A paperlint.json THAT DOES NOT PARSE — lint refuses to run ────────────────
121
- {
124
+ it("II-quater. A paperlint.json THAT DOES NOT PARSE — lint refuses to run", () => {
122
125
  const dir = consumer({ papersDir: "papers" });
123
126
  writeFileSync(join(dir, "paperlint.json"), '{ "papersDir": <<<<<<< HEAD\n');
124
127
  const r = runDoctor(dir, { cliPapers: "papers" });
@@ -129,13 +132,13 @@ const runDoctor = (
129
132
  /`paperlint lint` refuses to run/.test(r.out),
130
133
  );
131
134
  rmSync(dir, { recursive: true, force: true });
132
- }
135
+ });
133
136
 
134
137
  // ── II-ter. A FRESH PROJECT WITH NO PAPERS YET IS NOT BROKEN ───────────────────────────────
135
138
  // `init --yes` declares the default and creates no paper. The declared directory does not exist,
136
139
  // and no papers live anywhere else: there is nothing to check yet. A warning with the next
137
140
  // step, not a failure. (A missing directory while papers DO live elsewhere stays ✗ — case II.)
138
- {
141
+ it("II-ter. A FRESH PROJECT WITH NO PAPERS YET IS NOT BROKEN", () => {
139
142
  const dir = consumer({
140
143
  papersDir: "papers",
141
144
  declared: "papers",
@@ -150,10 +153,10 @@ const runDoctor = (
150
153
  !/watching nothing/.test(r.out),
151
154
  );
152
155
  rmSync(dir, { recursive: true, force: true });
153
- }
156
+ });
154
157
 
155
158
  // ── V. A SETTING THAT NAMES NO DIRECTORY IS NAMED, NOT TURNED INTO ONE ─────────────────────
156
- {
159
+ it("V. A SETTING THAT NAMES NO DIRECTORY IS NAMED, NOT TURNED INTO ONE", () => {
157
160
  const dir = consumer({ papersDir: "papers", declared: "" });
158
161
  const r = runDoctor(dir, { cliPapers: null });
159
162
  check(
@@ -161,10 +164,10 @@ const runDoctor = (
161
164
  /name no directory/.test(r.out),
162
165
  );
163
166
  rmSync(dir, { recursive: true, force: true });
164
- }
167
+ });
165
168
 
166
169
  // ── VI. EXTERNAL PROGRAMS ARE A FACT, NOT A VERDICT ─────────────────────────────────────────
167
- {
170
+ it("VI. EXTERNAL PROGRAMS ARE A FACT, NOT A VERDICT", () => {
168
171
  const dir = consumer({ papersDir: "papers", declared: "papers" });
169
172
  const none = runDoctor(dir, { cliPapers: "papers", have: () => 1 });
170
173
  check(
@@ -197,10 +200,10 @@ const runDoctor = (
197
200
  none.out,
198
201
  );
199
202
  rmSync(dir, { recursive: true, force: true });
200
- }
203
+ });
201
204
 
202
205
  // ── VII. DETECTING THE PAPERS DIRECTORY ─────────────────────────────────────────────────────
203
- {
206
+ it("VII. DETECTING THE PAPERS DIRECTORY", () => {
204
207
  const dir = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-detect-")));
205
208
  mkdirSync(join(dir, "writing", "drafts", "p1"), { recursive: true });
206
209
  writeFileSync(join(dir, "writing", "drafts", "p1", "paper.tex"), "x");
@@ -233,13 +236,13 @@ const runDoctor = (
233
236
  !detectPapers(dir).includes("only-template"),
234
237
  );
235
238
  rmSync(dir, { recursive: true, force: true });
236
- }
239
+ });
237
240
 
238
241
  // ── VII-bis. SKILLS THAT ARE NOT LINKED ARE NAMED — AND DO NOT FAIL THE RUN ─────────────────
239
242
  // Before this section a consumer without `.claude/skills/` links had no `/paper-pipeline`, and
240
- // nothing anywhere said so. The link state itself is `link-skills.harness.ts`'s subject; here
243
+ // nothing anywhere said so. The link state itself is `link-skills-fs.test.ts`'s subject; here
241
244
  // only doctor's REPORTING of it is judged, so the state is handed in rather than built on disk.
242
- {
245
+ it("VII-bis. SKILLS THAT ARE NOT LINKED ARE NAMED — AND DO NOT FAIL THE RUN", () => {
243
246
  const dir = consumer({ papersDir: "papers", declared: "papers" });
244
247
  const state = {
245
248
  ok: true,
@@ -274,17 +277,13 @@ const runDoctor = (
274
277
  /✓ all 1 shipped skills are reachable/.test(all.out),
275
278
  );
276
279
  rmSync(dir, { recursive: true, force: true });
277
- }
280
+ });
278
281
 
279
282
  // ── VIII. `found` ASKS THE SYSTEM, IT DOES NOT GUESS BY NAME ────────────────────────────────
280
- {
283
+ it("VIII. `found` ASKS THE SYSTEM, IT DOES NOT GUESS BY NAME", () => {
281
284
  check("a program that really exists is found", found("node") === true);
282
285
  check(
283
286
  "a made-up one is not (otherwise the check answers the form, not the subject)",
284
287
  found("paperlint-definitely-not-a-real-binary-xyz") === false,
285
288
  );
286
- }
287
-
288
- console.log(
289
- `✓ ${check.count} assertions passed — paperlint doctor: an install can vouch for itself`,
290
- );
289
+ });
@@ -5,7 +5,8 @@
5
5
  */
6
6
  import { describe, expect, it } from "vitest";
7
7
  import {
8
- CURE_BY_KIND,
8
+ CURE_BY_DEFAULT,
9
+ CURE_BY_FILE,
9
10
  KNOWN_CURES,
10
11
  NOTHING_DECLARED,
11
12
  PAPER_LAYOUT_TREE,
@@ -86,50 +87,61 @@ describe("judgeLayout — silent on the whole allowed set", () => {
86
87
  });
87
88
 
88
89
  describe("judgeLayout — reports", () => {
89
- it("a known name with its one destination: the plan is a section of the status file", () => {
90
- const [plan] = judgeLayout(
91
- [file("paper.tex"), file("PLAN.md")],
92
- NOTHING_DECLARED,
93
- );
94
- expect(plan?.name).toBe("PLAN.md");
95
- expect(plan?.cure).toMatch(
96
- /^a section of PIPELINE-STATUS\.md .*"Plan \/ now"/,
97
- );
98
- });
90
+ it.each([
91
+ ["PLAN.md", "file", "a section of PIPELINE-STATUS.md"],
92
+ ["Plan.md", "file", "a section of PIPELINE-STATUS.md"],
93
+ ["plans", "dir", "a section of PIPELINE-STATUS.md"],
94
+ ["DECISION-LOG.md", "file", "research/"],
95
+ ["EMAILS.md", "file", "submission/"],
96
+ ["data", "dir", "repro/data/"],
97
+ ["artifact", "dir", "repro/"],
98
+ ["archive", "dir", "extra/"],
99
+ ["venue-corpus", "dir", "<papers-root>/venues/<venue>/"],
100
+ ] as const)(
101
+ "a known name, %s (%s), goes to its one destination",
102
+ (name, kind, cure) => {
103
+ expect(judgeLayout([{ name, kind }], NOTHING_DECLARED)[0]?.cure).toBe(
104
+ cure,
105
+ );
106
+ },
107
+ );
99
108
 
100
109
  it.each([
101
- ["DECISION-LOG.md", "file", /^research\//],
102
- ["EMAILS.md", "file", /^submission\//],
103
- ["data", "dir", /^repro\//],
104
- ["artifact", "dir", /^repro\//],
105
- [
106
- "archive",
107
- "dir",
108
- /^versions\/ for frozen PDFs, submission\/ .*, extra\/ for the rest$/,
109
- ],
110
- [
111
- "venue-corpus",
112
- "dir",
113
- /^<papers-root>\/venues\/<venue>\/, outside the paper folder/,
114
- ],
115
- ["plans", "dir", /^a section of PIPELINE-STATUS\.md/],
116
- ["Plan.md", "file", /^a section of PIPELINE-STATUS\.md/],
117
- ] as const)("%s (%s) goes to its destination", (name, kind, cure) => {
118
- expect(judgeLayout([{ name, kind }], NOTHING_DECLARED)[0]?.cure).toMatch(
119
- cure,
120
- );
121
- });
110
+ ["results-final-v2.csv", "repro/data/"],
111
+ ["plot.py", "repro/tools/"],
112
+ ["fig1.PNG", "figures/"],
113
+ ["requirements.txt", "repro/tools/"],
114
+ ["Makefile", "repro/tools/"],
115
+ ["notes.md", "research/"],
116
+ ])(
117
+ "an unlisted file, %s, goes to the folder its kind names",
118
+ (name, cure) => {
119
+ expect(judgeLayout([file(name)], NOTHING_DECLARED)[0]?.cure).toBe(cure);
120
+ },
121
+ );
122
122
 
123
- it("an unknown name gets the choice by what it is", () => {
124
- expect(judgeLayout([dir("corpus")], NOTHING_DECLARED)).toEqual([
125
- { name: "corpus/", kind: "dir", cure: CURE_BY_KIND },
123
+ it("anything else goes to extra/: an unlisted folder, a file without a known extension", () => {
124
+ expect(
125
+ judgeLayout(
126
+ [dir("corpus"), file("LICENSE"), file("fig1.pdf")],
127
+ NOTHING_DECLARED,
128
+ ),
129
+ ).toEqual([
130
+ { name: "corpus/", kind: "dir", cure: CURE_BY_DEFAULT },
131
+ { name: "LICENSE", kind: "file", cure: CURE_BY_DEFAULT },
132
+ // A root PDF may be a figure, a draft or a review: no one folder is right, and versions/ holds
133
+ // only cycle folders and lock.json (versions/layout).
134
+ { name: "fig1.pdf", kind: "file", cure: CURE_BY_DEFAULT },
126
135
  ]);
136
+ expect(CURE_BY_DEFAULT).toBe("extra/");
127
137
  });
128
138
 
129
- it("a known file name used by a folder is not that file: the choice by kind", () => {
130
- expect(judgeLayout([dir("PLAN.md")], NOTHING_DECLARED)[0]?.cure).toBe(
131
- CURE_BY_KIND,
132
- );
139
+ it("a known file name, or a file extension, used by a folder is neither: extra/", () => {
140
+ expect(
141
+ judgeLayout([dir("PLAN.md"), dir("runs.csv")], NOTHING_DECLARED).map(
142
+ (s) => s.cure,
143
+ ),
144
+ ).toEqual([CURE_BY_DEFAULT, CURE_BY_DEFAULT]);
133
145
  });
134
146
  });
135
147
 
@@ -227,19 +239,47 @@ describe("judgeLayout — reports by name, exactly", () => {
227
239
  });
228
240
  });
229
241
 
230
- describe("strayMessage — stands alone for a reader with no context", () => {
231
- const [plan] = judgeLayout([file("PLAN.md")], NOTHING_DECLARED);
232
- const text = plan === undefined ? "" : strayMessage(plan);
242
+ describe("strayMessage — one short line naming one destination", () => {
243
+ const CURES = [
244
+ ...new Set([
245
+ ...KNOWN_CURES.map((c) => c.cure),
246
+ ...CURE_BY_FILE.map((c) => c.cure),
247
+ CURE_BY_DEFAULT,
248
+ ]),
249
+ ];
233
250
 
234
- it("names the entry, where it goes, draws the whole layout, and links the rule's page", () => {
235
- expect(text.split("\n")).toEqual([
236
- `\`PLAN.md\` is at the root of a paper folder (the folder holding PIPELINE-STATUS.md), and that root holds only paperlint's layout. Where it goes: ${KNOWN_CURES[0]?.cure ?? ""}.`,
237
- "The layout (extra/ takes anything and is never judged; the build's paper.* byproducts are never reported):",
238
- ...PAPER_LAYOUT_TREE.split("\n"),
239
- "Rule paper/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/paper/allowed-files-only.md",
240
- ]);
251
+ it.each(CURES)(
252
+ "for the destination %s: one line, the entry, the destination, extra/ as the fallback, no tree",
253
+ (cure) => {
254
+ const text = strayMessage({
255
+ name: "results-final-v2.csv",
256
+ kind: "file",
257
+ cure,
258
+ });
259
+ expect(text).not.toContain("\n");
260
+ expect(text.length).toBeLessThanOrEqual(120);
261
+ expect(text.startsWith("`results-final-v2.csv` ")).toBe(true);
262
+ expect(text).toContain(cure);
263
+ expect(text).toContain("extra/");
264
+ expect(text).not.toContain("<paper>/");
265
+ },
266
+ );
267
+
268
+ it("names no destination but its own: no other folder of the layout", () => {
269
+ const text = strayMessage({
270
+ name: "x.csv",
271
+ kind: "file",
272
+ cure: "repro/data/",
273
+ });
274
+ expect(
275
+ CURES.filter(
276
+ (c) => c !== "repro/data/" && c !== "extra/" && c !== "repro/",
277
+ ).filter((c) => text.includes(c)),
278
+ ).toEqual([]);
241
279
  });
280
+ });
242
281
 
282
+ describe("PAPER_LAYOUT_TREE — the drawing the rule's page embeds", () => {
243
283
  it("the layout it draws holds every allowed root entry, repro/'s own layout inside", () => {
244
284
  const lines = PAPER_LAYOUT_TREE.split("\n");
245
285
  expect(lines[0]).toBe("<paper>/");
@@ -31,7 +31,14 @@
31
31
  */
32
32
  import { basename, extname } from "node:path";
33
33
  import { leaf, renderTree, type TreeNode } from "./layout-tree.ts";
34
- import { REPRO_DIR, REPRO_NODES } from "./repro-layout.ts";
34
+ import {
35
+ DATA_EXTENSIONS,
36
+ NOTE_EXTENSIONS,
37
+ REPRO_DIR,
38
+ REPRO_NODES,
39
+ SCRIPT_EXTENSIONS,
40
+ TOOL_FILES,
41
+ } from "./repro-layout.ts";
35
42
 
36
43
  /** One entry at the paper folder's root: its name, and whether it is a folder. */
37
44
  export interface LayoutEntry {
@@ -51,7 +58,7 @@ export interface Stray {
51
58
  /** The entry's name; a folder's ends in a slash. */
52
59
  readonly name: string;
53
60
  readonly kind: "file" | "dir";
54
- /** Where it goes: one destination for a known name, else the choice by what it is. */
61
+ /** Where it goes: one destination, by its name, else by its kind, else `extra/`. */
55
62
  readonly cure: string;
56
63
  }
57
64
 
@@ -185,12 +192,10 @@ export const BUILD_BYPRODUCTS: readonly string[] = BYPRODUCT_EXTENSIONS.map(
185
192
  export const OS_FILES: readonly string[] = [".DS_Store", "Thumbs.db"];
186
193
 
187
194
  /** The live state of a paper — its stages, its plan, its scorecard — is one file. */
188
- const STATUS_SECTIONS =
189
- 'a section of PIPELINE-STATUS.md — the paper\'s one live-state file holds its stages, its plan ("Plan / now") and its scorecard; move what is still live there and delete the file';
195
+ const STATUS_SECTIONS = "a section of PIPELINE-STATUS.md";
190
196
 
191
- /** The shared corpus of a venue's accepted papers. */
192
- const VENUE_CORPUS =
193
- "<papers-root>/venues/<venue>/, outside the paper folder: one corpus per venue, shared by every paper that targets it";
197
+ /** The shared corpus of a venue's accepted papers, outside every paper folder. */
198
+ const VENUE_CORPUS = "<papers-root>/venues/<venue>/";
194
199
 
195
200
  /**
196
201
  * Names met in real paper folders, each with its one destination. Matched ignoring case, a file's
@@ -203,34 +208,43 @@ export const KNOWN_CURES: readonly {
203
208
  }[] = [
204
209
  { name: "PLAN.md", kind: "file", cure: STATUS_SECTIONS },
205
210
  { name: "plans", kind: "dir", cure: STATUS_SECTIONS },
206
- { name: "DECISION-LOG.md", kind: "file", cure: "research/ (a dated record)" },
207
- {
208
- name: "EMAILS.md",
209
- kind: "file",
210
- cure: "submission/ (mail with the venue is about submitting)",
211
- },
212
- {
213
- name: "data",
214
- kind: "dir",
215
- cure: "repro/data/ (the data behind the numbers)",
216
- },
217
- {
218
- name: "artifact",
219
- kind: "dir",
220
- cure: "repro/ — its scripts in repro/tools/, its data in repro/data/; the anonymized copy uploaded for review is about submitting and goes in submission/",
221
- },
222
- {
223
- name: "archive",
224
- kind: "dir",
225
- cure: "versions/ for frozen PDFs, submission/ for an earlier attempt's forms, mails and checklists, extra/ for the rest",
226
- },
211
+ { name: "DECISION-LOG.md", kind: "file", cure: "research/" },
212
+ { name: "EMAILS.md", kind: "file", cure: "submission/" },
213
+ { name: "data", kind: "dir", cure: "repro/data/" },
214
+ { name: "artifact", kind: "dir", cure: "repro/" },
215
+ { name: "archive", kind: "dir", cure: `${ESCAPE_HATCH}/` },
227
216
  { name: "venue-corpus", kind: "dir", cure: VENUE_CORPUS },
228
217
  { name: "venues", kind: "dir", cure: VENUE_CORPUS },
229
218
  ];
230
219
 
231
- /** For a name nobody listed: the choice by what the material is. */
232
- export const CURE_BY_KIND =
233
- "decide by what it is — a record or research → research/; about submitting (forms, mails, checklists, portal records) → submission/; live state of the paper (plan, status) → a section of PIPELINE-STATUS.md; reproduction (scripts, data, the artifact) → repro/; a frozen PDF of a stage → versions/; unclear → extra/, which is never judged";
220
+ /** The extensions of the images a figure is drawn from. */
221
+ export const IMAGE_EXTENSIONS: readonly string[] = [
222
+ ".png",
223
+ ".jpg",
224
+ ".jpeg",
225
+ ".gif",
226
+ ".svg",
227
+ ".eps",
228
+ ];
229
+
230
+ /**
231
+ * For a file nobody listed: the folder its kind names, by its exact name or its extension (matched
232
+ * ignoring case). The same kinds `repro/allowed-files-only` sorts by. No `.pdf`: a root PDF may be
233
+ * a figure, a draft or a review, and `versions/` holds only cycle folders (`versions/layout`).
234
+ */
235
+ export const CURE_BY_FILE: readonly {
236
+ readonly names: readonly string[];
237
+ readonly extensions: readonly string[];
238
+ readonly cure: string;
239
+ }[] = [
240
+ { names: TOOL_FILES, extensions: SCRIPT_EXTENSIONS, cure: "repro/tools/" },
241
+ { names: [], extensions: DATA_EXTENSIONS, cure: "repro/data/" },
242
+ { names: [], extensions: IMAGE_EXTENSIONS, cure: "figures/" },
243
+ { names: [], extensions: NOTE_EXTENSIONS, cure: "research/" },
244
+ ];
245
+
246
+ /** For anything else: the folder that is never judged. */
247
+ export const CURE_BY_DEFAULT = `${ESCAPE_HATCH}/`;
234
248
 
235
249
  const isAllowedFile = (name: string, declared: Declared): boolean =>
236
250
  ROOT_FILES.includes(name) ||
@@ -244,12 +258,20 @@ const isAllowed = (e: LayoutEntry, declared: Declared): boolean =>
244
258
  ? ROOT_DIRS.includes(e.name) || declared.roots.includes(e.name)
245
259
  : isAllowedFile(e.name, declared);
246
260
 
247
- /** Where material like `e` belongs: its listed destination, else the choice by what it is. */
261
+ /** Where `e` belongs: its listed destination, else its kind's folder, else `extra/`. */
248
262
  function cureFor(e: LayoutEntry): string {
249
263
  const known = KNOWN_CURES.find(
250
264
  (c) => c.kind === e.kind && c.name.toLowerCase() === e.name.toLowerCase(),
251
265
  );
252
- return known === undefined ? CURE_BY_KIND : known.cure;
266
+ if (known !== undefined) return known.cure;
267
+ const ext = extname(e.name).toLowerCase();
268
+ const byKind =
269
+ e.kind === "file"
270
+ ? CURE_BY_FILE.find(
271
+ (c) => c.names.includes(e.name) || c.extensions.includes(ext),
272
+ )
273
+ : undefined;
274
+ return byKind?.cure ?? CURE_BY_DEFAULT;
253
275
  }
254
276
 
255
277
  /** The root entries that are not part of the layout, in the order given. Pure. */
@@ -289,7 +311,7 @@ export const PAPER_NODES: readonly TreeNode[] = [
289
311
  })),
290
312
  ];
291
313
 
292
- /** The drawing of the paper folder's layout: the rule's message, the hook's refusal, the rule's page. */
314
+ /** The drawing of the paper folder's layout, which the rule's page embeds. */
293
315
  export const PAPER_LAYOUT_TREE: string = renderTree("<paper>/", PAPER_NODES);
294
316
 
295
317
  /** The folder beside the paper folders that holds one corpus of accepted papers per venue. */
@@ -326,14 +348,11 @@ export const PAPERS_LAYOUT_TREE: string = renderTree(
326
348
 
327
349
  /**
328
350
  * The one text a stray entry is reported with, by the rule `paper/allowed-files-only` and by the hook that
329
- * refuses to create such an entry. It stands alone: where the entry goes, and the whole layout drawn,
330
- * for a reader who knows nothing of paperlint.
351
+ * refuses to create such an entry: one line, the entry and its one destination. The layout, and how
352
+ * each destination is picked, are on the rule's page, which the finding's rule id names.
331
353
  */
332
354
  export function strayMessage(s: Stray): string {
333
- return [
334
- `\`${s.name}\` is at the root of a paper folder (the folder holding PIPELINE-STATUS.md), and that root holds only paperlint's layout. Where it goes: ${s.cure}.`,
335
- `The layout (${ESCAPE_HATCH}/ takes anything and is never judged; the build's paper.* byproducts are never reported):`,
336
- PAPER_LAYOUT_TREE,
337
- `Rule paper/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/paper/allowed-files-only.md`,
338
- ].join("\n");
355
+ const fallback =
356
+ s.cure === CURE_BY_DEFAULT ? "the folder for its kind" : CURE_BY_DEFAULT;
357
+ return `\`${s.name}\` does not belong at a paper folder's root: move it to ${s.cure}, or ${fallback}.`;
339
358
  }