paperlint 20.2.0 → 20.3.0

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 (62) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/adapters/venue-corpus/index.d.ts +17 -1
  3. package/dist/adapters/venue-corpus/index.d.ts.map +1 -1
  4. package/dist/adapters/venue-corpus/index.js +23 -7
  5. package/dist/adapters/venue-corpus/index.js.map +1 -1
  6. package/dist/cli.d.ts +4 -3
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +42 -13
  9. package/dist/cli.js.map +1 -1
  10. package/dist/corpus-record-rule.d.ts +65 -0
  11. package/dist/corpus-record-rule.d.ts.map +1 -0
  12. package/dist/corpus-record-rule.js +85 -0
  13. package/dist/corpus-record-rule.js.map +1 -0
  14. package/dist/domain/corpus-record.d.ts +51 -0
  15. package/dist/domain/corpus-record.d.ts.map +1 -0
  16. package/dist/domain/corpus-record.js +119 -0
  17. package/dist/domain/corpus-record.js.map +1 -0
  18. package/dist/domain/venue-corpus.d.ts +25 -3
  19. package/dist/domain/venue-corpus.d.ts.map +1 -1
  20. package/dist/domain/venue-corpus.js +4 -0
  21. package/dist/domain/venue-corpus.js.map +1 -1
  22. package/dist/paper-files.d.ts +10 -3
  23. package/dist/paper-files.d.ts.map +1 -1
  24. package/dist/paper-files.js +17 -2
  25. package/dist/paper-files.js.map +1 -1
  26. package/dist/papers-roots.d.ts +6 -0
  27. package/dist/papers-roots.d.ts.map +1 -1
  28. package/dist/papers-roots.js +14 -0
  29. package/dist/papers-roots.js.map +1 -1
  30. package/docs/design/venue-corpus.md +48 -27
  31. package/docs/layout.md +2 -2
  32. package/docs/rules/corpus/record.md +119 -0
  33. package/docs/rules.md +1 -0
  34. package/docs/venues.md +31 -20
  35. package/eslint.config.mjs +1 -0
  36. package/package.json +2 -1
  37. package/scripts/eslint-file-length.mjs +3 -3
  38. package/skills/study-accepted-papers/SKILL.md +14 -8
  39. package/skills/study-accepted-papers/SKILL.md.spec.ts +13 -7
  40. package/skills/study-accepted-papers/papers.schema.json +49 -2
  41. package/skills/study-accepted-papers/scripts/corpus-licences-core.js +2 -2
  42. package/skills/study-accepted-papers/scripts/corpus-licences-core.ts +2 -1
  43. package/skills/study-accepted-papers/scripts/corpus-licences.js +19 -9
  44. package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +4 -1
  45. package/src/adapters/venue-corpus/index.test.ts +68 -10
  46. package/src/adapters/venue-corpus/index.ts +28 -8
  47. package/src/cli-e2e.test.mjs +2 -2
  48. package/src/cli.test.ts +1 -1
  49. package/src/cli.ts +57 -13
  50. package/src/corpus-record-rule.test.ts +228 -0
  51. package/src/corpus-record-rule.ts +175 -0
  52. package/src/domain/corpus-record.test.ts +163 -0
  53. package/src/domain/corpus-record.ts +210 -0
  54. package/src/domain/venue-corpus.ts +32 -3
  55. package/src/paper-files.test.ts +13 -4
  56. package/src/paper-files.ts +23 -2
  57. package/src/paper-settings-commands.test.ts +2 -2
  58. package/src/papers-roots.test.ts +34 -1
  59. package/src/papers-roots.ts +15 -0
  60. package/src/rule-cases.test.ts +15 -0
  61. package/src/settled-paper.test.ts +1 -1
  62. package/src/unowned-file.test.ts +1 -1
@@ -8,7 +8,11 @@ import { dirname, join } from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
9
  import { describe, expect, it } from "vitest";
10
10
  import { z } from "zod";
11
- import type { Paper, VenueCorpus } from "../../domain/venue-corpus.ts";
11
+ import {
12
+ problemsText,
13
+ type Paper,
14
+ type VenueCorpus,
15
+ } from "../../domain/venue-corpus.ts";
12
16
  import {
13
17
  SCHEMA_FILE,
14
18
  venueCorpusCodec,
@@ -48,9 +52,16 @@ const EDITION = {
48
52
  listed_from: "https://conf.researchr.org/home/icse-2026/agent-2026",
49
53
  read_on: "2026-11-03",
50
54
  accepted: 27,
55
+ capped: null,
56
+ proxy: { what: "distinguished-paper award", papers: 4 },
51
57
  } as const;
52
58
 
53
- const RECORD = { venue: "agent", editions: [EDITION], papers: [PAPER] };
59
+ const RECORD = {
60
+ venue: "agent",
61
+ editions: [EDITION],
62
+ papers: [PAPER],
63
+ rebuild: ["node scripts/list-accepted.mjs agent 2026"],
64
+ };
54
65
 
55
66
  const text = (v: unknown): string => JSON.stringify(v);
56
67
  /** The record with its one paper replaced by `paper`. */
@@ -134,14 +145,27 @@ describe("a copy whose licence was never read", () => {
134
145
  corpus: { ...RECORD, papers: [{ ...PAPER, copies: [copy] }] },
135
146
  });
136
147
  });
148
+
149
+ it("🔴 the collection facts parse: what was capped, no proxy, no rebuild command", () => {
150
+ const facts = {
151
+ ...RECORD,
152
+ editions: [
153
+ { ...EDITION, capped: "the research track only, 100 of 312" },
154
+ { ...EDITION, edition: 2025, proxy: null },
155
+ ],
156
+ rebuild: [],
157
+ };
158
+ // Guards: each fact is a field, and "none" is null or an empty list.
159
+ expect(parse(text(facts))).toEqual({ ok: true, corpus: facts });
160
+ });
137
161
  });
138
162
 
139
163
  /** A file that is no record, and the reasons it is refused with. */
140
164
  const REFUSED: readonly (readonly [string, string, string])[] = [
141
165
  [
142
- "🔴 a misspelt key in a copy",
166
+ "🔴 a misspelt key in a copy, at the key",
143
167
  withCopy({ ...COPY, licence: undefined, lisence: LICENCE }),
144
- 'papers.0.copies.0.licence: Invalid input: expected object, received undefined; papers.0.copies.0: Unrecognized key: "lisence"',
168
+ 'papers.0.copies.0.licence: Invalid input: expected object, received undefined; papers.0.copies.0.lisence: Unrecognized key: "lisence"',
145
169
  ],
146
170
  [
147
171
  "🔴 a copy without its licence object",
@@ -156,12 +180,12 @@ const REFUSED: readonly (readonly [string, string, string])[] = [
156
180
  [
157
181
  "a misspelt key at the top level",
158
182
  text({ ...RECORD, edtions: [] }),
159
- '(top): Unrecognized key: "edtions"',
183
+ 'edtions: Unrecognized key: "edtions"',
160
184
  ],
161
185
  [
162
186
  "a misspelt key in a licence",
163
187
  withCopy({ ...COPY, licence: { ...LICENCE, read_form: "x" } }),
164
- 'papers.0.copies.0.licence: Unrecognized key: "read_form"',
188
+ 'papers.0.copies.0.licence.read_form: Unrecognized key: "read_form"',
165
189
  ],
166
190
  [
167
191
  "a licence read from nowhere",
@@ -181,7 +205,7 @@ const REFUSED: readonly (readonly [string, string, string])[] = [
181
205
  [
182
206
  "a copy of unknown origin under a licence",
183
207
  withCopy({ ...COPY, version: "unknown" }),
184
- 'papers.0.copies.0.licence.id: Invalid input: expected "NOASSERTION"; papers.0.copies.0.licence: Unrecognized keys: "read_from", "read_on"; papers.0.copies.0: Unrecognized key: "url"',
208
+ 'papers.0.copies.0.licence.id: Invalid input: expected "NOASSERTION"; papers.0.copies.0.licence.read_from: Unrecognized keys: "read_from", "read_on"; papers.0.copies.0.url: Unrecognized key: "url"',
185
209
  ],
186
210
  [
187
211
  "a stored copy that does not say where its bytes came from",
@@ -216,7 +240,7 @@ const REFUSED: readonly (readonly [string, string, string])[] = [
216
240
  [
217
241
  "a misspelt id",
218
242
  withPaper({ ...PAPER, ids: { dio: "10.1/x" } }),
219
- 'papers.0.ids: Unrecognized key: "dio"; papers.0.ids: at least one of doi, arxiv, dblp, s2, url',
243
+ 'papers.0.ids.dio: Unrecognized key: "dio"; papers.0.ids: at least one of doi, arxiv, dblp, s2, url',
220
244
  ],
221
245
  [
222
246
  "a key that cannot name a file",
@@ -229,6 +253,21 @@ const REFUSED: readonly (readonly [string, string, string])[] = [
229
253
  withPaper({ ...PAPER, key: "2501.15919" }),
230
254
  "papers.0.key: a letter or digit, then letters, digits, '_' or '-'",
231
255
  ],
256
+ [
257
+ "🔴 an edition that leaves out what was capped, and a proxy marking -1 papers",
258
+ text({
259
+ ...RECORD,
260
+ editions: [
261
+ { ...EDITION, capped: undefined, proxy: { what: "award", papers: -1 } },
262
+ ],
263
+ }),
264
+ "editions.0.capped: Invalid input: expected string, received undefined; editions.0.proxy.papers: Too small: expected number to be >=0",
265
+ ],
266
+ [
267
+ "🔴 a record without its rebuild commands",
268
+ text({ ...RECORD, rebuild: undefined }),
269
+ "rebuild: Invalid input: expected array, received undefined",
270
+ ],
232
271
  ];
233
272
 
234
273
  describe("refusing what is not a papers.json", () => {
@@ -236,13 +275,31 @@ describe("refusing what is not a papers.json", () => {
236
275
  // Guards: a broken file is named as such, not parsed as an empty record.
237
276
  expect(parse("{ venue: agent")).toEqual({
238
277
  ok: false,
239
- why: "papers.json is not JSON",
278
+ problems: [{ path: [], message: "not JSON" }],
279
+ });
280
+ });
281
+
282
+ it("🔴 each problem carries its path, a misspelt key's ending at the key", () => {
283
+ // Guards: `corpus/record` walks the path to the field it reports on.
284
+ expect(
285
+ parse(withPaper({ ...PAPER, ids: { doi: "10.1/x", dio: "10.1/x" } })),
286
+ ).toEqual({
287
+ ok: false,
288
+ problems: [
289
+ {
290
+ path: ["papers", 0, "ids", "dio"],
291
+ message: 'Unrecognized key: "dio"',
292
+ },
293
+ ],
240
294
  });
241
295
  });
242
296
 
243
297
  it.each(REFUSED)("%s", (_name, file, why) => {
244
298
  // Guards: the record is refused, and the reason names the path of every problem.
245
- expect(parse(file)).toEqual({ ok: false, why: `papers.json: ${why}` });
299
+ const parsed = parse(file);
300
+ expect(parsed.ok ? "parsed" : problemsText(parsed.problems)).toBe(
301
+ `papers.json: ${why}`,
302
+ );
246
303
  });
247
304
  });
248
305
 
@@ -274,6 +331,7 @@ describe("venueCorpusJsonSchema — the shipped schema file", () => {
274
331
  "venue",
275
332
  "editions",
276
333
  "papers",
334
+ "rebuild",
277
335
  ]);
278
336
  });
279
337
  });
@@ -16,7 +16,6 @@ import {
16
16
  STORED_KINDS,
17
17
  } from "../../domain/licence.ts";
18
18
  import {
19
- CORPUS_RECORD,
20
19
  KEY_PATTERN,
21
20
  KNOWN_VERSIONS,
22
21
  PAPER_ID_KINDS,
@@ -26,6 +25,8 @@ import {
26
25
  type ParsedCorpus,
27
26
  type Paper,
28
27
  type PaperIds,
28
+ type CorpusProblem,
29
+ type StrongAcceptProxy,
29
30
  type VenueCorpus,
30
31
  } from "../../domain/venue-corpus.ts";
31
32
  import type { VenueCorpusCodec } from "../../ports/venue-corpus-codec.ts";
@@ -162,11 +163,18 @@ const paper = z.discriminatedUnion("group", [
162
163
  }),
163
164
  ]);
164
165
 
166
+ const count = z.number().int().nonnegative();
167
+
168
+ const proxy = z.strictObject({ what: words, papers: count });
169
+
170
+ // `capped` and `proxy` are required, and "none" is null: a fact left out is not a fact recorded.
165
171
  const edition = z.strictObject({
166
172
  edition: year,
167
173
  listed_from: webUrl,
168
174
  read_on: date,
169
- accepted: z.number().int().nonnegative().optional(),
175
+ accepted: count.optional(),
176
+ capped: words.nullable(),
177
+ proxy: proxy.nullable(),
170
178
  });
171
179
 
172
180
  /** Keys unique, editions unique, and every paper of this venue of a listed edition. */
@@ -205,6 +213,7 @@ const record = z
205
213
  venue: words,
206
214
  editions: z.array(edition),
207
215
  papers: z.array(paper),
216
+ rebuild: z.array(words),
208
217
  })
209
218
  .superRefine(consistent);
210
219
 
@@ -229,6 +238,7 @@ type Same<A, B> =
229
238
  export type SchemasAreTheDomain = [
230
239
  Same<z.output<typeof record>, VenueCorpus>,
231
240
  Same<z.output<typeof edition>, Edition>,
241
+ Same<z.output<typeof proxy>, StrongAcceptProxy>,
232
242
  Same<z.output<typeof paper>, Paper>,
233
243
  Same<z.output<typeof copy>, Copy>,
234
244
  Same<z.output<typeof licence>, Licence>,
@@ -249,17 +259,27 @@ function jsonOf(text: string): unknown {
249
259
  }
250
260
  }
251
261
 
262
+ /**
263
+ * One zod issue as a problem. A misspelt key's path ends at the key (the first, when there are
264
+ * several), so a reader of the file lands on it rather than on the object holding it.
265
+ */
266
+ const problemOf = (i: z.core.$ZodIssue): CorpusProblem => ({
267
+ path: [
268
+ ...i.path.filter((s) => typeof s !== "symbol"),
269
+ ...(i.code === "unrecognized_keys" ? i.keys.slice(0, 1) : []),
270
+ ],
271
+ message: i.message,
272
+ });
273
+
252
274
  /** A `papers.json`'s text, parsed once at the boundary: the record, or every reason it is not one. */
253
275
  export function parseVenueCorpus(text: string): ParsedCorpus {
254
276
  const json = jsonOf(text);
255
277
  if (json === undefined)
256
- return { ok: false, why: `${CORPUS_RECORD} is not JSON` };
278
+ return { ok: false, problems: [{ path: [], message: "not JSON" }] };
257
279
  const parsed = record.safeParse(json);
258
- if (parsed.success) return { ok: true, corpus: parsed.data };
259
- const reasons = parsed.error.issues.map(
260
- (i) => `${i.path.length === 0 ? "(top)" : i.path.join(".")}: ${i.message}`,
261
- );
262
- return { ok: false, why: `${CORPUS_RECORD}: ${reasons.join("; ")}` };
280
+ return parsed.success
281
+ ? { ok: true, corpus: parsed.data }
282
+ : { ok: false, problems: parsed.error.issues.map(problemOf) };
263
283
  }
264
284
 
265
285
  export const venueCorpusCodec: VenueCorpusCodec = { parse: parseVenueCorpus };
@@ -180,11 +180,11 @@ it("config is assembled, and consumer data gets through", async () => {
180
180
  const ruleBlocks = (c) => c.filter((b) => Array.isArray(b.files));
181
181
  check(
182
182
  "without a LaTeX language the config still gets built — a corpus with no .tex is not a reason to refuse",
183
- Array.isArray(cfg) && ruleBlocks(cfg).length === 3,
183
+ Array.isArray(cfg) && ruleBlocks(cfg).length === 4,
184
184
  );
185
185
  check(
186
186
  "with a LaTeX language two blocks are added: paper.tex, and the files it includes",
187
- ruleBlocks(buildConfig({}, {})).length === 5,
187
+ ruleBlocks(buildConfig({}, {})).length === 6,
188
188
  );
189
189
  check(
190
190
  "🔴 the project's paper TEMPLATE directory is ignored — flat config does not skip dot-directories",
package/src/cli.test.ts CHANGED
@@ -682,7 +682,7 @@ test("a paper's paperlint.json that does not parse stops the lint with its path"
682
682
  "p/paper.tex": "% P\n",
683
683
  "p/paperlint.json": "{ nope",
684
684
  });
685
- const r = paperRuleBlocks([join(dir, "p")]);
685
+ const r = paperRuleBlocks([join(dir, "p")], []);
686
686
  assert.equal(r.ok, false);
687
687
  assert.match(r.error, /^.*rules-broken\/p\/paperlint\.json: /);
688
688
  });
package/src/cli.ts CHANGED
@@ -36,6 +36,7 @@ import { isOk } from "./domain/result.ts";
36
36
  import { stripVTControlCharacters } from "node:util";
37
37
  import { fileURLToPath } from "node:url";
38
38
  import { join, dirname, resolve, relative, basename, sep } from "node:path";
39
+ import json from "@eslint/json";
39
40
  import markdown from "@eslint/markdown";
40
41
  import { z } from "zod";
41
42
  // Types come from consumer.d.mts beside it.
@@ -135,6 +136,7 @@ import type { PortalSite } from "./ports/submission-portal.ts";
135
136
  import type { CheckReferences } from "./ports/check-references.ts";
136
137
  import {
137
138
  ANY_PAPER,
139
+ corpusFiles,
138
140
  narrowToOwners,
139
141
  ownedPatterns,
140
142
  paperFiles,
@@ -239,7 +241,13 @@ import {
239
241
  folderLayoutRules,
240
242
  } from "./folder-layout-rule.ts";
241
243
  import { folderLayoutHook } from "./folder-layout-hook.ts";
242
- import { papersDirOf, papersRoots, toPaths } from "./papers-roots.ts";
244
+ import { inCorpus, papersDirOf, papersRoots, toPaths } from "./papers-roots.ts";
245
+ import {
246
+ CORPUS_RECORD_RULE_LEVELS,
247
+ corpusRecordRules,
248
+ } from "./corpus-record-rule.ts";
249
+ import { CORPUS_RECORD } from "./domain/venue-corpus.ts";
250
+ import { venueCorpusCodec } from "./adapters/venue-corpus/index.ts";
243
251
  import { paperFolderOf, writtenPath } from "./domain/paper-folder.ts";
244
252
  import { papersReached, type PaperTree } from "./domain/paper-dirs.ts";
245
253
  import {
@@ -648,6 +656,26 @@ const TALK_RULE_DEPS = {
648
656
  listDir: nodeListDir,
649
657
  };
650
658
 
659
+ /**
660
+ * A venue corpus, `<papers-root>/venues/<venue>/`, reached through its `papers.json`, linted with
661
+ * ESLint's JSON language so `corpus/record` reports at the field (docs/design/venue-corpus.md,
662
+ * decision 4). The JSON language reaches no other file: this block alone names it.
663
+ */
664
+ const corpusBlock = (papers: PaperScope): ConfigBlock => ({
665
+ files: corpusFiles(papers, CORPUS_RECORD),
666
+ plugins: {
667
+ json,
668
+ corpus: {
669
+ rules: corpusRecordRules({
670
+ entries: nodeListEntries,
671
+ codec: venueCorpusCodec,
672
+ }),
673
+ },
674
+ },
675
+ language: "json/json",
676
+ rules: CORPUS_RECORD_RULE_LEVELS,
677
+ });
678
+
651
679
  /** The config the user would otherwise write by hand. The data comes from `opts`, the mechanism is here. */
652
680
  export function buildConfig(
653
681
  opts: PaperlintConfig = {},
@@ -733,6 +761,7 @@ export function buildConfig(
733
761
  ...STATUS_CYCLE_RULE_LEVELS,
734
762
  },
735
763
  },
764
+ corpusBlock(papers),
736
765
  {
737
766
  files: own("reviews/*.md"),
738
767
  plugins: { markdown, review: reviewFrontmatter },
@@ -864,11 +893,12 @@ export function eslintConfig(blocks: readonly ConfigBlock[]): Linter.Config[] {
864
893
 
865
894
  /**
866
895
  * The rule ids a consumer may name in `rules`: every rule paperlint's own config defines, read off that
867
- * config rather than listed again. `@eslint/markdown` is a dependency's plugin, not paperlint's.
896
+ * config rather than listed again. `@eslint/markdown` and `@eslint/json` are a dependency's plugins,
897
+ * not paperlint's.
868
898
  */
869
899
  export const SHIPPED_RULES: ReadonlySet<string> = shippedRuleIds(
870
900
  buildConfig({}, { sentinel: "tex language" }),
871
- [markdown],
901
+ [markdown, json],
872
902
  );
873
903
 
874
904
  /** A plugin as `rulePlugins` gives it: its rules, and for `tex` the LaTeX language when given. */
@@ -881,7 +911,7 @@ export interface RulePlugin {
881
911
  * Every plugin paperlint's config registers, ONE object per name, read off that config. In it one
882
912
  * name is bound to different objects in different blocks (`paper` beside `PIPELINE-STATUS.md` is
883
913
  * not `paper` beside `paper.tex`); here their rules are merged, so a config that lints any paper
884
- * file knows every rule id. `@eslint/markdown` is a dependency's plugin and is left out. The LaTeX
914
+ * file knows every rule id. `@eslint/markdown` and `@eslint/json` are a dependency's plugins and are left out. The LaTeX
885
915
  * language rides on `tex` when `texLanguage` is given, and that is how a consumer registers it: a
886
916
  * second `tex` plugin of its own is refused by ESLint ("Cannot redefine plugin "tex"", measured
887
917
  * with and without the language here). Without it, `tex` carries rules only.
@@ -890,7 +920,7 @@ export function rulePlugins(texLanguage?: unknown): Record<string, RulePlugin> {
890
920
  const out: Record<string, { rules: Record<string, unknown> }> = {};
891
921
  for (const block of buildConfig({}, texLanguage ?? { sentinel: "tex" }))
892
922
  for (const [name, plugin] of Object.entries(block.plugins ?? {}))
893
- if (plugin !== markdown)
923
+ if (plugin !== markdown && plugin !== json)
894
924
  out[name] = { rules: { ...out[name]?.rules, ...plugin.rules } };
895
925
  if (out["tex"] && texLanguage !== undefined)
896
926
  return {
@@ -1030,14 +1060,20 @@ const PAPER_TREE: PaperTree = {
1030
1060
  },
1031
1061
  };
1032
1062
 
1033
- /** The papers `paths` reach: a file counts as the folder it sits in (#582). */
1034
- const paperDirs = (paths: readonly string[]): readonly string[] =>
1063
+ /**
1064
+ * The papers `paths` reach: a file counts as the folder it sits in (#582). A folder in a venue corpus
1065
+ * of `roots` is none of them (#215): a `paper.tex` kept there is an accepted paper's source.
1066
+ */
1067
+ const paperDirs = (
1068
+ paths: readonly string[],
1069
+ roots: readonly string[],
1070
+ ): readonly string[] =>
1035
1071
  papersReached(
1036
1072
  paths.map((p) =>
1037
1073
  resolve(existsSync(p) && statSync(p).isFile() ? dirname(p) : p),
1038
1074
  ),
1039
1075
  PAPER_TREE,
1040
- );
1076
+ ).filter((d) => !inCorpus(d, roots));
1041
1077
 
1042
1078
  /**
1043
1079
  * Every linted paper's rules, as ESLint blocks scoped to that paper, in two groups: what its venue
@@ -1045,8 +1081,11 @@ const paperDirs = (paths: readonly string[]): readonly string[] =>
1045
1081
  * them. A file that does not parse, or names a rule paperlint does not ship, stops the run with one
1046
1082
  * line naming the file — the same strictness as the root's own `rules`.
1047
1083
  */
1048
- export function paperRuleBlocks(paths: readonly string[]): Parsed<PaperBlocks> {
1049
- const each = paperDirs(paths).map((dir): Parsed<PaperBlocks> => {
1084
+ export function paperRuleBlocks(
1085
+ paths: readonly string[],
1086
+ roots: readonly string[],
1087
+ ): Parsed<PaperBlocks> {
1088
+ const each = paperDirs(paths, roots).map((dir): Parsed<PaperBlocks> => {
1050
1089
  const p = paperPreset(dir, PRESET_DEPS);
1051
1090
  return p.kind === "settings-problem"
1052
1091
  ? { ok: false, error: settingsProblemLine(dir, p.problem) }
@@ -2737,7 +2776,8 @@ async function paperEslint(
2737
2776
  // paper's venue preset → the root paperlint.json → the paper's own paperlint.json → the paper's
2738
2777
  // stage (src/settled-paper.ts), last because a published text has nothing left to fix whoever
2739
2778
  // turned a writing rule on.
2740
- const papers = paperRuleBlocks(paths);
2779
+ const roots = papersRoots(cfg);
2780
+ const papers = paperRuleBlocks(paths, roots);
2741
2781
  if (!papers.ok) return papers;
2742
2782
  const opts = {
2743
2783
  ...cfg.opts,
@@ -2758,14 +2798,18 @@ async function paperEslint(
2758
2798
  // loaded, since only its rules read them. The project's papers too: `paperlint lint .` reaches
2759
2799
  // papers two levels down, which a directory's immediate papers do not.
2760
2800
  const bodies = texLanguage
2761
- ? paperBodies(paperDirs([...paths, ...papersRoots(cfg)]), RECORD_DEPS)
2801
+ ? paperBodies(paperDirs([...paths, ...roots], roots), RECORD_DEPS)
2762
2802
  : [];
2763
2803
 
2764
2804
  const cwd = lintRoot(cfg.root, paths);
2765
2805
  // The papers whose own files the config names: the ones `paths` reach and the project's. A copy of
2766
2806
  // a paper kept inside it (a review snapshot, a build copy) is in no such list, so no block claims
2767
2807
  // it (#582).
2768
- const claimed = papersScope(paperDirs([...paths, ...papersRoots(cfg)]), cwd);
2808
+ const claimed = papersScope(
2809
+ paperDirs([...paths, ...roots], roots),
2810
+ cwd,
2811
+ roots,
2812
+ );
2769
2813
  const eslint = new ESLint({
2770
2814
  cwd,
2771
2815
  overrideConfigFile: true,
@@ -0,0 +1,228 @@
1
+ /**
2
+ * `corpus/record` through `paperlint lint`, the way a consumer runs it: the block that lints a
3
+ * corpus's `papers.json` as JSON and reports at the field, no other JSON file reached, and a
4
+ * `paper.tex` kept in a corpus judged by no paper rule (#215).
5
+ */
6
+ import { describe, expect, it } from "vitest";
7
+ import { z } from "zod";
8
+ import { run } from "./cli.ts";
9
+ import { useTempDir, writeTree } from "../test/support.ts";
10
+
11
+ const STATUS = "---\nstages: []\n---\n# PIPELINE-STATUS\n";
12
+ const TEX = "\\documentclass{article}\n\\begin{document}\nx\n\\end{document}\n";
13
+ const PAPER = {
14
+ "papers/p/PIPELINE-STATUS.md": STATUS,
15
+ "papers/p/paper.tex": TEX,
16
+ };
17
+ const C = "papers/venues/agent";
18
+ const RECORD = `${C}/papers.json`;
19
+
20
+ const copy = (stored: readonly string[]) => ({
21
+ version: "published",
22
+ url: "https://doi.org/10.1/x",
23
+ licence: { id: "NOASSERTION" },
24
+ stored,
25
+ ...(stored.length > 0 ? { fetched_from: "https://doi.org/10.1/x" } : {}),
26
+ });
27
+ const record = (copies: readonly (readonly string[])[]): string =>
28
+ JSON.stringify(
29
+ {
30
+ venue: "agent",
31
+ editions: [
32
+ {
33
+ edition: 2026,
34
+ listed_from: "https://example.org/accepted",
35
+ read_on: "2026-11-03",
36
+ capped: null,
37
+ proxy: null,
38
+ },
39
+ ],
40
+ papers: [
41
+ {
42
+ key: "a",
43
+ edition: 2026,
44
+ group: "accepted",
45
+ title: "A",
46
+ ids: { doi: "10.1/x" },
47
+ copies: copies.map(copy),
48
+ },
49
+ ],
50
+ rebuild: [],
51
+ },
52
+ null,
53
+ 2,
54
+ );
55
+
56
+ const Results = z.array(
57
+ z.looseObject({
58
+ filePath: z.string(),
59
+ messages: z.array(
60
+ z.looseObject({
61
+ ruleId: z.string().nullable(),
62
+ messageId: z.string().optional(),
63
+ line: z.number().optional(),
64
+ column: z.number().optional(),
65
+ message: z.string(),
66
+ }),
67
+ ),
68
+ }),
69
+ );
70
+
71
+ /** `paperlint lint --json` over the tree: each linted file, and every message with its file. */
72
+ async function lint(tree: Readonly<Record<string, string>>) {
73
+ const dir = writeTree(useTempDir("paperlint-corpus-"), {
74
+ "package.json": '{"name":"consumer","private":true}',
75
+ ...tree,
76
+ });
77
+ const out: string[] = [];
78
+ await run(["lint", "--json"], {
79
+ cwd: dir,
80
+ log: (...a: unknown[]) => out.push(a.join(" ")),
81
+ err: () => undefined,
82
+ });
83
+ const results = Results.parse(JSON.parse(out.join("\n")));
84
+ const rel = (p: string) => p.slice(dir.length + 1);
85
+ return {
86
+ files: results.map((r) => rel(r.filePath)).sort(),
87
+ messages: results.flatMap((r) =>
88
+ r.messages.map((m) => ({ ...m, file: rel(r.filePath) })),
89
+ ),
90
+ };
91
+ }
92
+
93
+ /** Every message on a file of the corpus. */
94
+ const onCorpus = async (tree: Readonly<Record<string, string>>) =>
95
+ (await lint(tree)).messages.filter((m) => m.file.startsWith(C));
96
+
97
+ /** The corpus findings: where each is reported and which one it is. */
98
+ const corpusFindings = async (tree: Readonly<Record<string, string>>) =>
99
+ (await onCorpus(tree))
100
+ .filter((m) => m.ruleId === "corpus/record")
101
+ .map((m) => ({ file: m.file, line: m.line, messageId: m.messageId }));
102
+
103
+ /** The line of `text` holding the `nth` occurrence of `needle`, counted from 1. */
104
+ const lineOf = (text: string, needle: string, nth = 1): number =>
105
+ text
106
+ .split("\n")
107
+ .flatMap((l, i) => (l.includes(needle) ? [i + 1] : []))
108
+ .at(nth - 1) ?? 0;
109
+
110
+ describe("corpus/record: silent where nothing is wrong", () => {
111
+ it("🔴 is silent on a project with no venues/ at all", async () => {
112
+ // Guards: most consumers keep no corpus; the rule must cost them nothing.
113
+ expect(await corpusFindings(PAPER)).toEqual([]);
114
+ });
115
+
116
+ it("🔴 is silent on a corpus folder with stored files and no papers.json", async () => {
117
+ // Guards: a corpus not migrated yet is corpus/allowed-files-only's to report (PR 1b-ii), not this rule's.
118
+ const r = await lint({
119
+ ...PAPER,
120
+ [`${C}/MANIFEST.md`]: "# agent\n",
121
+ [`${C}/pdf/a.pdf`]: "%PDF",
122
+ [`${C}/text/a.txt`]: "a",
123
+ });
124
+ expect(r.files.filter((f) => f.startsWith("papers/venues/"))).toEqual([]);
125
+ expect(r.messages.filter((m) => m.file.startsWith(C))).toEqual([]);
126
+ });
127
+
128
+ it("is silent on a corpus whose stored files are each claimed by one copy", async () => {
129
+ const r = await lint({
130
+ ...PAPER,
131
+ [RECORD]: record([["pdf", "text"], []]),
132
+ [`${C}/pdf/a.pdf`]: "%PDF",
133
+ [`${C}/text/a.txt`]: "a",
134
+ [`${C}/text/a.pdfminer.txt`]: "a",
135
+ [`${C}/measurements.json`]: "[]",
136
+ });
137
+ // Guards: the block reaches the corpus (its papers.json is linted), and finds nothing.
138
+ expect(r.files).toContain(RECORD);
139
+ expect(r.messages.filter((m) => m.file.startsWith(C))).toEqual([]);
140
+ });
141
+ });
142
+
143
+ describe("corpus/record: each finding, at its place in papers.json", () => {
144
+ it("🔴 reports a field that breaks the schema at that field's line", async () => {
145
+ const text = record([["pdf"]]).replace('"fetched_from"', '"fetched"');
146
+ const found = await onCorpus({
147
+ ...PAPER,
148
+ [RECORD]: text,
149
+ [`${C}/pdf/a.pdf`]: "%PDF",
150
+ });
151
+ // Guards: the required key is reported on its copy (the line opening it), the misspelt one where it stands.
152
+ expect(found.map((m) => [m.line, m.column, m.messageId])).toEqual([
153
+ [lineOf(text, '"version"') - 1, 9, "unparsed"],
154
+ [lineOf(text, '"fetched"'), 11, "unparsed"],
155
+ ]);
156
+ expect(found.map((m) => m.message.split(":")[0])).toEqual([
157
+ "`papers.0.copies.0.fetched_from`",
158
+ "`papers.0.copies.0.fetched`",
159
+ ]);
160
+ });
161
+
162
+ it("reports a papers.json that is not JSON as ESLint's parse error", async () => {
163
+ const found = await onCorpus({ ...PAPER, [RECORD]: '{ "venue": ' });
164
+ expect(found.map((m) => [m.ruleId, m.line])).toEqual([[null, 1]]);
165
+ });
166
+
167
+ it("reports an unclaimed file, a missing file and two copies storing one kind", async () => {
168
+ const text = record([["pdf"], ["pdf", "text"]]);
169
+ // The second copy's `stored` holds both the second "pdf" and the "text" whose file is absent.
170
+ const second = lineOf(text, '"stored"', 2);
171
+ expect(
172
+ await corpusFindings({
173
+ ...PAPER,
174
+ [RECORD]: text,
175
+ [`${C}/pdf/a.pdf`]: "%PDF",
176
+ [`${C}/pdf/b.pdf`]: "%PDF",
177
+ }),
178
+ ).toEqual([
179
+ // A file of no listed paper is reported on the record's first line.
180
+ { file: RECORD, line: 1, messageId: "unclaimed" },
181
+ { file: RECORD, line: second, messageId: "twice" },
182
+ { file: RECORD, line: second, messageId: "missing" },
183
+ ]);
184
+ });
185
+
186
+ it("is turned off in the root paperlint.json by one line", async () => {
187
+ expect(
188
+ await corpusFindings({
189
+ ...PAPER,
190
+ "paperlint.json": JSON.stringify({
191
+ rules: { "corpus/record": "off" },
192
+ }),
193
+ [RECORD]: record([]),
194
+ [`${C}/pdf/a.pdf`]: "%PDF",
195
+ }),
196
+ ).toEqual([]);
197
+ });
198
+ });
199
+
200
+ describe("the JSON language reaches papers.json and nothing else", () => {
201
+ it("🔴 lints no other JSON file: the root and a paper's paperlint.json, measurements.json", async () => {
202
+ const r = await lint({
203
+ ...PAPER,
204
+ "paperlint.json": "{}",
205
+ "papers/p/paperlint.json": "{}",
206
+ "papers/p/data.json": "{ broken",
207
+ [RECORD]: record([]),
208
+ [`${C}/measurements.json`]: "{ broken",
209
+ "papers/venues/papers.json": "{ broken",
210
+ });
211
+ expect(r.files.filter((f) => f.endsWith(".json"))).toEqual([RECORD]);
212
+ });
213
+ });
214
+
215
+ describe("a paper.tex kept in a corpus (#215)", () => {
216
+ it("🔴 is judged by no paper rule, and the corpus still is", async () => {
217
+ const r = await lint({
218
+ ...PAPER,
219
+ [RECORD]: record([]),
220
+ [`${C}/paper.tex`]: TEX,
221
+ [`${C}/PIPELINE-STATUS.md`]: "no frontmatter\n",
222
+ [`${C}/sources/x/paper.tex`]: TEX,
223
+ });
224
+ expect(r.files.filter((f) => f.startsWith("papers/venues/"))).toEqual([
225
+ RECORD,
226
+ ]);
227
+ });
228
+ });