paperlint 20.6.1 → 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.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/default-levels.d.ts +5 -0
- package/dist/default-levels.d.ts.map +1 -0
- package/dist/default-levels.js +36 -0
- package/dist/default-levels.js.map +1 -0
- package/dist/folder-venue-rule.d.ts +1 -1
- package/dist/folder-venue-rule.d.ts.map +1 -1
- package/dist/folder-venue-rule.js.map +1 -1
- package/dist/tex-venue-rules.d.ts +4 -24
- package/dist/tex-venue-rules.d.ts.map +1 -1
- package/dist/tex-venue-rules.js +6 -84
- package/dist/tex-venue-rules.js.map +1 -1
- package/dist/venue-leftover.d.ts +50 -0
- package/dist/venue-leftover.d.ts.map +1 -0
- package/dist/venue-leftover.js +129 -0
- package/dist/venue-leftover.js.map +1 -0
- package/docs/rules/tex/venue-leftover.md +34 -3
- package/docs/rules.md +1 -1
- package/package.json +2 -1
- package/scripts/eslint-file-length.mjs +2 -2
- package/scripts/release-config.test.ts +114 -0
- package/scripts/release-type.test.ts +86 -0
- package/scripts/release-type.ts +76 -0
- package/scripts/semantic-release-plugins.d.ts +20 -1
- package/src/default-levels.test.ts +43 -0
- package/src/default-levels.ts +53 -0
- package/src/folder-venue-rule.ts +2 -1
- package/src/rule-cases.test.ts +10 -3
- package/src/tex-venue-rules.test.ts +63 -129
- package/src/tex-venue-rules.ts +25 -146
- package/src/venue-leftover.test.ts +112 -0
- package/src/venue-leftover.ts +207 -0
|
@@ -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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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,
|
|
1392
|
-
//
|
|
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
|
-
|
|
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
|
|
package/src/tex-venue-rules.ts
CHANGED
|
@@ -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
|
-
): {
|
|
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(
|
|
721
|
+
reportInPaper(
|
|
722
|
+
context,
|
|
723
|
+
meta.messages,
|
|
724
|
+
r.paper,
|
|
725
|
+
judge({ ...r.reading, options }),
|
|
726
|
+
);
|
|
848
727
|
},
|
|
849
728
|
};
|
|
850
729
|
},
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tex/venue-leftover`'s judge (`src/venue-leftover.ts`): where it reads — the venue lines wherever
|
|
3
|
+
* they stand, the front matter always, the body only with `body` — and a name the parser gave no
|
|
4
|
+
* place. The rule as ESLint runs it, on whole papers, is in `src/tex-venue-rules.test.ts`.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { latexReader } from "./adapters/latex/index.ts";
|
|
8
|
+
import { memoryFiles } from "./adapters/memory/index.ts";
|
|
9
|
+
import type { Outline } from "./domain/tex-document.ts";
|
|
10
|
+
import { resolvePreset } from "./presets.ts";
|
|
11
|
+
import {
|
|
12
|
+
frontMatterEnd,
|
|
13
|
+
judgeLeftover,
|
|
14
|
+
leftoverPlaces,
|
|
15
|
+
} from "./venue-leftover.ts";
|
|
16
|
+
import { PAPER, shipped, VENUES } from "../test/venue-rules-lint.ts";
|
|
17
|
+
|
|
18
|
+
/** An outline whose first section starts at `at` (null: no section; "unplaced": one with no place). */
|
|
19
|
+
const outline = (at: number | null | "unplaced"): Outline => ({
|
|
20
|
+
sections:
|
|
21
|
+
at === null
|
|
22
|
+
? []
|
|
23
|
+
: [
|
|
24
|
+
{
|
|
25
|
+
title: "Introduction",
|
|
26
|
+
place:
|
|
27
|
+
at === "unplaced"
|
|
28
|
+
? { kind: "unplaced" }
|
|
29
|
+
: { kind: "at", span: { start: at, end: at + 21 } },
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
backMatter: null,
|
|
33
|
+
end: null,
|
|
34
|
+
});
|
|
35
|
+
const span = (start: number) => ({ start, end: start + 5 });
|
|
36
|
+
|
|
37
|
+
describe("frontMatterEnd", () => {
|
|
38
|
+
it("is where the first section starts, or null without a placed one", () => {
|
|
39
|
+
expect(
|
|
40
|
+
[outline(100), outline(null), outline("unplaced")].map(frontMatterEnd),
|
|
41
|
+
).toEqual([100, null, null]);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("leftoverPlaces — which prose is read", () => {
|
|
46
|
+
it("by default the front matter only: before the first section, not after it, not unplaced", () => {
|
|
47
|
+
const { read } = leftoverPlaces([], outline(100), []);
|
|
48
|
+
expect([read(span(10)), read(span(150)), read(null)]).toEqual([
|
|
49
|
+
true,
|
|
50
|
+
false,
|
|
51
|
+
false,
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("with `body: true`, everything, a name with no place included", () => {
|
|
56
|
+
const { read } = leftoverPlaces([], outline(100), [{ body: true }]);
|
|
57
|
+
expect([read(span(10)), read(span(150)), read(null)]).toEqual([
|
|
58
|
+
true,
|
|
59
|
+
true,
|
|
60
|
+
true,
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("a paper with no section is all front matter", () => {
|
|
65
|
+
const { read } = leftoverPlaces([], outline(null), [{ body: false }]);
|
|
66
|
+
expect([read(span(10)), read(null)]).toEqual([true, true]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("a venue line holds a name wherever it stands; an unplaced line holds none", () => {
|
|
70
|
+
const { inLine } = leftoverPlaces(
|
|
71
|
+
[{ kind: "at", span: { start: 200, end: 260 } }, { kind: "unplaced" }],
|
|
72
|
+
outline(100),
|
|
73
|
+
[],
|
|
74
|
+
);
|
|
75
|
+
expect([inLine(span(210)), inLine(span(10)), inLine(null)]).toEqual([
|
|
76
|
+
true,
|
|
77
|
+
false,
|
|
78
|
+
false,
|
|
79
|
+
]);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("an option the schema does not declare is refused, not ignored", () => {
|
|
83
|
+
expect(() =>
|
|
84
|
+
leftoverPlaces([], outline(null), [{ bodies: true }]),
|
|
85
|
+
).toThrow();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("judgeLeftover, on places the parser did not give", () => {
|
|
90
|
+
const files = memoryFiles(shipped);
|
|
91
|
+
const aidc = resolvePreset("paperlint:aidc-2026", `${PAPER}/paperlint.json`, {
|
|
92
|
+
files,
|
|
93
|
+
venuesDir: VENUES,
|
|
94
|
+
});
|
|
95
|
+
const preset = aidc.ok ? aidc.value : null;
|
|
96
|
+
|
|
97
|
+
it("a venue line with no place holds no name; a parent's name no shipped venue carries is shown as written", () => {
|
|
98
|
+
expect(preset).not.toBeNull();
|
|
99
|
+
if (preset === null) return;
|
|
100
|
+
const src = "Unlike AISec, and Gone 2025.";
|
|
101
|
+
// The line is unplaced, so «AISec» without a year stands in prose: silent.
|
|
102
|
+
const found = judgeLeftover(
|
|
103
|
+
latexReader.renderedRuns(src),
|
|
104
|
+
{ ...preset, parentNames: ["Gone"] },
|
|
105
|
+
[],
|
|
106
|
+
leftoverPlaces([{ kind: "unplaced" }], latexReader.outline(src), []),
|
|
107
|
+
);
|
|
108
|
+
expect(found.map((f) => f.data)).toEqual([
|
|
109
|
+
{ name: "Gone", other: "Gone 2025", venue: "AIDC 2026" },
|
|
110
|
+
]);
|
|
111
|
+
});
|
|
112
|
+
});
|