paperlint 18.2.1 → 18.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 (71) hide show
  1. package/.github/dependabot.yml +17 -0
  2. package/.github/workflows/ci.yml +30 -5
  3. package/CLAUDE.md +2 -1
  4. package/dist/domain/register.d.ts +1 -1
  5. package/dist/domain/register.d.ts.map +1 -1
  6. package/dist/domain/sentences.d.ts +3 -11
  7. package/dist/domain/sentences.d.ts.map +1 -1
  8. package/dist/domain/sentences.js +53 -8
  9. package/dist/domain/sentences.js.map +1 -1
  10. package/dist/eslint-rules/CLAUDE.md.spec.js +2 -2
  11. package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
  12. package/dist/folder-venue-rule.js +1 -1
  13. package/dist/readability.d.ts +12 -9
  14. package/dist/readability.d.ts.map +1 -1
  15. package/dist/readability.js +3 -3
  16. package/dist/readability.js.map +1 -1
  17. package/docs/design/paper-sources.md +1 -1
  18. package/docs/e2e.md +2 -2
  19. package/docs/optional-rules.md +2 -2
  20. package/docs/rules/pdf/body-size.md +1 -1
  21. package/docs/rules/tex/heading-case.md +2 -2
  22. package/docs/rules/tex/max-paragraph-numbers.md +13 -7
  23. package/docs/rules/tex/max-paragraph-words.md +17 -28
  24. package/docs/rules/tex/max-sentence-words.md +3 -2
  25. package/docs/rules/tex/negated-sentences.md +2 -2
  26. package/docs/rules/tex/register.md +1 -1
  27. package/docs/rules/tex/term-before-definition.md +1 -1
  28. package/docs/rules.md +3 -3
  29. package/docs/venues.md +1 -1
  30. package/docs/website.md +61 -5
  31. package/eslint-rules/CLAUDE.md +3 -3
  32. package/eslint-rules/CLAUDE.md.spec.ts +2 -2
  33. package/eslint.config.mjs +15 -4
  34. package/fixtures/real-papers.test.ts +24 -19
  35. package/package.json +4 -5
  36. package/presets/acm-sigconf.jsonc +1 -1
  37. package/presets/aidc-2026.jsonc +4 -4
  38. package/presets/aidc-2026.md +1 -1
  39. package/presets/ase-2026.md +1 -1
  40. package/presets/ieee-conference.jsonc +1 -1
  41. package/presets/msr-2027.jsonc +1 -1
  42. package/presets/neurips-style.jsonc +2 -2
  43. package/presets/neurips-style.md +1 -1
  44. package/presets/sp-2027.md +1 -1
  45. package/presets/venue-profile.schema.json +1 -1
  46. package/scripts/check.ts +9 -1
  47. package/scripts/coverage-config.test.ts +2 -0
  48. package/scripts/grow-real-papers/archive.test.ts +294 -0
  49. package/scripts/grow-real-papers/archive.ts +287 -0
  50. package/scripts/grow-real-papers/collect.test.ts +329 -0
  51. package/scripts/grow-real-papers/collect.ts +316 -0
  52. package/scripts/grow-real-papers/http.test.ts +95 -0
  53. package/scripts/grow-real-papers/http.ts +76 -0
  54. package/scripts/grow-real-papers/main.test.ts +295 -0
  55. package/scripts/grow-real-papers/main.ts +221 -0
  56. package/scripts/grow-real-papers/paper.test.ts +305 -0
  57. package/scripts/grow-real-papers/paper.ts +241 -0
  58. package/scripts/grow-real-papers/rules.test.ts +222 -0
  59. package/scripts/grow-real-papers/rules.ts +250 -0
  60. package/scripts/grow-real-papers/sources.test.ts +275 -0
  61. package/scripts/grow-real-papers/sources.ts +239 -0
  62. package/scripts/grow-real-papers/testkit.ts +79 -0
  63. package/src/domain/register.ts +1 -1
  64. package/src/domain/sentences.test.ts +128 -0
  65. package/src/domain/sentences.ts +60 -11
  66. package/src/folder-venue-rule.test.ts +1 -1
  67. package/src/folder-venue-rule.ts +1 -1
  68. package/src/readability.test.ts +82 -41
  69. package/src/readability.ts +12 -9
  70. package/src/register-bands.test.ts +4 -4
  71. package/src/rule-cases.test.ts +6 -6
@@ -0,0 +1,222 @@
1
+ /**
2
+ * The four selection rules, each on a planted defect and on a clean case.
3
+ */
4
+ import { describe, expect, test } from "vitest";
5
+ import {
6
+ judgeClass,
7
+ judgeComment,
8
+ judgeLicence,
9
+ judgeListedVenue,
10
+ judgeSize,
11
+ MAX_BYTES,
12
+ preambleOf,
13
+ stripComments,
14
+ } from "./rules.ts";
15
+
16
+ const neurips = {
17
+ venue: "neur\\s?ips|nips",
18
+ series: "NeurIPS",
19
+ year: 2025,
20
+ allowPoster: true,
21
+ };
22
+ const acl = { venue: "acl", series: "ACL", year: 2025 };
23
+ const say = (comment: string, journal_ref = "") => ({ comment, journal_ref });
24
+
25
+ describe("rule 1: the acceptance wording", () => {
26
+ test.each([
27
+ [
28
+ "the edition is not named",
29
+ say("Accepted at NeurIPS 2024"),
30
+ "comment does not state NeurIPS 2025",
31
+ ],
32
+ [
33
+ "a workshop title naming the venue",
34
+ say("Accepted: Workshop on Safe Agents at NeurIPS 2025"),
35
+ 'not accepted wording: reads as a workshop title (": Workshop on Safe Agents at NeurIPS")',
36
+ ],
37
+ [
38
+ "a negative word",
39
+ say("Submitted to NeurIPS 2025"),
40
+ 'not accepted wording: comment says "Submitted"',
41
+ ],
42
+ [
43
+ "an «@ venue», which names a workshop or a track",
44
+ say("Accepted, SafeML @ NeurIPS 2025"),
45
+ 'not accepted wording: comment says "@ NeurIPS"',
46
+ ],
47
+ [
48
+ "no positive word",
49
+ say("NeurIPS 2025, 9 pages"),
50
+ "not accepted wording: no acceptance statement",
51
+ ],
52
+ ])("rejects %s", (_, c, reason) => {
53
+ // Guards: each reason the probe log records, as a whole verdict.
54
+ expect(judgeComment(c, neurips)).toEqual({ ok: false, reason });
55
+ });
56
+
57
+ test("a poster passes where the slot allows posters, and not elsewhere", () => {
58
+ const c = say("Accepted as a poster at NeurIPS 2025");
59
+ // Guards: allowPoster lets a poster through.
60
+ expect(judgeComment(c, neurips)).toEqual({ ok: true, track: null });
61
+ // Guards: without allowPoster the same comment is rejected.
62
+ expect(judgeComment(c, { ...neurips, allowPoster: false })).toEqual({
63
+ ok: false,
64
+ reason: 'not accepted wording: comment says "poster"',
65
+ });
66
+ });
67
+
68
+ test("the journal-ref counts, and Findings is a track of the ACL family only", () => {
69
+ const findings = say("", "Findings of ACL 2025, accepted");
70
+ // Guards: an ACL Findings paper is kept with its track.
71
+ expect(judgeComment(findings, acl)).toEqual({
72
+ ok: true,
73
+ track: "Findings",
74
+ });
75
+ // Guards: "findings" in another series is no track.
76
+ expect(
77
+ judgeComment(say("Accepted at NeurIPS 2025, findings"), neurips),
78
+ ).toEqual({ ok: true, track: null });
79
+ });
80
+
81
+ test("a Semantic Scholar venue string must be the main proceedings", () => {
82
+ // Guards: a workshop venue string is rejected.
83
+ expect(judgeListedVenue("NeurIPS Workshop on X")).toEqual({
84
+ ok: false,
85
+ reason:
86
+ 'S2 venue string is not the main proceedings: "NeurIPS Workshop on X"',
87
+ });
88
+ // Guards: the proceedings pass.
89
+ expect(judgeListedVenue("OSDI")).toEqual({ ok: true, track: null });
90
+ });
91
+ });
92
+
93
+ describe("rule 2: the licence", () => {
94
+ test("only the redistributable licences pass", () => {
95
+ // Guards: arXiv's default licence (no <license>) is rejected.
96
+ expect(judgeLicence(undefined)).toEqual({
97
+ ok: false,
98
+ reason: "licence arXiv default (none)",
99
+ });
100
+ // Guards: a non-commercial licence is rejected, named without its host.
101
+ expect(
102
+ judgeLicence("http://creativecommons.org/licenses/by-nc-nd/4.0/"),
103
+ ).toEqual({ ok: false, reason: "licence licenses/by-nc-nd/4.0/" });
104
+ // Guards: CC BY passes with its name and https URL.
105
+ expect(judgeLicence("http://creativecommons.org/licenses/by/4.0/")).toEqual(
106
+ {
107
+ ok: true,
108
+ key: "http://creativecommons.org/licenses/by/4.0/",
109
+ name: "CC BY 4.0",
110
+ url: "https://creativecommons.org/licenses/by/4.0/",
111
+ },
112
+ );
113
+ });
114
+ });
115
+
116
+ const CLASS_REJECTED: readonly (readonly [string, string, string, string])[] = [
117
+ ["a missing class", "neurips", "", "template: class null, not article"],
118
+ [
119
+ "no class where a class decides",
120
+ "ieee",
121
+ "",
122
+ "template: class null, not IEEEtran",
123
+ ],
124
+ [
125
+ "the class without the style package",
126
+ "neurips",
127
+ "\\documentclass{article}",
128
+ "template: class article without the venue style package (/^(neurips|nips)_20\\d\\d$/)",
129
+ ],
130
+ [
131
+ "the style in review mode",
132
+ "acl",
133
+ "\\documentclass{article}\\usepackage[review]{acl}",
134
+ "template: style acl in review/submission mode [review]",
135
+ ],
136
+ [
137
+ "the class in review mode",
138
+ "acm",
139
+ "\\documentclass[sigconf,review]{acmart}",
140
+ "template: class acmart in review mode [sigconf,review]",
141
+ ],
142
+ [
143
+ "a class neither alternative takes",
144
+ "acm_or_ieee",
145
+ "\\documentclass{article}",
146
+ "template: class article, not acmart",
147
+ ],
148
+ ];
149
+
150
+ const CLASS_KEPT: readonly (readonly [string, string, object])[] = [
151
+ [
152
+ "neurips",
153
+ "\\documentclass{article}\\usepackage[final]{neurips_2025}",
154
+ { ok: true, style: "neurips_2025", styleOpts: "final" },
155
+ ],
156
+ ["ieee", "\\documentclass[conference]{IEEEtran}", { ok: true }],
157
+ ["acm_or_ieee", "\\documentclass[conference]{IEEEtran}", { ok: true }],
158
+ ["acm_or_ieee", "\\documentclass[sigconf]{acmart}", { ok: true }],
159
+ [
160
+ "usenix",
161
+ "\\documentclass{article}\\usepackage{usenix2019_v3}",
162
+ {
163
+ ok: true,
164
+ style: "usenix2019_v3",
165
+ styleOpts: "",
166
+ },
167
+ ],
168
+ ];
169
+
170
+ describe("rule 3: the class and style", () => {
171
+ test("the preamble: class, options and packages, comments ignored", () => {
172
+ const main = [
173
+ "% \\documentclass{acmart}",
174
+ "\\documentclass[sigconf,review]{tmpl/acmart.cls}",
175
+ "\\usepackage[final]{neurips_2025} 100\\% sure",
176
+ "\\RequirePackage{amsmath, amssymb}",
177
+ ].join("\n");
178
+ // Guards: the first uncommented class, its path and extension dropped, every package.
179
+ expect(preambleOf(main)).toEqual({
180
+ cls: "acmart",
181
+ clsOpts: "sigconf,review",
182
+ pkgs: [
183
+ { name: "neurips_2025", opts: "final" },
184
+ { name: "amsmath", opts: "" },
185
+ { name: "amssymb", opts: "" },
186
+ ],
187
+ });
188
+ // Guards: no class at all.
189
+ expect(preambleOf("text")).toEqual({ cls: null, clsOpts: "", pkgs: [] });
190
+ // Guards: an escaped percent stays.
191
+ expect(stripComments("a\\% b % c")).toBe("a\\% b ");
192
+ });
193
+
194
+ test.each(CLASS_REJECTED)("rejects %s", (_, spec, main, reason) => {
195
+ // Guards: each class reason, prefixed as the log records it.
196
+ expect(judgeClass(spec, preambleOf(main))).toEqual({ ok: false, reason });
197
+ });
198
+
199
+ test.each(CLASS_KEPT)("keeps a camera-ready of %s", (spec, main, verdict) => {
200
+ // Guards: the clean case of each kind of spec (style, class, either side of an either).
201
+ expect(judgeClass(spec, preambleOf(main))).toEqual(verdict);
202
+ });
203
+
204
+ test("an unknown classSpec is a broken queries.json", () => {
205
+ // Guards: a typo in queries.json stops the run instead of rejecting every paper.
206
+ expect(() => judgeClass("neurps", preambleOf(""))).toThrow(
207
+ "queries.json: unknown classSpec neurps",
208
+ );
209
+ });
210
+ });
211
+
212
+ describe("rule 4: the size", () => {
213
+ test("at most MAX_BYTES of text", () => {
214
+ // Guards: the limit itself passes.
215
+ expect(judgeSize(MAX_BYTES)).toEqual({ ok: true });
216
+ // Guards: one byte more is rejected, with the count.
217
+ expect(judgeSize(MAX_BYTES + 1)).toEqual({
218
+ ok: false,
219
+ reason: ">300KB of text sources (300001 bytes)",
220
+ });
221
+ });
222
+ });
@@ -0,0 +1,250 @@
1
+ /**
2
+ * The selection rules of the accepted set (fixtures/real-papers/accepted/README.md, «How the papers
3
+ * were chosen»), each a pure decision over text the collector already fetched: rule 1 the
4
+ * acceptance wording, rule 2 the licence, rule 3 the class and style, rule 4 the size. No I/O.
5
+ * `fixtures/real-papers/balance.ts` reads `LICENCES` and `PER_EDITION` from here, so the collector
6
+ * and the balance test cannot disagree on them.
7
+ */
8
+ import { z } from "zod";
9
+
10
+ /** At most this many papers per venue edition (series and year), over every manifest entry. */
11
+ export const PER_EDITION = 5;
12
+
13
+ /** At most this many bytes of text sources per paper. */
14
+ export const MAX_BYTES = 300_000;
15
+
16
+ /** The extensions kept from a source archive; everything else (figures, PDFs, data) is dropped. */
17
+ export const TEXT_EXT: ReadonlySet<string> = new Set([
18
+ "tex",
19
+ "bib",
20
+ "bbl",
21
+ "cls",
22
+ "sty",
23
+ "bst",
24
+ "cfg",
25
+ "def",
26
+ ]);
27
+
28
+ const cc = (path: string, name: string) => ({
29
+ name,
30
+ url: `https://creativecommons.org/${path}`,
31
+ });
32
+
33
+ /** The licences a paper may be redistributed under, keyed as arXiv's metadata spells them. */
34
+ export const LICENCES: ReadonlyMap<
35
+ string,
36
+ Readonly<{ name: string; url: string }>
37
+ > = new Map([
38
+ [
39
+ "http://creativecommons.org/licenses/by/4.0/",
40
+ cc("licenses/by/4.0/", "CC BY 4.0"),
41
+ ],
42
+ [
43
+ "http://creativecommons.org/licenses/by-sa/4.0/",
44
+ cc("licenses/by-sa/4.0/", "CC BY-SA 4.0"),
45
+ ],
46
+ [
47
+ "http://creativecommons.org/publicdomain/zero/1.0/",
48
+ cc("publicdomain/zero/1.0/", "CC0 1.0"),
49
+ ],
50
+ ]);
51
+
52
+ /** One venue edition of `queries.json`. */
53
+ export const SlotSchema = z.object({
54
+ field: z.string(),
55
+ series: z.string(),
56
+ year: z.number(),
57
+ cap: z.number(),
58
+ queries: z.array(z.string()),
59
+ max_results: z.number(),
60
+ venue: z.string(),
61
+ classSpec: z.string(),
62
+ allowPoster: z.boolean().optional(),
63
+ source: z.literal("semantic-scholar").optional(),
64
+ s2Venue: z.string().optional(),
65
+ });
66
+ export type Slot = Readonly<z.infer<typeof SlotSchema>>;
67
+
68
+ /** What a rule says: kept, with what it learned, or rejected, with the reason the log records. */
69
+ export type Verdict<T extends object = object> =
70
+ Readonly<{ ok: true } & T> | Readonly<{ ok: false; reason: string }>;
71
+
72
+ const no = (reason: string) => ({ ok: false, reason }) as const;
73
+
74
+ const POSITIVE =
75
+ /accepted|to appear|will appear|appears? in|published (in|at)|camera[- ]?ready|to be presented|will be presented|spotlight|\boral\b|proceedings of/i;
76
+ const NEGATIVE =
77
+ /submitted|under review|to be accepted|extended version|full version|long version|journal version|technical report|supplementary version|pending|extended abstract|late[- ]breaking|doctoral|student research|demo(nstration)? (track|paper)|tutorial|companion|workshop|\bSRW\b|demonstrations?|\bdemo\b|\bposter/gi;
78
+ const FINDINGS_SERIES = new Set(["ACL", "EMNLP", "NAACL", "EACL"]);
79
+
80
+ /** The first negative word of a comment (a poster is not one where the slot allows posters), or an «@ venue». */
81
+ const negativeWord = (
82
+ text: string,
83
+ slot: Pick<Slot, "venue" | "allowPoster">,
84
+ ): string | undefined =>
85
+ [...text.matchAll(NEGATIVE)]
86
+ .map((m) => m[0])
87
+ .find((n) => !(/^poster/i.test(n) && slot.allowPoster === true)) ??
88
+ new RegExp(`@\\s*(?:${slot.venue})`, "i").exec(text)?.[0];
89
+
90
+ /**
91
+ * Rule 1 on an arXiv comment and journal-ref: the slot's venue and year stand together, no
92
+ * negative word (a poster passes where the slot allows posters), no workshop title naming the
93
+ * venue, and a positive acceptance word. `track` is "Findings" for an ACL-family Findings paper.
94
+ */
95
+ export function judgeComment(
96
+ c: Readonly<{ comment: string; journal_ref: string }>,
97
+ slot: Pick<Slot, "venue" | "series" | "year" | "allowPoster">,
98
+ ): Verdict<{ track: string | null }> {
99
+ const text = `${c.comment} | ${c.journal_ref}`;
100
+ const yy = String(slot.year).slice(2);
101
+ const near = new RegExp(
102
+ `(?:${slot.venue})[^0-9]{0,14}(?:20)?${yy}(?![0-9])`,
103
+ "i",
104
+ );
105
+ if (!near.test(text))
106
+ return no(`comment does not state ${slot.series} ${String(slot.year)}`);
107
+ const workshop = new RegExp(
108
+ `[:–-]\\s*[^.]{5,}\\bat\\s+(?:${slot.venue})|proceedings of (?:the )?(?![^.]*(?:conference|symposium|meeting|annual))[^.]{8,}\\bat\\s*(?:${slot.venue})`,
109
+ "i",
110
+ ).exec(text);
111
+ if (workshop !== null)
112
+ return no(
113
+ `not accepted wording: reads as a workshop title ("${workshop[0].slice(0, 60)}")`,
114
+ );
115
+ const said = negativeWord(text, slot);
116
+ if (said !== undefined)
117
+ return no(`not accepted wording: comment says "${said}"`);
118
+ if (!POSITIVE.test(text))
119
+ return no("not accepted wording: no acceptance statement");
120
+ const findings = /findings/i.test(text) && FINDINGS_SERIES.has(slot.series);
121
+ return { ok: true, track: findings ? "Findings" : null };
122
+ }
123
+
124
+ /** Rule 1 on a Semantic Scholar listing: the venue string names the main proceedings. */
125
+ export const judgeListedVenue = (venue: string): Verdict<{ track: null }> =>
126
+ /workshop|companion|poster|demo|tutorial|doctoral/i.test(venue)
127
+ ? no(`S2 venue string is not the main proceedings: "${venue}"`)
128
+ : { ok: true, track: null };
129
+
130
+ /** Rule 2: the `<license>` of arXiv's OAI record, exactly one of `LICENCES`. */
131
+ export function judgeLicence(
132
+ url: string | undefined,
133
+ ): Verdict<{ key: string; name: string; url: string }> {
134
+ const lic = url === undefined ? undefined : LICENCES.get(url);
135
+ if (url !== undefined && lic !== undefined)
136
+ return { ok: true, key: url, ...lic };
137
+ return no(
138
+ `licence ${url === undefined ? "arXiv default (none)" : url.replace(/^https?:\/\/(creativecommons|arxiv)\.org\//, "")}`,
139
+ );
140
+ }
141
+
142
+ /** A LaTeX source with its `%` comments removed (an escaped `\%` stays). */
143
+ export const stripComments = (t: string): string =>
144
+ t.replace(/(^|[^\\])%.*$/gm, "$1");
145
+
146
+ /** The first `\documentclass` of a main file, its options, and every package it loads. */
147
+ export type Preamble = Readonly<{
148
+ cls: string | null;
149
+ clsOpts: string;
150
+ pkgs: readonly Readonly<{ name: string; opts: string }>[];
151
+ }>;
152
+
153
+ export function preambleOf(main: string): Preamble {
154
+ const t = stripComments(main);
155
+ const dc = /\\documentclass\s*(?:\[([^\]]*)\])?\s*\{([^}]*)\}/.exec(t);
156
+ const pkgs = [
157
+ ...t.matchAll(
158
+ /\\(?:usepackage|RequirePackage)\s*(?:\[([^\]]*)\])?\s*\{([^}]*)\}/g,
159
+ ),
160
+ ].flatMap((m) =>
161
+ String(m[2])
162
+ .split(",")
163
+ .map((n) => ({ name: n.trim(), opts: m[1] ?? "" })),
164
+ );
165
+ const cls =
166
+ dc === null
167
+ ? null
168
+ : String(dc[2])
169
+ .trim()
170
+ .replace(/^.*\//, "")
171
+ .replace(/\.cls$/, "");
172
+ return { cls, clsOpts: dc?.[1] ?? "", pkgs };
173
+ }
174
+
175
+ type ClassVerdict = Verdict<{ style?: string; styleOpts?: string }>;
176
+ type ClassSpec = (p: Preamble) => ClassVerdict;
177
+
178
+ const withStyle =
179
+ (classes: readonly string[], style: RegExp, reviewOpts?: RegExp): ClassSpec =>
180
+ (p) => {
181
+ if (!classes.includes(p.cls ?? ""))
182
+ return no(`class ${String(p.cls)}, not ${classes.join("/")}`);
183
+ const hit = p.pkgs.find((x) => style.test(x.name));
184
+ if (hit === undefined)
185
+ return no(
186
+ `class ${String(p.cls)} without the venue style package (${String(style)})`,
187
+ );
188
+ if (reviewOpts?.test(hit.opts) === true)
189
+ return no(`style ${hit.name} in review/submission mode [${hit.opts}]`);
190
+ return { ok: true, style: hit.name, styleOpts: hit.opts };
191
+ };
192
+
193
+ const ofClass =
194
+ (classes: readonly string[], reviewOpts?: RegExp): ClassSpec =>
195
+ (p) => {
196
+ if (!classes.includes(p.cls ?? ""))
197
+ return no(`class ${String(p.cls)}, not ${classes.join("/")}`);
198
+ if (reviewOpts?.test(p.clsOpts) === true)
199
+ return no(`class ${String(p.cls)} in review mode [${p.clsOpts}]`);
200
+ return { ok: true };
201
+ };
202
+
203
+ /** The first spec that keeps the paper, or the first one's reason. */
204
+ const either =
205
+ (first: ClassSpec, second: ClassSpec): ClassSpec =>
206
+ (p) => {
207
+ const a = first(p);
208
+ const b = second(p);
209
+ return a.ok ? a : b.ok ? b : a;
210
+ };
211
+
212
+ /** Rule 3, per `classSpec` of `queries.json`: the class, and for ML/NLP/AI the style package. */
213
+ export const CLASS_SPECS: Readonly<Record<string, ClassSpec>> = {
214
+ neurips: withStyle(["article"], /^(neurips|nips)_20\d\d$/),
215
+ icml: withStyle(["article"], /^icml20\d\d$/),
216
+ iclr: withStyle(["article"], /^iclr20\d\d_conference$/),
217
+ acl: withStyle(
218
+ ["article"],
219
+ /^(acl|acl_natbib|emnlp(_?20\d\d)?|naacl(_?20\d\d)?|eacl(_?20\d\d)?|acl20\d\d)$/,
220
+ /\breview\b/,
221
+ ),
222
+ aaai: withStyle(["article"], /^aaai\d{2,4}$/, /submission/),
223
+ ijcai: withStyle(["article"], /^ijcai\d\d$/, /review|submission/),
224
+ usenix: either(withStyle(["article"], /^usenix/), ofClass(["usenix"])),
225
+ ieee: ofClass(["IEEEtran"]),
226
+ ndss: ofClass(["IEEEtran"]),
227
+ icra: ofClass(["IEEEtran", "ieeeconf"]),
228
+ acm: ofClass(["acmart"], /\breview\b/),
229
+ acm_or_ieee: either(ofClass(["acmart"], /\breview\b/), ofClass(["IEEEtran"])),
230
+ vldb: either(
231
+ withStyle(["article", "acmart"], /^vldb/),
232
+ ofClass(["acmart"], /\breview\b/),
233
+ ),
234
+ cvpr: withStyle(["article"], /^(cvpr|iccv|eccv)(_?20\d\d)?$/, /review/),
235
+ };
236
+
237
+ /** Rule 3 for one slot; a `classSpec` this file does not know is a broken `queries.json`. */
238
+ export function judgeClass(spec: string, p: Preamble): ClassVerdict {
239
+ const check = CLASS_SPECS[spec];
240
+ if (check === undefined)
241
+ throw new Error(`queries.json: unknown classSpec ${spec}`);
242
+ const v = check(p);
243
+ return v.ok ? v : no(`template: ${v.reason}`);
244
+ }
245
+
246
+ /** Rule 4: the text sources kept, summed. */
247
+ export const judgeSize = (bytes: number): Verdict =>
248
+ bytes > MAX_BYTES
249
+ ? no(`>300KB of text sources (${String(bytes)} bytes)`)
250
+ : { ok: true };