paperlint 7.0.0 → 7.2.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 (152) hide show
  1. package/.github/workflows/ci.yml +3 -0
  2. package/.github/workflows/deadlines.yml +100 -0
  3. package/README.md +24 -11
  4. package/dist/adapters/hotcrp/deadlines.d.ts +8 -0
  5. package/dist/adapters/hotcrp/deadlines.d.ts.map +1 -0
  6. package/dist/adapters/hotcrp/deadlines.io.d.ts +6 -0
  7. package/dist/adapters/hotcrp/deadlines.io.d.ts.map +1 -0
  8. package/dist/adapters/hotcrp/deadlines.io.js +26 -0
  9. package/dist/adapters/hotcrp/deadlines.io.js.map +1 -0
  10. package/dist/adapters/hotcrp/deadlines.js +134 -0
  11. package/dist/adapters/hotcrp/deadlines.js.map +1 -0
  12. package/dist/adapters/hotcrp/index.d.ts +2 -0
  13. package/dist/adapters/hotcrp/index.d.ts.map +1 -1
  14. package/dist/adapters/hotcrp/index.js +2 -0
  15. package/dist/adapters/hotcrp/index.js.map +1 -1
  16. package/dist/cli.d.ts.map +1 -1
  17. package/dist/cli.js +42 -7
  18. package/dist/cli.js.map +1 -1
  19. package/dist/cycle-rules.d.ts +24 -0
  20. package/dist/cycle-rules.d.ts.map +1 -0
  21. package/dist/cycle-rules.js +212 -0
  22. package/dist/cycle-rules.js.map +1 -0
  23. package/dist/domain/body-pages.d.ts +29 -0
  24. package/dist/domain/body-pages.d.ts.map +1 -1
  25. package/dist/domain/body-pages.js +25 -0
  26. package/dist/domain/body-pages.js.map +1 -1
  27. package/dist/domain/cycle.d.ts +148 -0
  28. package/dist/domain/cycle.d.ts.map +1 -0
  29. package/dist/domain/cycle.js +281 -0
  30. package/dist/domain/cycle.js.map +1 -0
  31. package/dist/domain/deadline.d.ts +128 -0
  32. package/dist/domain/deadline.d.ts.map +1 -0
  33. package/dist/domain/deadline.js +281 -0
  34. package/dist/domain/deadline.js.map +1 -0
  35. package/dist/eslint-rules/cycle-stage.d.ts +39 -0
  36. package/dist/eslint-rules/cycle-stage.d.ts.map +1 -0
  37. package/dist/eslint-rules/cycle-stage.js +119 -0
  38. package/dist/eslint-rules/cycle-stage.js.map +1 -0
  39. package/dist/lib/paper-config.d.ts.map +1 -1
  40. package/dist/lib/paper-config.js +2 -0
  41. package/dist/lib/paper-config.js.map +1 -1
  42. package/dist/paper-includes.d.ts +3 -0
  43. package/dist/paper-includes.d.ts.map +1 -1
  44. package/dist/paper-includes.js +17 -2
  45. package/dist/paper-includes.js.map +1 -1
  46. package/dist/paper-settings.d.ts +7 -0
  47. package/dist/paper-settings.d.ts.map +1 -1
  48. package/dist/paper-settings.js +61 -8
  49. package/dist/paper-settings.js.map +1 -1
  50. package/dist/ports/venue-deadlines.d.ts +14 -0
  51. package/dist/ports/venue-deadlines.d.ts.map +1 -0
  52. package/dist/ports/venue-deadlines.js +2 -0
  53. package/dist/ports/venue-deadlines.js.map +1 -0
  54. package/dist/presets.d.ts +22 -3
  55. package/dist/presets.d.ts.map +1 -1
  56. package/dist/presets.js +26 -17
  57. package/dist/presets.js.map +1 -1
  58. package/dist/submission.d.ts +16 -0
  59. package/dist/submission.d.ts.map +1 -1
  60. package/dist/submission.js +59 -16
  61. package/dist/submission.js.map +1 -1
  62. package/dist/tex-requirements.d.ts +12 -0
  63. package/dist/tex-requirements.d.ts.map +1 -1
  64. package/dist/tex-requirements.js +26 -3
  65. package/dist/tex-requirements.js.map +1 -1
  66. package/dist/tex-venue-rules.d.ts +24 -2
  67. package/dist/tex-venue-rules.d.ts.map +1 -1
  68. package/dist/tex-venue-rules.js +98 -10
  69. package/dist/tex-venue-rules.js.map +1 -1
  70. package/dist/venue-rules.d.ts +12 -1
  71. package/dist/venue-rules.d.ts.map +1 -1
  72. package/dist/venue-rules.js +81 -17
  73. package/dist/venue-rules.js.map +1 -1
  74. package/docs/configuration.md +140 -12
  75. package/docs/e2e.md +14 -12
  76. package/docs/rules/cycle/evidence.md +87 -0
  77. package/docs/rules/cycle/port-done.md +75 -0
  78. package/docs/rules/cycle/record.md +152 -0
  79. package/docs/rules/cycle/stage.md +85 -0
  80. package/docs/rules/format/page-limit.md +18 -1
  81. package/docs/rules/tex/template.md +25 -5
  82. package/docs/rules/tex/venue-leftover.md +13 -0
  83. package/docs/rules.md +68 -55
  84. package/docs/submission.md +10 -1
  85. package/eslint-rules/cycle-stage.test.mjs +131 -0
  86. package/eslint-rules/cycle-stage.ts +141 -0
  87. package/eslint.config.mjs +41 -1
  88. package/fixtures/build-e2e/msr/PIPELINE-STATUS.md +3 -0
  89. package/fixtures/build-e2e/msr/expect.json +18 -0
  90. package/fixtures/build-e2e/msr/paper.tex +49 -0
  91. package/fixtures/build-e2e/msr/paperlint.json +1 -0
  92. package/fixtures/build-e2e/msr-appendix-after/PIPELINE-STATUS.md +3 -0
  93. package/fixtures/build-e2e/msr-appendix-after/expect.json +20 -0
  94. package/fixtures/build-e2e/msr-appendix-after/paper.tex +48 -0
  95. package/fixtures/build-e2e/msr-appendix-after/paperlint.json +1 -0
  96. package/lib/paper-config.ts +3 -0
  97. package/package.json +1 -1
  98. package/presets/aidc.jsonc +24 -3
  99. package/presets/aidc.md +6 -3
  100. package/presets/ieee-conference.md +1 -1
  101. package/presets/msr.jsonc +95 -0
  102. package/presets/msr.md +98 -0
  103. package/presets/venue-profile.schema.json +64 -0
  104. package/scripts/check.ts +4 -0
  105. package/scripts/refresh-deadlines.test.ts +431 -0
  106. package/scripts/refresh-deadlines.ts +387 -0
  107. package/skills/camera-ready/SKILL.md +8 -1
  108. package/skills/camera-ready/SKILL.md.spec.ts +7 -0
  109. package/skills/submission-portal/SKILL.md +2 -2
  110. package/skills/submission-portal/SKILL.md.spec.ts +1 -1
  111. package/skills/submit-paper/SKILL.md +9 -1
  112. package/skills/submit-paper/SKILL.md.spec.ts +8 -0
  113. package/src/adapters/hotcrp/cassette/README.md +22 -0
  114. package/src/adapters/hotcrp/cassette/deadlines-aidc26.html +17 -0
  115. package/src/adapters/hotcrp/cassette/deadlines-fse2027.html +24 -0
  116. package/src/adapters/hotcrp/cassette/deadlines-icse2027.html +25 -0
  117. package/src/adapters/hotcrp/cassette/deadlines-msr2027.html +25 -0
  118. package/src/adapters/hotcrp/cassette/deadlines-nosuch.html +18 -0
  119. package/src/adapters/hotcrp/cassette/deadlines-sosp26.html +26 -0
  120. package/src/adapters/hotcrp/deadlines.io.test.ts +86 -0
  121. package/src/adapters/hotcrp/deadlines.io.ts +27 -0
  122. package/src/adapters/hotcrp/deadlines.test.ts +170 -0
  123. package/src/adapters/hotcrp/deadlines.ts +161 -0
  124. package/src/adapters/hotcrp/index.ts +2 -0
  125. package/src/cli.test.ts +9 -0
  126. package/src/cli.ts +50 -6
  127. package/src/cycle-rules.test.ts +278 -0
  128. package/src/cycle-rules.ts +273 -0
  129. package/src/domain/body-pages.test.ts +144 -0
  130. package/src/domain/body-pages.ts +61 -1
  131. package/src/domain/cycle.test.ts +456 -0
  132. package/src/domain/cycle.ts +432 -0
  133. package/src/domain/deadline.test.ts +386 -0
  134. package/src/domain/deadline.ts +472 -0
  135. package/src/new-paper.test.ts +28 -0
  136. package/src/paper-includes.test.ts +26 -0
  137. package/src/paper-includes.ts +20 -2
  138. package/src/paper-settings-commands.test.ts +1 -1
  139. package/src/paper-settings.test.ts +167 -0
  140. package/src/paper-settings.ts +85 -11
  141. package/src/ports/venue-deadlines.ts +14 -0
  142. package/src/preset-card-rule.test.ts +1 -0
  143. package/src/presets.test.ts +171 -1
  144. package/src/presets.ts +65 -15
  145. package/src/rule-cases.test.ts +144 -0
  146. package/src/submission.test.ts +147 -4
  147. package/src/submission.ts +100 -18
  148. package/src/tex-requirements.ts +52 -4
  149. package/src/tex-venue-rules.test.ts +237 -0
  150. package/src/tex-venue-rules.ts +130 -15
  151. package/src/venue-rules.test.ts +255 -2
  152. package/src/venue-rules.ts +115 -22
@@ -0,0 +1,472 @@
1
+ /**
2
+ * A VENUE'S DEADLINE — what each page said about it, and which instant binds.
3
+ *
4
+ * One entry per deadline of an attempt, in a cycle's `deadlines`:
5
+ *
6
+ * {
7
+ * "what": "submission",
8
+ * "observed": [
9
+ * { "at": "2026-10-20T04:00:00Z", "source": "portal", "url": "…/deadlines", "read": "2026-10-05" },
10
+ * { "at": "2026-10-23 AoE", "source": "call", "url": "…/cfp", "read": "2026-10-05" }
11
+ * ],
12
+ * "override": { "at": "2026-10-27T04:00:00Z", "reason": "…", "evidence": "mail/extension.eml" }
13
+ * }
14
+ *
15
+ * ── OBSERVED, THEN OVERRIDDEN ──────────────────────────────────────────────────────────
16
+ * A READING is what one page said on one day: its instant, whether the page was the portal (which
17
+ * refuses the upload) or the call (which only announces), where, and when it was read. The portal
18
+ * and the call often disagree — an AoE day in a call is a day after the portal's UTC instant, and a
19
+ * HotCRP "submissions must be completed by" can fall on the call's abstract day — so both are kept,
20
+ * and the EARLIER binds: the safe reading of two. An OVERRIDE is a human decision that another
21
+ * instant binds (the chairs extended by mail); it wins, and it carries its reason and a file as
22
+ * evidence, so it is never a silent edit of a reading.
23
+ *
24
+ * ── THE WORDS ───────────────────────────────────────────────────────────────────────────
25
+ * A call says "abstract" and "paper"; HotCRP says registration, submission and resubmission. Here:
26
+ * `registration` is the abstract registration (a call's "abstract" date), `submission` the full paper
27
+ * (a call's "paper" date, HotCRP's "submissions must be completed by"), `resubmission` the updates a
28
+ * portal allows to a completed submission. Recorded honestly, a call's "paper" day and a portal's
29
+ * earlier "submission" cutoff are two readings of ONE deadline, and the earlier binds.
30
+ *
31
+ * Parsed by hand: the domain imports no schema library (see `src/CLAUDE.md`). Every object in the
32
+ * record refuses a key it does not know: an `override` typed under another name would otherwise look
33
+ * recorded and not be in force.
34
+ */
35
+ import { err, ok, type Result } from "./result.ts";
36
+ import { isRecord } from "./record.ts";
37
+
38
+ /** A calendar day, `YYYY-MM-DD`. */
39
+ export type IsoDate = string;
40
+ /** A moment, as an ISO string in UTC: `2026-10-20T04:00:00Z`. Never a bare date. */
41
+ export type Instant = string;
42
+
43
+ export type DeadlineWhat =
44
+ | "registration"
45
+ | "submission"
46
+ | "resubmission"
47
+ | "notification"
48
+ | "camera-ready";
49
+ /** The kinds, in the order a venue's deadlines keep. */
50
+ export const DEADLINE_WHATS: readonly DeadlineWhat[] = [
51
+ "registration",
52
+ "submission",
53
+ "resubmission",
54
+ "notification",
55
+ "camera-ready",
56
+ ];
57
+
58
+ /** What each kind is, in a call's words where they differ — said in every message that names the kinds. */
59
+ export const WHAT_MEANS: Readonly<Record<DeadlineWhat, string | null>> = {
60
+ registration: 'abstract registration: a call\'s "abstract" date',
61
+ submission: 'the full paper: a call\'s "paper" date',
62
+ resubmission: "updates to a completed submission",
63
+ notification: null,
64
+ "camera-ready": null,
65
+ };
66
+
67
+ export type DeadlineSource = "portal" | "call";
68
+
69
+ /** What one page said about one deadline, and on which day it was read. */
70
+ export interface Observation {
71
+ readonly at: Instant;
72
+ readonly source: DeadlineSource;
73
+ /** The page it was read on. */
74
+ readonly url: string;
75
+ readonly read: IsoDate;
76
+ }
77
+
78
+ /** A human decision that another instant binds, with why and the file it rests on. */
79
+ export interface Override {
80
+ readonly at: Instant;
81
+ readonly reason: string;
82
+ /** A file in the paper folder: the mail, the saved page. `cycle/evidence` requires it on disk. */
83
+ readonly evidence: string;
84
+ }
85
+
86
+ /** One deadline of an attempt, as the paper records it. */
87
+ export interface Deadline {
88
+ readonly what: DeadlineWhat;
89
+ readonly observed: readonly Observation[];
90
+ readonly override: Override | null;
91
+ }
92
+
93
+ /** One reading of one deadline, as a venue preset carries it. */
94
+ export interface Reading extends Observation {
95
+ readonly what: DeadlineWhat;
96
+ }
97
+
98
+ /** What binds a deadline: the override, or the reading that was earliest. */
99
+ export type Binding =
100
+ | { readonly kind: "override"; readonly override: Override }
101
+ | { readonly kind: "reading"; readonly reading: Observation };
102
+
103
+ /** A deadline in force: its instant, what set it, and every reading of it. */
104
+ export interface InForce {
105
+ readonly what: DeadlineWhat;
106
+ readonly at: Instant;
107
+ readonly by: Binding;
108
+ readonly readings: readonly Observation[];
109
+ }
110
+
111
+ /**
112
+ * What a venue's portal says about its deadlines, in paperlint's words — what the scheduled refresh
113
+ * of the shipped presets reads (`scripts/refresh-deadlines.ts`). One adapter per portal kind.
114
+ */
115
+ export interface PortalDeadlines {
116
+ /** The portal's clock when it answered, Unix seconds. */
117
+ readonly now: number;
118
+ /** Whether the portal takes submissions now. */
119
+ readonly open: boolean;
120
+ /** How the venue reviews, as the portal says it; null when it does not say. */
121
+ readonly blind: boolean | "optional" | "until-review" | null;
122
+ readonly deadlines: readonly PortalDeadline[];
123
+ }
124
+
125
+ /** One deadline the portal lists: its kind when it is one paperlint names, the portal's own label, and when. */
126
+ export interface PortalDeadline {
127
+ readonly what: DeadlineWhat | null;
128
+ readonly label: string;
129
+ readonly at: Instant;
130
+ }
131
+
132
+ // ── instants ───────────────────────────────────────────────────────────────────────────
133
+
134
+ const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
135
+ export const isIsoDate = (v: unknown): v is IsoDate =>
136
+ typeof v === "string" && ISO_DATE.test(v) && !Number.isNaN(Date.parse(v));
137
+
138
+ const asInstant = (ms: number): Instant =>
139
+ new Date(ms).toISOString().replace(/\.\d{3}Z$/, "Z");
140
+
141
+ /** Unix seconds → the instant, in UTC. */
142
+ export const instantOfUnix = (seconds: number): Instant =>
143
+ asInstant(seconds * 1000);
144
+
145
+ /** The forms `at` takes, for every message that refuses one. */
146
+ const INSTANT_FORMS = `an instant with its zone (2026-10-20T04:00:00Z) or a call's "YYYY-MM-DD AoE"`;
147
+
148
+ /**
149
+ * An ISO instant with its zone (`Z` or `±hh:mm`), or a call's `YYYY-MM-DD AoE`; normalised to UTC.
150
+ * A bare date or a zoneless time is refused: it is the deadline people get wrong.
151
+ */
152
+ export function instantOf(text: string): Result<Instant, string> {
153
+ const bad = err(
154
+ `"${text}" must be an instant with its zone (2026-10-20T04:00:00Z, 2026-10-20T09:00:00+05:00) or a call's "YYYY-MM-DD AoE"`,
155
+ );
156
+ const aoe = /^(\d{4}-\d{2}-\d{2}) AoE$/i.exec(text.trim());
157
+ if (aoe) {
158
+ const day = String(aoe[1]); // the group always participates in a match
159
+ // The end of that day at UTC−12: 23:59:59 there is 11:59:59 UTC of the next day.
160
+ const ms = Date.parse(`${day}T23:59:59-12:00`);
161
+ return Number.isNaN(ms) ? bad : ok(asInstant(ms));
162
+ }
163
+ if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(Z|[+-]\d{2}:\d{2})$/.test(text))
164
+ return bad;
165
+ const ms = Date.parse(text);
166
+ return Number.isNaN(ms) ? bad : ok(asInstant(ms));
167
+ }
168
+
169
+ // ── parsing ────────────────────────────────────────────────────────────────────────────
170
+
171
+ /** The first key of `v` that is not in `known`, as the refusal naming it; null when there is none. */
172
+ export const unknownKey = (
173
+ v: Readonly<Record<string, unknown>>,
174
+ known: readonly string[],
175
+ at: string,
176
+ whose: string,
177
+ ): string | null => {
178
+ const k = Object.keys(v).find((x) => !known.includes(x));
179
+ return k === undefined
180
+ ? null
181
+ : `${at}: unknown key "${k}" — ${whose} keys: ${known.join(", ")}`;
182
+ };
183
+
184
+ /** `v[key]` as an instant, or the refusal naming the key and both forms. */
185
+ const instantField = (
186
+ v: Readonly<Record<string, unknown>>,
187
+ key: string,
188
+ at: string,
189
+ ): Result<Instant, string> => {
190
+ const text = v[key];
191
+ const instant =
192
+ typeof text === "string" ? instantOf(text) : err("not a string");
193
+ return instant.ok
194
+ ? instant
195
+ : err(
196
+ `${at}: "${key}" must be ${INSTANT_FORMS}, got ${JSON.stringify(text)}`,
197
+ );
198
+ };
199
+
200
+ const nonEmpty = (v: unknown): v is string => typeof v === "string" && v !== "";
201
+
202
+ const READING_KEYS: readonly string[] = ["at", "source", "url", "read"];
203
+
204
+ /** `source`, `url` and `read` of a reading: where and when it was read. */
205
+ function provenance(
206
+ v: Readonly<Record<string, unknown>>,
207
+ at: string,
208
+ ): Result<Omit<Observation, "at">, string> {
209
+ const { source, url, read } = v;
210
+ if (source !== "portal" && source !== "call")
211
+ return err(
212
+ `${at}: "source" must be "portal" or "call", got ${JSON.stringify(source)} — a deadline moved by mail is an "override", with the mail as its "evidence"`,
213
+ );
214
+ if (!nonEmpty(url))
215
+ return err(`${at}: "url" must be where the deadline was read`);
216
+ if (!isIsoDate(read))
217
+ return err(`${at}: "read" must be the day the page was read, YYYY-MM-DD`);
218
+ return ok({ source, url, read });
219
+ }
220
+
221
+ function parseObservation(v: unknown, at: string): Result<Observation, string> {
222
+ if (!isRecord(v))
223
+ return err(`${at}: a reading must be { "at", "source", "url", "read" }`);
224
+ const unknown = unknownKey(v, READING_KEYS, at, "a reading's");
225
+ if (unknown !== null) return err(unknown);
226
+ const instant = instantField(v, "at", at);
227
+ if (!instant.ok) return instant;
228
+ const rest = provenance(v, at);
229
+ return rest.ok ? ok({ at: instant.value, ...rest.value }) : rest;
230
+ }
231
+
232
+ /** Each item of a list through `one`; the first refusal, naming its index. */
233
+ function eachOf<T>(
234
+ list: readonly unknown[],
235
+ at: string,
236
+ one: (v: unknown, at: string) => Result<T, string>,
237
+ ): Result<readonly T[], string> {
238
+ return list.reduce<Result<readonly T[], string>>((acc, v, i) => {
239
+ if (!acc.ok) return acc;
240
+ const p = one(v, `${at}[${String(i)}]`);
241
+ return p.ok ? ok([...acc.value, p.value]) : p;
242
+ }, ok([]));
243
+ }
244
+
245
+ /** The readings of one deadline: at most one per source — a re-read replaces the earlier one. */
246
+ function parseObserved(
247
+ v: unknown,
248
+ at: string,
249
+ ): Result<readonly Observation[], string> {
250
+ if (v === undefined) return ok([]);
251
+ if (!Array.isArray(v))
252
+ return err(
253
+ `${at}: "observed" must be a list of readings { "at", "source", "url", "read" }`,
254
+ );
255
+ const list = eachOf(v, `${at}.observed`, parseObservation);
256
+ if (!list.ok) return list;
257
+ const twice = (["portal", "call"] as const).find(
258
+ (s) => list.value.filter((o) => o.source === s).length > 1,
259
+ );
260
+ return twice === undefined
261
+ ? list
262
+ : err(
263
+ `${at}: two "${twice}" readings — keep one per source, the latest (its "read" says when)`,
264
+ );
265
+ }
266
+
267
+ const OVERRIDE_KEYS: readonly string[] = ["at", "reason", "evidence"];
268
+
269
+ function parseOverride(
270
+ v: unknown,
271
+ at: string,
272
+ ): Result<Override | null, string> {
273
+ if (v === undefined) return ok(null);
274
+ if (!isRecord(v))
275
+ return err(`${at}: "override" must be { "at", "reason", "evidence" }`);
276
+ const where = `${at}.override`;
277
+ const unknown = unknownKey(v, OVERRIDE_KEYS, where, "an override's");
278
+ if (unknown !== null) return err(unknown);
279
+ const instant = instantField(v, "at", where);
280
+ if (!instant.ok) return instant;
281
+ const { reason, evidence } = v;
282
+ if (!nonEmpty(reason))
283
+ return err(
284
+ `${where}: "reason" must say why this instant binds rather than the readings (the chairs extended it by mail, …)`,
285
+ );
286
+ return nonEmpty(evidence)
287
+ ? ok({ at: instant.value, reason, evidence })
288
+ : err(
289
+ `${where}: "evidence" must be a file in the paper folder — the mail or the saved page the override rests on`,
290
+ );
291
+ }
292
+
293
+ const isWhat = (v: unknown): v is DeadlineWhat =>
294
+ DEADLINE_WHATS.some((w) => w === v);
295
+
296
+ /** Every kind with what it is, for the message that refuses an unknown one. */
297
+ const KINDS_TEXT = DEADLINE_WHATS.map((w) => {
298
+ const means = WHAT_MEANS[w];
299
+ return means === null ? w : `${w} (${means})`;
300
+ }).join(", ");
301
+
302
+ const DEADLINE_KEYS: readonly string[] = ["what", "observed", "override"];
303
+
304
+ function parseDeadline(v: unknown, at: string): Result<Deadline, string> {
305
+ if (!isRecord(v))
306
+ return err(
307
+ `${at}: a deadline must be { "what", "observed": [ … ], "override"? }`,
308
+ );
309
+ const unknown = unknownKey(v, DEADLINE_KEYS, at, "a deadline's");
310
+ if (unknown !== null) return err(unknown);
311
+ const what = v["what"];
312
+ if (!isWhat(what))
313
+ return err(
314
+ `${at}: "what" must be one of ${KINDS_TEXT}; got ${JSON.stringify(what)}`,
315
+ );
316
+ const observed = parseObserved(v["observed"], at);
317
+ if (!observed.ok) return observed;
318
+ const override = parseOverride(v["override"], at);
319
+ if (!override.ok) return override;
320
+ return observed.value.length === 0 && override.value === null
321
+ ? err(
322
+ `${at}: the "${what}" deadline records nothing — add what a page said ("observed") or an "override"`,
323
+ )
324
+ : ok({ what, observed: observed.value, override: override.value });
325
+ }
326
+
327
+ /** The first kind with two entries, as the refusal naming both; null when each kind has one. */
328
+ function twoEntries(list: readonly Deadline[], at: string): string | null {
329
+ const second = list.findIndex(
330
+ (d, i) => list.findIndex((e) => e.what === d.what) !== i,
331
+ );
332
+ const d = list[second];
333
+ if (d === undefined) return null;
334
+ const first = list.findIndex((e) => e.what === d.what);
335
+ return `${at}: the "${d.what}" deadline has two entries (deadlines[${String(first)}] and deadlines[${String(second)}]) — one entry per deadline: put every reading of it in that entry's "observed" list`;
336
+ }
337
+
338
+ /** A cycle's `deadlines` value → the list, or one line naming the place and the cure. Pure. */
339
+ export function parseDeadlines(
340
+ v: unknown,
341
+ at: string,
342
+ ): Result<readonly Deadline[], string> {
343
+ if (v === undefined) return ok([]);
344
+ if (!Array.isArray(v)) return err(`${at}: "deadlines" must be a list`);
345
+ const list = eachOf(v, `${at}.deadlines`, parseDeadline);
346
+ if (!list.ok) return list;
347
+ const twice = twoEntries(list.value, at);
348
+ return twice === null ? list : err(twice);
349
+ }
350
+
351
+ // ── deriving ───────────────────────────────────────────────────────────────────────────
352
+
353
+ /** The earliest of the readings; the first of equals. */
354
+ const earliest = (readings: readonly Observation[]): Observation | undefined =>
355
+ readings.reduce<Observation | undefined>(
356
+ (best, o) => (best === undefined || o.at < best.at ? o : best),
357
+ undefined,
358
+ );
359
+
360
+ const withoutWhat = ({ at, source, url, read }: Reading): Observation => ({
361
+ at,
362
+ source,
363
+ url,
364
+ read,
365
+ });
366
+
367
+ /** One kind in force from the preset's readings and the paper's entry; null when neither says anything. */
368
+ function oneInForce(
369
+ what: DeadlineWhat,
370
+ own: Deadline | undefined,
371
+ preset: readonly Reading[],
372
+ ): InForce | null {
373
+ const readings = [
374
+ ...preset.filter((r) => r.what === what).map(withoutWhat),
375
+ ...(own?.observed ?? []),
376
+ ];
377
+ const override = own?.override ?? null;
378
+ if (override !== null)
379
+ return {
380
+ what,
381
+ at: override.at,
382
+ by: { kind: "override", override },
383
+ readings,
384
+ };
385
+ const first = earliest(readings);
386
+ return first === undefined
387
+ ? null
388
+ : { what, at: first.at, by: { kind: "reading", reading: first }, readings };
389
+ }
390
+
391
+ /**
392
+ * Every deadline in force for an attempt: the paper's own entries over the venue preset's readings
393
+ * (empty for a venue without a preset). The override, else the earliest reading. Pure.
394
+ */
395
+ export function deadlinesInForce(
396
+ own: readonly Deadline[],
397
+ preset: readonly Reading[],
398
+ ): readonly InForce[] {
399
+ return DEADLINE_WHATS.flatMap((what) => {
400
+ const d = oneInForce(
401
+ what,
402
+ own.find((x) => x.what === what),
403
+ preset,
404
+ );
405
+ return d === null ? [] : [d];
406
+ });
407
+ }
408
+
409
+ /** One instant per kind, the earliest a layer holds for it, in the order of the kinds. */
410
+ type Layer = readonly { readonly what: DeadlineWhat; readonly at: Instant }[];
411
+
412
+ const layerOf = (entries: Layer): Layer =>
413
+ DEADLINE_WHATS.flatMap((what) => {
414
+ const ats = entries.filter((e) => e.what === what).map((e) => e.at);
415
+ const first = ats.toSorted()[0];
416
+ return first === undefined ? [] : [{ what, at: first }];
417
+ });
418
+
419
+ /** The pairs of a layer out of the order registration ≤ submission ≤ resubmission < notification < camera-ready. */
420
+ const inversions = (
421
+ layer: Layer,
422
+ says: (what: DeadlineWhat, at: Instant, later: boolean) => string,
423
+ ): readonly string[] =>
424
+ layer.flatMap((d, i) => {
425
+ const before = layer[i - 1];
426
+ return before !== undefined && before.at > d.at
427
+ ? [
428
+ `${says(before.what, before.at, false)} is after ${says(d.what, d.at, true)}`,
429
+ ]
430
+ : [];
431
+ });
432
+
433
+ const readingsOf = (
434
+ own: readonly Deadline[],
435
+ preset: readonly Reading[],
436
+ source: DeadlineSource,
437
+ ): Layer => [
438
+ ...preset.filter((r) => r.source === source),
439
+ ...own.flatMap((d) =>
440
+ d.observed
441
+ .filter((o) => o.source === source)
442
+ .map((o) => ({ what: d.what, at: o.at })),
443
+ ),
444
+ ];
445
+
446
+ /**
447
+ * The deadlines out of order WITHIN one source — the portal's readings, the call's, the overrides —
448
+ * the shape a date typed wrong or an AoE day miscounted takes. Across sources a disagreement is what
449
+ * the record holds, and the earlier binds; it is not a problem. Pure.
450
+ */
451
+ export function deadlineOrderProblems(
452
+ own: readonly Deadline[],
453
+ preset: readonly Reading[],
454
+ ): readonly string[] {
455
+ const overrides = own.flatMap((d) =>
456
+ d.override === null ? [] : [{ what: d.what, at: d.override.at }],
457
+ );
458
+ return [
459
+ ...inversions(
460
+ layerOf(readingsOf(own, preset, "portal")),
461
+ (w, at, later) => `${later ? "its" : "the portal's"} "${w}" (${at})`,
462
+ ),
463
+ ...inversions(
464
+ layerOf(readingsOf(own, preset, "call")),
465
+ (w, at, later) => `${later ? "its" : "the call's"} "${w}" (${at})`,
466
+ ),
467
+ ...inversions(
468
+ layerOf(overrides),
469
+ (w, at) => `the override of "${w}" (${at})`,
470
+ ),
471
+ ];
472
+ }
@@ -60,6 +60,7 @@ describe("paperlint new — paperlint.json", () => {
60
60
  identity: null,
61
61
  talk: null,
62
62
  submission: null,
63
+ cycles: null,
63
64
  },
64
65
  });
65
66
  });
@@ -234,6 +235,33 @@ describe("paperlint new --venue / --kind", () => {
234
235
  });
235
236
  });
236
237
 
238
+ describe("paperlint new --venue msr", () => {
239
+ it("`new --venue msr` writes MSR's class line, and once the paper declares who wrote it, lint is clean", async () => {
240
+ const r = await newIn(["--venue", "msr", "--kind", "technical"]);
241
+ const tex = readFileSync(join(r.dir, "paper.tex"), "utf8");
242
+ expect(tex).toContain("\\documentclass[10pt,conference]{IEEEtran}\n");
243
+ expect(r.out).not.toMatch(/tex\/template|format\/page-limit|pdf\/profile/);
244
+ // MSR reviews double-anonymously: the one thing the stub lacks is the authors' identity.
245
+ expect(r.out).toMatch(/anonymity\/identity/);
246
+ expect(r.code).toBe(1);
247
+ writeFileSync(
248
+ join(r.dir, "paperlint.json"),
249
+ JSON.stringify({ ...r.settings(), identity: ["Ada Example"] }),
250
+ );
251
+ const out: string[] = [];
252
+ const code = await run(["lint", r.dir], {
253
+ cwd: r.dir,
254
+ log: (s: string) => out.push(s),
255
+ err: () => {},
256
+ });
257
+ // Guards: what remains is the reminder that the PDF is not built yet — a warning, not a finding
258
+ // about the paper.
259
+ expect(out.join("\n")).toMatch(/\(0 errors, 1 warning\)/);
260
+ expect(out.join("\n")).toMatch(/pdf\/measured/);
261
+ expect(code).toBe(0);
262
+ });
263
+ });
264
+
237
265
  describe("paperlint new --venue — a venue it cannot use", () => {
238
266
  it("an unknown venue exits 2, lists the shipped presets, and creates nothing", async () => {
239
267
  const r = await newIn(["--venue", "icse"]);
@@ -102,6 +102,32 @@ describe("lint reads the files paper.tex includes from its body", () => {
102
102
  ]);
103
103
  });
104
104
 
105
+ it("🔴 an included file that is not `.tex` — a `.bbl` — is not handed to ESLint, which parsed it as JavaScript (#153)", async () => {
106
+ const { byFile, err } = await lint(
107
+ project({
108
+ "papers/a/paper.tex": doc(
109
+ "{article}",
110
+ "",
111
+ "Text, as Figure~\\ref{f1} shows.\n\\input{paper.bbl}",
112
+ ),
113
+ // What bibtex writes: a comment first, which ESLint's JavaScript parser stops at.
114
+ "papers/a/paper.bbl":
115
+ "% Generated by IEEEtran.bst\n\\begin{thebibliography}{1}\n" +
116
+ "\\bibitem{a} A. Author, ``A result with p < .05,'' 2024.\n" +
117
+ "\\end{thebibliography}\n",
118
+ }),
119
+ );
120
+ // Guards: the `.bbl` was the one file of the run with a parse error («Unexpected token %»).
121
+ // It is bibtex's output, not prose the author edits: no fragment rule reports in it, and
122
+ // paper.tex — which reads it, spliced, as TeX typesets it — draws no finding from its `.05`.
123
+ expect(byFile).toEqual({
124
+ "papers/a/PIPELINE-STATUS.md": [],
125
+ "papers/a/paper.tex": [],
126
+ });
127
+ // Read, not missing: no «lint did not read» note names it.
128
+ expect(err).not.toMatch(/paper\.bbl/);
129
+ });
130
+
105
131
  it("--fix rewrites the included file, to the paper's majority form", async () => {
106
132
  const root = project({});
107
133
  const before = readFileSync(join(root, "papers/a/paper.tex"), "utf8");
@@ -14,18 +14,35 @@
14
14
  * `paper.tex`, so only the files named here are ever enumerated;
15
15
  * 2. `settings.paperlint.paper` for `paper.tex` and its body files: the main file and the whole set,
16
16
  * for the rules whose verdict is the paper's (eslint-rules/paper-context.ts).
17
+ *
18
+ * ── ONLY `.tex` FILES ARE HANDED TO ESLint (#153) ────────────────────────────────
19
+ * An include may resolve to a file of another extension: `\input{paper.bbl}` in a paper that ships
20
+ * bibtex's output instead of a `.bib`, a plot exported as `.pgf`. Handed to ESLint, such a file got
21
+ * no language — the fragment block claims `.tex` only — and the JavaScript parser stopped at its
22
+ * first `%`. It is not given the LaTeX language either: the fragment rules judge and `--fix` the
23
+ * prose an author writes in that file, and a file of another extension is in practice a tool's
24
+ * output, whose words are someone else's (the titles of cited works) and whose fix the next run of
25
+ * the tool overwrites. TeX still reads it, and so does `readPaper`: the rules over the whole paper
26
+ * see it spliced into `paper.tex`, where TeX typesets it.
17
27
  */
18
- import { join, relative } from "node:path";
28
+ import { extname, join, relative } from "node:path";
19
29
  import { PAPERLINT_SETTINGS } from "#eslint-rules/paper-context";
20
30
  import { callerPath } from "./caller-path.ts";
21
31
  import type { AbsolutePath } from "./domain/paths.ts";
22
32
  import type { ConfigBlock } from "./rules-config.ts";
23
33
  import { bodyFiles, type PaperDeps, type Unread } from "./tex-paper.ts";
24
34
 
35
+ /** The files the fragment block (`buildConfig`) claims: the only body files ESLint is handed. */
36
+ export const FRAGMENT_FILES: readonly string[] = ["**/*.tex"];
37
+
38
+ /** Whether a body file is one the fragment block claims — the extension its glob names. */
39
+ const isFragment = (file: string): boolean => extname(file) === ".tex";
40
+
25
41
  /** One paper's main file and body files, and the includes that resolved nowhere. */
26
42
  export interface PaperBody {
27
43
  readonly dir: string;
28
44
  readonly main: AbsolutePath;
45
+ /** The body files ESLint lints, each as a fragment: the `.tex` ones. */
29
46
  readonly files: readonly AbsolutePath[];
30
47
  readonly missing: readonly Unread[];
31
48
  }
@@ -40,7 +57,8 @@ export function paperBodies(
40
57
  const bytes = deps.files.readBytes(main);
41
58
  if (bytes === null) return [];
42
59
  const body = bodyFiles(main, new TextDecoder().decode(bytes), deps);
43
- return [{ dir, main, files: body.files, missing: body.missing }];
60
+ const files = body.files.filter(isFragment);
61
+ return [{ dir, main, files, missing: body.missing }];
44
62
  });
45
63
  }
46
64
 
@@ -299,7 +299,7 @@ describe("paperlint lint — the paper over its preset, and the project's own pr
299
299
  const r = await lint(root);
300
300
  expect(r.code).toBe(1);
301
301
  expect(r.out).toMatch(
302
- /acm-sigconf, agenticdev, aidc, aisec, ieee-conference, realm/,
302
+ /acm-sigconf, agenticdev, aidc, aisec, ieee-conference, msr, realm/,
303
303
  );
304
304
  });
305
305
  });