paperlint 20.6.0 → 20.6.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 (39) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/corpus-layout-rule.d.ts +6 -2
  3. package/dist/corpus-layout-rule.d.ts.map +1 -1
  4. package/dist/corpus-layout-rule.js +6 -2
  5. package/dist/corpus-layout-rule.js.map +1 -1
  6. package/dist/default-levels.d.ts +5 -0
  7. package/dist/default-levels.d.ts.map +1 -0
  8. package/dist/default-levels.js +36 -0
  9. package/dist/default-levels.js.map +1 -0
  10. package/dist/folder-venue-rule.d.ts +1 -1
  11. package/dist/folder-venue-rule.d.ts.map +1 -1
  12. package/dist/folder-venue-rule.js.map +1 -1
  13. package/dist/tex-venue-rules.d.ts +4 -24
  14. package/dist/tex-venue-rules.d.ts.map +1 -1
  15. package/dist/tex-venue-rules.js +6 -84
  16. package/dist/tex-venue-rules.js.map +1 -1
  17. package/dist/venue-leftover.d.ts +50 -0
  18. package/dist/venue-leftover.d.ts.map +1 -0
  19. package/dist/venue-leftover.js +129 -0
  20. package/dist/venue-leftover.js.map +1 -0
  21. package/docs/rules/corpus/allowed-files-only.md +9 -8
  22. package/docs/rules/tex/venue-leftover.md +34 -3
  23. package/docs/rules.md +2 -2
  24. package/package.json +2 -1
  25. package/scripts/eslint-file-length.mjs +2 -2
  26. package/scripts/release-config.test.ts +114 -0
  27. package/scripts/release-type.test.ts +86 -0
  28. package/scripts/release-type.ts +76 -0
  29. package/scripts/semantic-release-plugins.d.ts +20 -1
  30. package/src/corpus-layout-rule.test.ts +3 -1
  31. package/src/corpus-layout-rule.ts +7 -3
  32. package/src/default-levels.test.ts +43 -0
  33. package/src/default-levels.ts +53 -0
  34. package/src/folder-venue-rule.ts +2 -1
  35. package/src/rule-cases.test.ts +10 -3
  36. package/src/tex-venue-rules.test.ts +63 -129
  37. package/src/tex-venue-rules.ts +25 -146
  38. package/src/venue-leftover.test.ts +112 -0
  39. package/src/venue-leftover.ts +207 -0
@@ -113,8 +113,10 @@ describe("corpus/allowed-files-only: a corpus that stores copies with no papers.
113
113
  "papers/venues/kept/papers.json": EMPTY.replace("agent", "kept"),
114
114
  "papers/venues/kept/pdf/.gitkeep": "",
115
115
  });
116
+ // Guards: a corpus folder made before papers.json existed warns and never fails the build (v20.6.0
117
+ // shipped this rule at error in a minor release, which turned such a consumer red).
116
118
  expect({ code: r.code, found: r.found }).toEqual({
117
- code: 1,
119
+ code: 0,
118
120
  found: [
119
121
  ["paperlint.json", 1, "papers/venues/agent/"],
120
122
  ["paperlint.json", 1, "papers/venues/other/"],
@@ -139,7 +139,11 @@ export function corpusLayoutRules(
139
139
  };
140
140
  }
141
141
 
142
- /** On by default, on every corpus's `papers.json` and the root `paperlint.json`. */
142
+ /**
143
+ * On by default, on every corpus's `papers.json` and the root `paperlint.json`, at `warn`: a corpus
144
+ * folder made before `papers.json` existed is a migration to do, not a broken build. Raising it to
145
+ * `error` is a major release.
146
+ */
143
147
  export const CORPUS_LAYOUT_RULE_LEVELS: Readonly<
144
- Record<"corpus/allowed-files-only", "error">
145
- > = { "corpus/allowed-files-only": "error" };
148
+ Record<"corpus/allowed-files-only", "warn">
149
+ > = { "corpus/allowed-files-only": "warn" };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The default rule set, kept in `default-rules.json` at the repository root. The release compares the
3
+ * file at the last release tag with HEAD (`scripts/release-type.ts`), so a change here that the file
4
+ * does not show would release without its version bump. After an intended change:
5
+ * `npx vitest run src/default-levels.test.ts -u`, and commit the file.
6
+ */
7
+ import { describe, expect, it } from "vitest";
8
+ import { buildConfig } from "./cli.ts";
9
+ import { defaultLevels } from "./default-levels.ts";
10
+
11
+ describe("defaultLevels", () => {
12
+ it("keeps each rule's highest level, in every severity form, and drops what is off", () => {
13
+ // Guards: a rule at warn in one block and error in another is an error rule.
14
+ expect(
15
+ defaultLevels([
16
+ { rules: { "a/x": "warn", "a/off": "off", "b/y": 1 } },
17
+ { rules: { "a/x": ["error", { n: 1 }], "a/off": 0, "c/z": 2 } },
18
+ ]),
19
+ ).toEqual({ "a/x": "error", "b/y": "warn", "c/z": "error" });
20
+ });
21
+
22
+ it("refuses a value that is no severity", () => {
23
+ // Guards: ESLint refuses it too; read as "off", it would drop a rule from the snapshot unseen.
24
+ expect(() => defaultLevels([{ rules: { "a/x": "loud" } }])).toThrow(
25
+ "not an ESLint severity: loud",
26
+ );
27
+ });
28
+
29
+ it("an empty config has no default rules", () => {
30
+ expect(defaultLevels([{}, { rules: {} }])).toEqual({});
31
+ });
32
+ });
33
+
34
+ describe("default-rules.json", () => {
35
+ it("is the default rule set of a project with no configuration", async () => {
36
+ const levels = defaultLevels(buildConfig({}, { sentinel: "tex language" }));
37
+ // Guards: a broken read of the config would snapshot nothing and pass.
38
+ expect(Object.keys(levels).length).toBeGreaterThan(30);
39
+ await expect(`${JSON.stringify(levels, null, 2)}\n`).toMatchFileSnapshot(
40
+ "../default-rules.json",
41
+ );
42
+ });
43
+ });
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The default rule set as a record: each rule a project gets with no configuration, at the highest
3
+ * level any of paperlint's own config blocks gives it. `default-levels.test.ts` keeps it in
4
+ * `default-rules.json`, and the release reads that file (`scripts/release-type.ts`): a rule that
5
+ * joins the set at `error`, or rises to `error`, makes the release a major one.
6
+ */
7
+ import { pipe, flatMap, groupBy, mapValues, firstBy, entries } from "remeda";
8
+ import type { ConfigBlock } from "./rules-config.ts";
9
+
10
+ export type Level = "warn" | "error";
11
+
12
+ const LEVEL_OF: Readonly<Record<string, Level | "off">> = {
13
+ off: "off",
14
+ warn: "warn",
15
+ error: "error",
16
+ "0": "off",
17
+ "1": "warn",
18
+ "2": "error",
19
+ };
20
+
21
+ const RANK: Readonly<Record<Level | "off", number>> = {
22
+ off: 0,
23
+ warn: 1,
24
+ error: 2,
25
+ };
26
+
27
+ /** A rule entry's level: `"error"`, `2` or `["error", options]` alike; any other value is refused. */
28
+ const levelOf = (entry: unknown): Level | "off" => {
29
+ const severity = String(Array.isArray(entry) ? entry[0] : entry);
30
+ const level = LEVEL_OF[severity];
31
+ if (level === undefined)
32
+ throw new Error(`not an ESLint severity: ${severity}`);
33
+ return level;
34
+ };
35
+
36
+ /** Every rule the blocks turn on, by id, at its highest level; ids in order. */
37
+ export const defaultLevels = (
38
+ blocks: readonly ConfigBlock[],
39
+ ): Readonly<Record<string, Level>> => {
40
+ const highest = pipe(
41
+ blocks,
42
+ flatMap((b) =>
43
+ entries(b.rules ?? {}).map(([id, e]) => ({ id, level: levelOf(e) })),
44
+ ),
45
+ groupBy((r) => r.id),
46
+ mapValues((rs) => firstBy(rs, [(r) => RANK[r.level], "desc"]).level),
47
+ );
48
+ return Object.fromEntries(
49
+ Object.entries(highest)
50
+ .filter((pair): pair is [string, Level] => pair[1] !== "off")
51
+ .sort(([a], [b]) => a.localeCompare(b)),
52
+ );
53
+ };
@@ -29,7 +29,8 @@ import { basename, dirname } from "node:path";
29
29
  import { venuesNamedBy, type NamedIn } from "./domain/venue-name.ts";
30
30
  import { editionLabel } from "./domain/edition.ts";
31
31
  import { folderNamesOf, paperPreset, type Preset } from "./presets.ts";
32
- import { otherVenues, type OtherVenue } from "./tex-venue-rules.ts";
32
+ import { otherVenues } from "./tex-venue-rules.ts";
33
+ import type { OtherVenue } from "./venue-leftover.ts";
33
34
  import type { Finding, VenueRuleDeps } from "./venue-rules.ts";
34
35
 
35
36
  /** The file the rule reports on: one per paper folder. */
@@ -1408,13 +1408,20 @@ const CASES: Readonly<Record<string, RuleCases>> = {
1408
1408
  }),
1409
1409
  }),
1410
1410
  },
1411
- // EMNLP 2026, a shipped venue (REALM's conference), named with its year in a BlindConf paper's text.
1411
+ // EMNLP 2026, a shipped venue (REALM's conference), named with its year in a BlindConf paper's
1412
+ // front matter: the default reads prose before the first \section only (#552).
1412
1413
  "tex/venue-leftover": {
1413
1414
  reports: {
1414
- tree: blind("First written for EMNLP 2026."),
1415
+ tree: paper(
1416
+ tex(
1417
+ `First written for EMNLP 2026.\n\\section{Introduction}\nText.\n${STATEMENT}`,
1418
+ IEEE,
1419
+ ),
1420
+ BLIND_PAPER,
1421
+ ),
1415
1422
  file: TEX_FILE,
1416
1423
  severity: 1,
1417
- line: 4,
1424
+ line: 3,
1418
1425
  },
1419
1426
  silent: blind("Text."),
1420
1427
  },
@@ -3,119 +3,30 @@
3
3
  * memory beside the SHIPPED presets, so a preset edit that breaks a check shows here. Each rule has
4
4
  * both halves: the finding a planted defect produces, and the silence of a conforming source.
5
5
  */
6
- import { readdirSync, readFileSync } from "node:fs";
7
- import { join } from "node:path";
8
6
  import { describe, expect, it } from "vitest";
9
7
  import { memoryFiles } from "./adapters/memory/index.ts";
10
- import { sourcesCodec } from "./adapters/sources-record/index.ts";
11
- import { presetsDir } from "./package-dirs.ts";
12
8
  import { latexReader } from "./adapters/latex/index.ts";
13
9
  import {
14
- cyclePortRules,
15
10
  judgeRequiredSections,
16
- judgeLeftover,
17
11
  judgeStyle,
18
12
  judgeTemplate,
19
13
  otherStyles,
20
14
  otherVenues,
21
15
  FORMAT_RULE_LEVELS,
22
- formatRules,
23
16
  TEX_VENUE_RULE_LEVELS,
24
- texVenueRules,
25
17
  } from "./tex-venue-rules.ts";
26
18
  import { resolvePreset } from "./presets.ts";
27
19
  import { buildConfig, SHIPPED_RULES } from "./cli.ts";
28
20
  import { builtPaper } from "../test/recorded-fixture.ts";
29
21
  import { venuePreset } from "../test/support.ts";
30
-
31
- const VENUES = presetsDir();
32
- const PAPER = "/work/papers/p";
33
- /** What the rules read with besides the files: the presets, the LaTeX reader, the record's schema. */
34
- const READERS = { venuesDir: VENUES, latex: latexReader, codec: sourcesCodec };
35
- const shipped = Object.fromEntries(
36
- readdirSync(VENUES)
37
- .filter((f) => f.endsWith(".jsonc") || f.endsWith(".json"))
38
- .map((f) => [join(VENUES, f), readFileSync(join(VENUES, f))]),
39
- );
40
-
41
- interface Finding {
42
- readonly rule: string;
43
- readonly messageId: string;
44
- readonly message: string;
45
- readonly line: number;
46
- }
47
-
48
- /** The line and 1-based column of an offset, as ESLint's text source code gives them. */
49
- const locOf = (src: string) => (i: number) => {
50
- const before = src.slice(0, i).split("\n");
51
- return { line: before.length, column: (before.at(-1) ?? "").length + 1 };
52
- };
53
-
54
- /**
55
- * Every venue-conformance rule over one `paper.tex`, the way ESLint runs them: `create`, then
56
- * `root`. `settings` is the paper's paperlint.json (absent: no file); `extra` more files.
57
- */
58
- function lint(
59
- tex: string,
60
- settings: object | undefined,
61
- {
62
- filename = `${PAPER}/paper.tex`,
63
- extra = {},
64
- raw = true,
65
- }: {
66
- filename?: string;
67
- extra?: Record<string, string>;
68
- /** false: the source code carries no `raw` (not the `.tex` language's), only `text`. */
69
- raw?: boolean;
70
- } = {},
71
- ): Finding[] {
72
- const files = memoryFiles({
73
- ...shipped,
74
- ...(settings === undefined
75
- ? {}
76
- : { [`${PAPER}/paperlint.json`]: JSON.stringify(settings) }),
77
- ...extra,
78
- });
79
- const out: Finding[] = [];
80
- const deps = { files, ...READERS };
81
- for (const [id, rule] of [
82
- ...Object.entries(texVenueRules(deps)).map(
83
- ([n, r]) => [`tex/${n}`, r] as const,
84
- ),
85
- ...Object.entries(formatRules(deps)).map(
86
- ([n, r]) => [`format/${n}`, r] as const,
87
- ),
88
- ...Object.entries(cyclePortRules(deps)).map(
89
- ([n, r]) => [`cycle/${n}`, r] as const,
90
- ),
91
- ]) {
92
- const visitor = rule.create({
93
- filename,
94
- sourceCode: {
95
- text: tex,
96
- ...(raw ? { raw: tex } : {}),
97
- getLocFromIndex: locOf(tex),
98
- },
99
- report: (d) =>
100
- out.push({
101
- rule: id,
102
- // A finding from an included file arrives as a whole message, its file at the front.
103
- messageId: "messageId" in d ? d.messageId : "(message)",
104
- message:
105
- "messageId" in d
106
- ? Object.entries(d.data ?? {}).reduce(
107
- (m, [k, v]) => m.replaceAll(`{{${k}}}`, String(v)),
108
- rule.meta.messages[d.messageId] ??
109
- `(no message ${d.messageId})`,
110
- )
111
- : d.message,
112
- line: d.loc.start.line,
113
- }),
114
- });
115
- visitor.root?.();
116
- }
117
- return out;
118
- }
22
+ import {
23
+ lint,
24
+ PAPER,
25
+ READERS,
26
+ shipped,
27
+ VENUES,
28
+ type Finding,
29
+ } from "../test/venue-rules-lint.ts";
119
30
 
120
31
  const ids = (fs: readonly Finding[]) =>
121
32
  fs.map((f) => `${f.rule}:${f.messageId}`).sort();
@@ -1127,6 +1038,55 @@ describe("tex/venue-leftover — another venue named in the text", () => {
1127
1038
  });
1128
1039
  });
1129
1040
 
1041
+ describe("tex/venue-leftover — where a leftover is looked for (#552)", () => {
1042
+ const ACM = { extends: "paperlint:acm-sigconf", kind: "research" };
1043
+ const ASE_LINE =
1044
+ "\\acmConference[ASE '26]{Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering}{October 12--16, 2026}{Munich, Germany}";
1045
+ const CITED =
1046
+ "\\section{Introduction}\nLam~et~al.\\ (\\emph{CodeCrash}, NeurIPS 2025) report a drop.\n\\section{Conclusion}\nText.\n";
1047
+
1048
+ it("a family preset names no venue, so nothing is another venue: silent", () => {
1049
+ // Guards: an ASE paper on the generic ACM template was told its own \\acmConference is a leftover.
1050
+ const tex = paper(
1051
+ "\\documentclass[sigconf]{acmart}",
1052
+ `${ASE_LINE}\n${BODY}`,
1053
+ );
1054
+ expect(leftovers(lint(tex, ACM))).toEqual([]);
1055
+ });
1056
+
1057
+ it("a venue named in the body after the first section is related work by default: silent", () => {
1058
+ // Guards: a CCS paper citing «(CodeCrash, NeurIPS 2025)» was told it is a leftover.
1059
+ expect(leftovers(lint(aidcPaper(`${CITED}${STATEMENT}`), AIDC))).toEqual(
1060
+ [],
1061
+ );
1062
+ });
1063
+
1064
+ it("with `body: true` the body is read too, and the same citation is reported", () => {
1065
+ const fs = leftovers(
1066
+ lint(aidcPaper(`${CITED}${STATEMENT}`), AIDC, {
1067
+ options: [{ body: true }],
1068
+ }),
1069
+ );
1070
+ expect(fs.map((f) => f.line)).toEqual([5]);
1071
+ });
1072
+
1073
+ it("the front matter is read whatever the option: the author block's leftover is still reported", () => {
1074
+ // Guards: narrowing the prose scan must not lose the leftover a reviewer reads before the abstract.
1075
+ expect(
1076
+ leftovers(
1077
+ lint(aidcPaper(`${INSTITUTION}\n${BODY}${STATEMENT}`), AIDC),
1078
+ ).map((f) => f.line),
1079
+ ).toEqual([4, 4]);
1080
+ });
1081
+
1082
+ it("a venue command after the first section still counts: it states the paper's venue", () => {
1083
+ const tex = aidcPaper(
1084
+ `${BODY}\\acmConference[AISec '26]{AISec}{2026}{Salt Lake City}\n${STATEMENT}`,
1085
+ );
1086
+ expect(leftovers(lint(tex, AIDC)).length).toBeGreaterThan(0);
1087
+ });
1088
+ });
1089
+
1130
1090
  describe("tex/venue-leftover — a workshop's parent conference (`parent`) is the paper's own", () => {
1131
1091
  const agenticdev = (text: string) =>
1132
1092
  paper("\\documentclass[sigconf]{acmart}", `${text}\nText.`);
@@ -1388,43 +1348,17 @@ describe("tex/venue-leftover — where names are found, and whose they are", ()
1388
1348
  ).toEqual([]);
1389
1349
  });
1390
1350
 
1391
- it("under a family, a venue that extends it is another venue", () => {
1392
- // ieee-conference is on aidc's chain, so under the family aidc is ANOTHER venue.
1351
+ it("under a family, no venue is another venue: the family names none, so it is silent", () => {
1352
+ // Guards: «Accepted at AAAI 2026» on the generic AAAI template, and an ASE paper's own
1353
+ // \\acmConference on the generic ACM one, were reported as leftovers (#552). A family cannot
1354
+ // know which venue the paper is for, so it has nothing to compare a name with.
1393
1355
  const tex = paper(
1394
1356
  "\\documentclass[conference]{IEEEtran}",
1395
1357
  "Accepted at AIDC 2026. Formerly at AISec 2026.",
1396
1358
  );
1397
1359
  expect(
1398
- leftovers(lint(tex, { extends: "paperlint:ieee-conference" }))
1399
- .map((f) => /«(.*?)»/u.exec(f.message)?.[1])
1400
- .sort(),
1401
- ).toEqual(["AIDC", "AISec"]);
1402
- });
1403
- });
1404
-
1405
- describe("tex/venue-leftover, judged on places the parser did not give", () => {
1406
- const files = memoryFiles(shipped);
1407
- const aidc = resolvePreset("paperlint:aidc-2026", `${PAPER}/paperlint.json`, {
1408
- files,
1409
- venuesDir: VENUES,
1410
- });
1411
- const preset = aidc.ok ? aidc.value : null;
1412
-
1413
- it("a venue line with no place holds no name; a parent's name no shipped venue carries is shown as written", () => {
1414
- expect(preset).not.toBeNull();
1415
- if (preset === null) return;
1416
- const src = "Unlike AISec, and Gone 2025.";
1417
- const runs = latexReader.renderedRuns(src);
1418
- // The line is unplaced, so «AISec» without a year stands in prose: silent.
1419
- const found = judgeLeftover(
1420
- runs,
1421
- [{ kind: "unplaced" }],
1422
- { ...preset, parentNames: ["Gone"] },
1423
- [],
1424
- );
1425
- expect(found.map((f) => f.data)).toEqual([
1426
- { name: "Gone", other: "Gone 2025", venue: "AIDC 2026" },
1427
- ]);
1360
+ leftovers(lint(tex, { extends: "paperlint:ieee-conference" })),
1361
+ ).toEqual([]);
1428
1362
  });
1429
1363
  });
1430
1364
 
@@ -36,8 +36,6 @@ import {
36
36
  missingOptions,
37
37
  optionsInEffect,
38
38
  readWhole,
39
- runText,
40
- spanIn,
41
39
  usepackageLine,
42
40
  type ClassCandidate,
43
41
  type ClassLine,
@@ -49,7 +47,6 @@ import {
49
47
  type Place,
50
48
  type StylePackage,
51
49
  type Span,
52
- type TextRun,
53
50
  } from "./domain/tex-document.ts";
54
51
  import type { LatexReader } from "./ports/latex.ts";
55
52
  import {
@@ -59,13 +56,17 @@ import {
59
56
  type Preset,
60
57
  type PresetTemplate,
61
58
  } from "./presets.ts";
62
- import type { NamedVenue } from "./domain/venue-name.ts";
63
- import { editionLabel } from "./domain/edition.ts";
64
59
  import type { PaperSource } from "./domain/paper-source.ts";
65
60
  import { readPaper, reportInPaper, type ProseDeps } from "./tex-paper.ts";
66
61
  import type { RequiredSection } from "./tex-requirements.ts";
67
62
  import type { Finding, VenueRuleDeps } from "./venue-rules.ts";
68
63
  import { isPorting } from "./domain/cycle.ts";
64
+ import {
65
+ judgeLeftover,
66
+ LEFTOVER_SCHEMA,
67
+ leftoverPlaces,
68
+ type OtherVenue,
69
+ } from "./venue-leftover.ts";
69
70
 
70
71
  /** A finding and where it points; null points at the top of the file. */
71
72
  export interface Located extends Finding {
@@ -458,143 +459,6 @@ export function judgeRequiredSections(
458
459
  );
459
460
  }
460
461
 
461
- /**
462
- * Another shipped venue as the text names it: the word for it (its `name`), every name it goes by,
463
- * and its edition's year (from its id).
464
- */
465
- export type OtherVenue = NamedVenue & Pick<Preset, "year" | "declaredAliases">;
466
-
467
- /**
468
- * A year beside a name, right after it: `2027`, `'27` or `’27`, after spaces or none (`~` renders
469
- * as a no-break space). Anchored: it is tried on the text after the name.
470
- */
471
- const YEAR_AFTER = /^[\s\u00a0]*(?:(\d{4})|['’](\d{2}))(?![\p{L}\p{N}])/u;
472
-
473
- /** The year written right after offset `end` of `text`, or null. `'27` is 2027. Pure. */
474
- function yearAfter(text: string, end: number): number | null {
475
- const m = YEAR_AFTER.exec(text.slice(end));
476
- if (m === null) return null;
477
- return m[1] !== undefined
478
- ? Number.parseInt(m[1], 10)
479
- : 2000 + Number.parseInt(String(m[2]), 10);
480
- }
481
-
482
- /** `s` as a pattern that matches it literally. */
483
- const literal = (s: string): string =>
484
- s.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
485
-
486
- /** One name a match is judged by: whether it is the paper's own, and the venue it shows as. */
487
- interface NameToJudge {
488
- readonly name: string;
489
- readonly own: boolean;
490
- readonly shows: string;
491
- }
492
-
493
- /**
494
- * Every name to look for, once each: every other shipped venue's, shown as that venue's `name`, and
495
- * the paper's own and its parent's, which count only in another edition. Pure.
496
- */
497
- function namesToJudge(
498
- preset: Pick<Preset, "label" | "aliases" | "parentNames">,
499
- others: readonly OtherVenue[],
500
- ): readonly NameToJudge[] {
501
- const own = new Set([...preset.aliases, ...preset.parentNames]);
502
- const shownBy = (name: string): string =>
503
- others.find((o) => o.aliases.includes(name))?.label ??
504
- (preset.aliases.includes(name) ? preset.label : name);
505
- const all = [...new Set([...others.flatMap((o) => o.aliases), ...own])];
506
- return all.map((name) => ({
507
- name,
508
- own: own.has(name),
509
- shows: shownBy(name),
510
- }));
511
- }
512
-
513
- /**
514
- * Whether a name at a place, with `year` beside it (null: none), names another venue than the
515
- * paper's edition (of year `paperYear`). Inside a venue-identity command (`inLine`) any other
516
- * venue's name counts; in prose only beside a year no older than the paper's year minus one, so
517
- * related work («ICSE 2019») and a bare acronym are not leftovers. The paper's own names, and its
518
- * parent's, count only beside another year: another edition of its own series. Pure.
519
- */
520
- export function namesAnotherEdition(
521
- n: { readonly own: boolean; readonly inLine: boolean },
522
- year: number | null,
523
- paperYear: number | null,
524
- ): boolean {
525
- const recent = paperYear === null || (year !== null && year >= paperYear - 1);
526
- if (n.own)
527
- return (
528
- year !== null &&
529
- paperYear !== null &&
530
- year !== paperYear &&
531
- (n.inLine || recent)
532
- );
533
- return n.inLine || (year !== null && recent);
534
- }
535
-
536
- /** A name to look for, with the pattern that finds it as a whole word. */
537
- type NameMatcher = NameToJudge & { readonly re: RegExp };
538
-
539
- /**
540
- * The findings of one name in one run: each whole-word match judged with the year beside it and
541
- * whether it stands in a venue-stating command (`inLine`). Pure.
542
- */
543
- function matchesIn(
544
- run: TextRun,
545
- n: NameMatcher,
546
- paper: {
547
- readonly inLine: (at: Span | null) => boolean;
548
- readonly year: number | null;
549
- readonly venue: string;
550
- },
551
- ): readonly Located[] {
552
- const { inLine, venue } = paper;
553
- const text = runText(run);
554
- return [...text.matchAll(n.re)].flatMap((m) => {
555
- const at = spanIn(run, m.index, m.index + m[0].length);
556
- const year = yearAfter(text, m.index + m[0].length);
557
- const judged = { own: n.own, inLine: inLine(at) };
558
- if (!namesAnotherEdition(judged, year, paper.year)) return [];
559
- const other = editionLabel(n.shows, year);
560
- return [{ messageId: "leftover", data: { name: m[0], other, venue }, at }];
561
- });
562
- }
563
-
564
- /**
565
- * Each place the rendered text names another venue than the paper's edition — a name as a whole
566
- * word, case and all, judged with the year beside it (`namesAnotherEdition`). `lines` are the spans
567
- * of the commands that state the paper's venue (`\acmConference` …).
568
- */
569
- export function judgeLeftover(
570
- runs: readonly TextRun[],
571
- lines: readonly Place[],
572
- preset: Preset,
573
- others: readonly OtherVenue[],
574
- ): readonly Located[] {
575
- const venue = editionLabel(preset.label, preset.year);
576
- const inLine = (at: Span | null): boolean =>
577
- at !== null &&
578
- lines.some(
579
- (l) =>
580
- l.kind === "at" && l.span.start <= at.start && at.start < l.span.end,
581
- );
582
- const names: readonly NameMatcher[] = namesToJudge(preset, others).map(
583
- (n) => ({
584
- ...n,
585
- re: new RegExp(
586
- `(?<![\\p{L}\\p{N}])${literal(n.name)}(?![\\p{L}\\p{N}])`,
587
- "gu",
588
- ),
589
- }),
590
- );
591
- return runs.flatMap((run) =>
592
- names.flatMap((n) =>
593
- matchesIn(run, n, { inLine, year: preset.year, venue }),
594
- ),
595
- );
596
- }
597
-
598
462
  /** Where a rule's page lives: `docs/rules/tex/<name>.md` on the default branch. */
599
463
  export const ruleDocsUrl = (
600
464
  name:
@@ -618,6 +482,8 @@ export const ruleDocsUrl = (
618
482
  /** What a judge reads: the paper's source through the reader, its preset, the other venues. */
619
483
  interface Reading {
620
484
  readonly src: string;
485
+ /** The rule's options from the config, as ESLint validated them against the rule's schema. */
486
+ readonly options: readonly unknown[];
621
487
  readonly latex: LatexReader;
622
488
  readonly preset: Preset;
623
489
  readonly others: () => readonly OtherVenue[];
@@ -731,9 +597,13 @@ const RULES: Readonly<
731
597
  judge: (r) =>
732
598
  judgeLeftover(
733
599
  r.latex.renderedRuns(r.src),
734
- r.latex.venueLines(r.src),
735
600
  r.preset,
736
601
  r.others(),
602
+ leftoverPlaces(
603
+ r.latex.venueLines(r.src),
604
+ r.latex.outline(r.src),
605
+ r.options,
606
+ ),
737
607
  ),
738
608
  meta: {
739
609
  type: "suggestion",
@@ -742,7 +612,7 @@ const RULES: Readonly<
742
612
  "the text names another shipped venue than the one the paper extends — a leftover from an earlier submission",
743
613
  url: ruleDocsUrl("venue-leftover"),
744
614
  },
745
- schema: [],
615
+ schema: LEFTOVER_SCHEMA,
746
616
  messages: {
747
617
  leftover:
748
618
  "«{{name}}» names {{other}}, and this paper extends {{venue}} — a leftover from an earlier submission? A reviewer reads it before the abstract. Comments and citation keys are not reported; a sentence that names the other venue on purpose can keep it with a disable directive",
@@ -814,7 +684,10 @@ function readingOf(
814
684
  filename: string,
815
685
  src: string,
816
686
  deps: TexVenueRuleDeps,
817
- ): { readonly reading: Reading; readonly paper: PaperSource } | null {
687
+ ): {
688
+ readonly reading: Omit<Reading, "options">;
689
+ readonly paper: PaperSource;
690
+ } | null {
818
691
  const dir = dirname(filename);
819
692
  const p = paperPreset(dir, deps);
820
693
  if (p.kind !== "resolved") return null;
@@ -843,8 +716,14 @@ function rule(name: RuleName, deps: TexVenueRuleDeps): TexRuleModule {
843
716
  root() {
844
717
  const sc = context.sourceCode;
845
718
  const r = readingOf(context.filename, sc.raw ?? sc.text, deps);
719
+ const options = context.options ?? [];
846
720
  if (r !== null)
847
- reportInPaper(context, meta.messages, r.paper, judge(r.reading));
721
+ reportInPaper(
722
+ context,
723
+ meta.messages,
724
+ r.paper,
725
+ judge({ ...r.reading, options }),
726
+ );
848
727
  },
849
728
  };
850
729
  },