paperlint 17.1.0 → 17.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 (66) hide show
  1. package/CLAUDE.md +2 -2
  2. package/README.md +24 -20
  3. package/dist/cli.d.ts +1 -1
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +28 -29
  6. package/dist/cli.js.map +1 -1
  7. package/dist/presets.d.ts.map +1 -1
  8. package/dist/presets.js +6 -1
  9. package/dist/presets.js.map +1 -1
  10. package/dist/register-bands.d.ts +1 -7
  11. package/dist/register-bands.d.ts.map +1 -1
  12. package/dist/register-bands.js +12 -19
  13. package/dist/register-bands.js.map +1 -1
  14. package/dist/rule-sets.d.ts +43 -0
  15. package/dist/rule-sets.d.ts.map +1 -0
  16. package/dist/rule-sets.js +59 -0
  17. package/dist/rule-sets.js.map +1 -0
  18. package/dist/rules-config.d.ts +2 -1
  19. package/dist/rules-config.d.ts.map +1 -1
  20. package/dist/rules-config.js +17 -3
  21. package/dist/rules-config.js.map +1 -1
  22. package/docs/configuration.md +9 -2
  23. package/docs/optional-rules.md +48 -6
  24. package/docs/rules/tex/claim-emphasis.md +1 -1
  25. package/docs/rules/tex/claim-provenance.md +3 -3
  26. package/docs/rules/tex/contrast-frames.md +1 -1
  27. package/docs/rules/tex/max-caption-words.md +1 -1
  28. package/docs/rules/tex/max-paragraph-numbers.md +1 -1
  29. package/docs/rules/tex/max-paragraph-words.md +1 -1
  30. package/docs/rules/tex/max-sentence-words.md +1 -1
  31. package/docs/rules/tex/negated-sentences.md +1 -1
  32. package/docs/rules/tex/register.md +1 -1
  33. package/docs/rules/tex/relation-markers.md +1 -1
  34. package/docs/rules.md +20 -16
  35. package/fixtures/build-e2e/fse/PIPELINE-STATUS.md +3 -0
  36. package/fixtures/build-e2e/fse/expect.json +15 -0
  37. package/fixtures/build-e2e/fse/paper.tex +42 -0
  38. package/fixtures/build-e2e/fse/paperlint.json +1 -0
  39. package/fixtures/build-e2e/fse-over/PIPELINE-STATUS.md +3 -0
  40. package/fixtures/build-e2e/fse-over/expect.json +16 -0
  41. package/fixtures/build-e2e/fse-over/paper.tex +41 -0
  42. package/fixtures/build-e2e/fse-over/paperlint.json +1 -0
  43. package/fixtures/real-papers.test.ts +3 -0
  44. package/package.json +1 -1
  45. package/presets/acm-acmsmall.jsonc +115 -0
  46. package/presets/acm-acmsmall.md +62 -0
  47. package/presets/aidc.jsonc +2 -1
  48. package/presets/aidc.md +4 -3
  49. package/presets/fse.jsonc +93 -0
  50. package/presets/fse.md +143 -0
  51. package/src/cli.harness.mjs +25 -5
  52. package/src/cli.ts +43 -30
  53. package/src/folder-venue-rule.test.ts +11 -0
  54. package/src/lint-fix.test.ts +15 -2
  55. package/src/paper-includes.test.ts +62 -1
  56. package/src/paper-settings-commands.test.ts +1 -1
  57. package/src/preset-card-rule.test.ts +2 -0
  58. package/src/presets.test.ts +52 -1
  59. package/src/presets.ts +8 -1
  60. package/src/register-bands.ts +13 -23
  61. package/src/rule-cases.test.ts +155 -16
  62. package/src/rule-sets.test.ts +150 -0
  63. package/src/rule-sets.ts +63 -0
  64. package/src/rules-config.ts +31 -3
  65. package/src/tex-venue-rules.test.ts +53 -0
  66. package/src/venue-rules.test.ts +132 -2
@@ -139,6 +139,46 @@ describe("shipped presets: paperlint:msr", () => {
139
139
  });
140
140
  });
141
141
 
142
+ describe("shipped presets: paperlint:fse", () => {
143
+ it("paperlint:fse → fse over acm-acmsmall: one column, the family's template, two kinds, both readings of the deadline", () => {
144
+ const r = resolve("paperlint:fse");
145
+ expect(r.ok).toBe(true);
146
+ if (!r.ok) return;
147
+ expect(r.value.chain.map((f) => f.split("/").pop())).toEqual([
148
+ "acm-acmsmall.jsonc",
149
+ "fse.jsonc",
150
+ ]);
151
+ expect(r.value.format.columns).toBe(1);
152
+ expect(r.value.format.pageWidthIn).toBe(6.75);
153
+ expect(r.value.format.pageHeightIn).toBe(10);
154
+ expect(r.value.format.fontsText).toBe("LinLibertine");
155
+ expect(r.value.format.fontsTitle).toBe("LinBiolinum");
156
+ expect([...r.value.format.kinds]).toEqual([
157
+ ["research", { pagesMax: null, bodyPagesMax: 18, refPagesMax: 4 }],
158
+ ["major-revision", { pagesMax: null, bodyPagesMax: 20, refPagesMax: 4 }],
159
+ ]);
160
+ // The call only encourages review, screen and anonymous, so the family's line stands.
161
+ expect(r.value.template).toEqual({
162
+ text: "\\documentclass[acmsmall]{acmart}",
163
+ file: join(VENUES, "acm-acmsmall.jsonc"),
164
+ forbids: [],
165
+ });
166
+ expect("acmart" in r.value.tex.packages).toBe(true);
167
+ expect(r.value.blind).toBe(true);
168
+ expect(r.value.portal).toEqual({
169
+ kind: "hotcrp",
170
+ url: "https://fse2027.hotcrp.com",
171
+ });
172
+ // One submission deadline, read twice: the portal's and the call's extended day, both kept.
173
+ expect(r.value.deadlines.map((d) => [d.what, d.source])).toEqual([
174
+ ["submission", "portal"],
175
+ ["submission", "call"],
176
+ ]);
177
+ expect(r.value.label).toBe("FSE 2027");
178
+ expect(r.value.rules).toEqual({});
179
+ });
180
+ });
181
+
142
182
  describe("shipped presets: a family, and a venue that stands alone", () => {
143
183
  it("a paper may extend a family directly: format and fonts, and no kinds", () => {
144
184
  const r = resolve("paperlint:acm-sigconf");
@@ -176,6 +216,7 @@ const FAMILIES = PARSED.filter((p) =>
176
216
 
177
217
  // What each shipped preset declares itself to be; a new preset adds its row here.
178
218
  const DECLARED = {
219
+ "acm-acmsmall.jsonc": { type: "family" },
179
220
  "acm-sigconf.jsonc": { type: "family" },
180
221
  "agenticdev.jsonc": {
181
222
  type: "venue",
@@ -212,6 +253,11 @@ const DECLARED = {
212
253
  name: "ACM CCS",
213
254
  url: "https://www.sigsac.org/ccs/CCS2026/call-for/call-for-papers.html",
214
255
  },
256
+ "fse.jsonc": {
257
+ type: "venue",
258
+ name: "FSE 2027",
259
+ url: "https://conf.researchr.org/track/fse-2027/fse-2027-papers",
260
+ },
215
261
  "icse.jsonc": {
216
262
  type: "venue",
217
263
  name: "ICSE 2028",
@@ -274,6 +320,7 @@ describe("the naming convention of shipped presets (docs/rules.md)", () => {
274
320
 
275
321
  it("there are families to check (else the checks below see nothing)", () => {
276
322
  expect(families.map((f) => f.name).sort()).toEqual([
323
+ "acm-acmsmall",
277
324
  "acm-sigconf",
278
325
  "ieee-conference",
279
326
  ]);
@@ -496,7 +543,7 @@ describe("what does not resolve, and says why", () => {
496
543
  "a shipped name with a typo",
497
544
  "paperlint:agenticdve",
498
545
  "not-found",
499
- /acm-sigconf, agent, agenticdev, agentverify, aidc, aisec, ase, ccs, icse, ieee-conference, msr, nlbse, realm, sp/,
546
+ /acm-acmsmall, acm-sigconf, agent, agenticdev, agentverify, aidc, aisec, ase, ccs, fse, icse, ieee-conference, msr, nlbse, realm, sp/,
500
547
  ],
501
548
  ["the base TeX set", "paperlint:tex-base", "not-found", /agenticdev/],
502
549
  [
@@ -773,6 +820,7 @@ describe("shippedVenueNames — what each shipped venue is called", () => {
773
820
  const names = shippedVenueNames(deps());
774
821
  // A venue is labelled by its `name`, a family by its file name.
775
822
  expect(names.map((n) => n.label)).toEqual([
823
+ "acm-acmsmall",
776
824
  "acm-sigconf",
777
825
  "AGENT 2027",
778
826
  "AgenticDev",
@@ -781,6 +829,7 @@ describe("shippedVenueNames — what each shipped venue is called", () => {
781
829
  "AISec",
782
830
  "ASE",
783
831
  "ACM CCS",
832
+ "FSE 2027",
784
833
  "ICSE 2028",
785
834
  "ieee-conference",
786
835
  "MSR",
@@ -801,6 +850,7 @@ describe("shippedVenueNames — what each shipped venue is called", () => {
801
850
  expect(
802
851
  shippedVenueNames({ files, venuesDir: VENUES }).map((n) => n.label),
803
852
  ).toEqual([
853
+ "acm-acmsmall",
804
854
  "acm-sigconf",
805
855
  "AGENT 2027",
806
856
  "AgenticDev",
@@ -809,6 +859,7 @@ describe("shippedVenueNames — what each shipped venue is called", () => {
809
859
  "AISec",
810
860
  "ASE",
811
861
  "ACM CCS",
862
+ "FSE 2027",
812
863
  "ICSE 2028",
813
864
  "ieee-conference",
814
865
  "MSR",
package/src/presets.ts CHANGED
@@ -68,6 +68,7 @@ import {
68
68
  } from "./paper-settings.ts";
69
69
  import { CONFIG_FILE } from "#lib/paper-config";
70
70
  import { messageOf } from "./domain/text.ts";
71
+ import { setMembers } from "./rule-sets.ts";
71
72
  import type { RegisterAnchor } from "./domain/register.ts";
72
73
  import type { VenueTalk } from "./domain/talk.ts";
73
74
  import type { VenuePortal } from "./domain/submission.ts";
@@ -508,6 +509,12 @@ export const venueOf = ({
508
509
  export const shippedVenueNames = (deps: PresetDeps): readonly ShippedVenue[] =>
509
510
  resolveShipped(deps).map(venueOf);
510
511
 
512
+ /** For a rule set named where a venue belongs, where the set goes instead; "" otherwise. Pure. */
513
+ const ruleSetHint = (spec: string): string =>
514
+ setMembers(spec) === null
515
+ ? ""
516
+ : `. ${spec} is a rule set, not a venue: turn it on in "rules": { "${spec}": "warn" }`;
517
+
511
518
  /**
512
519
  * One line for a problem, naming what to change. `key` is the setting that named the spec of an
513
520
  * `unsupported` or `not-found` problem. Pure.
@@ -520,7 +527,7 @@ export function presetProblemText(
520
527
  case "unsupported":
521
528
  return `"${key}": "${p.spec}" — a preset is \`paperlint:<name>\` (shipped) or a path starting with ./ or ../ (your own); npm presets: not yet supported. Did you mean "${shippedSpec(p.spec)}"?`;
522
529
  case "not-found":
523
- return `"${key}": "${p.spec}" names no preset (${p.file}); shipped presets (${SHIPPED_PREFIX}<name>): ${p.shipped.join(", ")}`;
530
+ return `"${key}": "${p.spec}" names no preset (${p.file}); shipped presets (${SHIPPED_PREFIX}<name>): ${p.shipped.join(", ")}${ruleSetHint(p.spec)}`;
524
531
  case "cycle":
525
532
  return `the presets extend each other in a cycle: ${p.chain.join(" → ")}`;
526
533
  case "too-deep":
@@ -2,15 +2,18 @@
2
2
  * THE REGISTER RULES THAT MEASURE A BODY AGAINST ITS VENUE'S ACCEPTED PAPERS — each a rate per
3
3
  * 10,000 words, judged against the band the venue preset's anchors set (`src/domain/register.ts`):
4
4
  *
5
- * tex/contrast-frames warn «X, not Y», «rather than», «instead of» … outside the band; above it,
6
- * each frame is reported where it stands
7
- * tex/claim-emphasis warn claims set in bold inside a sentence outside the band; above it, each
8
- * is reported where it stands
9
- * tex/relation-markers warn words naming how a sentence relates to the one before (because,
10
- * therefore, however, for example …) outside the band
11
- * tex/negated-sentences off the share of the body's sentences that hold a negator (not, no,
12
- * never, without …) outside the band — a percent of sentences, not
13
- * a rate per words; off until a project turns it on
5
+ * tex/contrast-frames «X, not Y», «rather than», «instead of» … outside the band; above it, each
6
+ * frame is reported where it stands
7
+ * tex/claim-emphasis claims set in bold inside a sentence outside the band; above it, each is
8
+ * reported where it stands
9
+ * tex/relation-markers words naming how a sentence relates to the one before (because, therefore,
10
+ * however, for example …) outside the band
11
+ * tex/negated-sentences the share of the body's sentences that hold a negator (not, no, never,
12
+ * without …) outside the band — a percent of sentences, not a rate per words
13
+ *
14
+ * All four are off by default, on any preset, the anchored AIDC included: they measure the writing,
15
+ * and the anchors are other papers' writing, not a number the venue states. They are in the opt-in
16
+ * set `paperlint:writing` (src/rule-sets.ts), which turns them on at `warn` (the author, 2026-11-19).
14
17
  *
15
18
  * ── WHY ──────────────────────────────────────────────────────────────────────────
16
19
  * Reviewers called a paper "too informal" and "a blogpost". Its text differed from the accepted
@@ -59,7 +62,7 @@ import type { VenueRuleDeps } from "./venue-rules.ts";
59
62
  /** What the three rules read: the preset store, the LaTeX reader, and the paper's files as the build recorded them. */
60
63
  export interface RegisterBandDeps extends VenueRuleDeps, ProseDeps {}
61
64
 
62
- /** The band rules on by default: each a rate per 10,000 words. */
65
+ /** The band rules that judge a rate per 10,000 words. */
63
66
  export type WordBandRuleName =
64
67
  "contrast-frames" | "claim-emphasis" | "relation-markers";
65
68
 
@@ -339,16 +342,3 @@ export function registerBandRules(
339
342
  "negated-sentences": rule("negated-sentences", deps),
340
343
  };
341
344
  }
342
-
343
- /**
344
- * The level each rule is on at in paperlint's own config, for every `paper.tex`. `tex/negated-sentences`
345
- * is not here: a writing measure added after the default set was fixed to what the venue decides,
346
- * it ships off.
347
- */
348
- export const REGISTER_BAND_RULE_LEVELS: Readonly<
349
- Record<`tex/${WordBandRuleName}`, "warn">
350
- > = {
351
- "tex/contrast-frames": "warn",
352
- "tex/claim-emphasis": "warn",
353
- "tex/relation-markers": "warn",
354
- };
@@ -184,6 +184,17 @@ const DECLARE_SAMPLE_ON: Readonly<Record<string, string>> = {
184
184
  }),
185
185
  };
186
186
 
187
+ /**
188
+ * The writing set (src/rule-sets.ts) is off by default; a paper turns it on with one line in its
189
+ * `paperlint.json`. The cases of its rules that were on by default before it run with it on.
190
+ */
191
+ const WRITING_ON: Readonly<Record<string, string>> = {
192
+ [`${P}/paperlint.json`]: JSON.stringify({
193
+ extends: null,
194
+ rules: { "paperlint:writing": "warn" },
195
+ }),
196
+ };
197
+
187
198
  /** `tex/max-paragraph-words` is off by default; a paper turns it on in its `paperlint.json`. */
188
199
  const MAX_PARAGRAPH_WORDS_ON: Readonly<Record<string, string>> = {
189
200
  [`${P}/paperlint.json`]: JSON.stringify({
@@ -480,6 +491,15 @@ const blind = (body: string, cls = IEEE) =>
480
491
  tex(`\\section{Introduction}\n${body}\n${STATEMENT}`, cls),
481
492
  BLIND_PAPER,
482
493
  );
494
+ /** A BlindConf paper that turns the writing set on: the register bands are in it, off by default. */
495
+ const blindWriting = (body: string) =>
496
+ paper(tex(`\\section{Introduction}\n${body}\n${STATEMENT}`, IEEE), {
497
+ ...BLIND_PAPER,
498
+ [`${P}/paperlint.json`]: JSON.stringify({
499
+ extends: "./blindconf.jsonc",
500
+ rules: { "paperlint:writing": "warn" },
501
+ }),
502
+ });
483
503
  /** A BlindConf paper that turns `tex/negated-sentences` on, which is off by default. */
484
504
  const blindNegation = (body: string) =>
485
505
  paper(tex(`\\section{Introduction}\n${body}\n${STATEMENT}`, IEEE), {
@@ -977,7 +997,7 @@ const CASES: Readonly<Record<string, RuleCases>> = {
977
997
  },
978
998
  "paper/section-word": {
979
999
  reports: {
980
- tree: paper(tex("As in §2.")),
1000
+ tree: paper(tex("As in §2."), WRITING_ON),
981
1001
  file: TEX_FILE,
982
1002
  severity: 1,
983
1003
  line: 3,
@@ -988,25 +1008,26 @@ const CASES: Readonly<Record<string, RuleCases>> = {
988
1008
  "As in Section~2.",
989
1009
  "\\documentclass{article}\n\\usepackage{cleveref}\n\\crefname{section}{§}{§§}",
990
1010
  ),
1011
+ WRITING_ON,
991
1012
  ),
992
1013
  },
993
1014
  "paper/leading-zero": {
994
1015
  reports: {
995
- tree: paper(tex("We found $p < .05$.")),
1016
+ tree: paper(tex("We found $p < .05$."), WRITING_ON),
996
1017
  file: TEX_FILE,
997
1018
  severity: 1,
998
1019
  line: 3,
999
1020
  },
1000
- silent: paper(tex("We found $p < 0.05$.")),
1021
+ silent: paper(tex("We found $p < 0.05$."), WRITING_ON),
1001
1022
  },
1002
1023
  "paper/figure-ref-style": {
1003
1024
  reports: {
1004
- tree: paper(tex("Fig.~\\ref{f1} and Figure~\\ref{f2}.")),
1025
+ tree: paper(tex("Fig.~\\ref{f1} and Figure~\\ref{f2}."), WRITING_ON),
1005
1026
  file: TEX_FILE,
1006
1027
  severity: 1,
1007
1028
  line: 3,
1008
1029
  },
1009
- silent: paper(tex("Figure~\\ref{f1} and Figure~\\ref{f2}.")),
1030
+ silent: paper(tex("Figure~\\ref{f1} and Figure~\\ref{f2}."), WRITING_ON),
1010
1031
  },
1011
1032
  "paper/author-list": {
1012
1033
  reports: {
@@ -1302,7 +1323,7 @@ const CASES: Readonly<Record<string, RuleCases>> = {
1302
1323
  },
1303
1324
  "tex/claim-provenance": {
1304
1325
  reports: {
1305
- tree: paper(tex("Text.\nAgents ignore 42\\% of the rules.")),
1326
+ tree: paper(tex("Text.\nAgents ignore 42\\% of the rules."), WRITING_ON),
1306
1327
  file: TEX_FILE,
1307
1328
  severity: 1,
1308
1329
  line: 4,
@@ -1311,16 +1332,20 @@ const CASES: Readonly<Record<string, RuleCases>> = {
1311
1332
  tex(
1312
1333
  "Text.\nWe measured that agents ignore 42\\% of the rules.\nThey run on Claude 3 and Python 3.12.",
1313
1334
  ),
1335
+ WRITING_ON,
1314
1336
  ),
1315
1337
  },
1316
1338
  "tex/register": {
1317
1339
  reports: {
1318
- tree: paper(tex(`${FORMAL} But it holds. So it goes. And it ends.`)),
1340
+ tree: paper(
1341
+ tex(`${FORMAL} But it holds. So it goes. And it ends.`),
1342
+ WRITING_ON,
1343
+ ),
1319
1344
  file: TEX_FILE,
1320
1345
  severity: 1,
1321
1346
  line: 3,
1322
1347
  },
1323
- silent: paper(tex(FORMAL)),
1348
+ silent: paper(tex(FORMAL), WRITING_ON),
1324
1349
  },
1325
1350
  // The paragraph ceiling is off by default (see "tex/max-paragraph-words is off by default"
1326
1351
  // below): its cases turn it on in the paper's paperlint.json, as study/declare-sample's do.
@@ -1383,31 +1408,39 @@ const CASES: Readonly<Record<string, RuleCases>> = {
1383
1408
  },
1384
1409
  silent: paper(tex(GATE_DEFINED), TERMS_ON),
1385
1410
  },
1386
- // The three register bands judge a body against the anchor of BlindConf's preset; the body opens
1387
- // on line 3, right after the \\section, where the finding about the whole body stands.
1411
+ // The three register bands judge a body against the anchor of BlindConf's preset, with the
1412
+ // writing set on (they are off by default); the body opens on line 3, right after the \\section,
1413
+ // where the finding about the whole body stands.
1388
1414
  "tex/contrast-frames": {
1389
1415
  reports: {
1390
- tree: blind(formalWith(5, "It reads the word, not the operation.")),
1416
+ tree: blindWriting(
1417
+ formalWith(5, "It reads the word, not the operation."),
1418
+ ),
1391
1419
  file: TEX_FILE,
1392
1420
  severity: 1,
1393
1421
  line: 3,
1394
1422
  },
1395
- silent: blind(LINKED),
1423
+ silent: blindWriting(LINKED),
1396
1424
  },
1397
1425
  "tex/claim-emphasis": {
1398
1426
  reports: {
1399
- tree: blind(
1427
+ tree: blindWriting(
1400
1428
  formalWith(6, "We find that \\textbf{the rule counts 46 sentences}."),
1401
1429
  ),
1402
1430
  file: TEX_FILE,
1403
1431
  severity: 1,
1404
1432
  line: 3,
1405
1433
  },
1406
- silent: blind(LINKED),
1434
+ silent: blindWriting(LINKED),
1407
1435
  },
1408
1436
  "tex/relation-markers": {
1409
- reports: { tree: blind(FORMAL), file: TEX_FILE, severity: 1, line: 3 },
1410
- silent: blind(LINKED),
1437
+ reports: {
1438
+ tree: blindWriting(FORMAL),
1439
+ file: TEX_FILE,
1440
+ severity: 1,
1441
+ line: 3,
1442
+ },
1443
+ silent: blindWriting(LINKED),
1411
1444
  },
1412
1445
  // Off by default; on in this paper's paperlint.json. FORMAL holds no negator (0%, below 7.2%);
1413
1446
  // 25 negated sentences of 225 are 11.1%, inside the band.
@@ -1615,6 +1648,112 @@ describe("every registered rule has cases, and every case names a registered rul
1615
1648
  });
1616
1649
  });
1617
1650
 
1651
+ describe("the writing set: off by default, one line turns it on", () => {
1652
+ /** One body with a defect for each rule of the set that was on by default before it. */
1653
+ const DEFECTS = tex(
1654
+ `${FORMAL} But it holds. So it goes. And it ends.\nAs in §2, $p < .05$; Fig.~\\ref{f1} and Figure~\\ref{f2}.\nAgents ignore 42\\% of the rules.`,
1655
+ );
1656
+ const FIVE = [
1657
+ "paper/section-word",
1658
+ "paper/leading-zero",
1659
+ "paper/figure-ref-style",
1660
+ "tex/claim-provenance",
1661
+ "tex/register",
1662
+ ];
1663
+ const fromSet = async (tree: Record<string, string>) =>
1664
+ (await lintTree(tree))
1665
+ .map((m) => m.ruleId ?? "")
1666
+ .filter((id) => FIVE.includes(id));
1667
+
1668
+ it("🔴 a paper with all five defects and no set gets no finding from them", async () => {
1669
+ expect(await fromSet(paper(DEFECTS))).toEqual([]);
1670
+ });
1671
+
1672
+ it("the same paper with the set on in its paperlint.json gets each of them", async () => {
1673
+ expect(new Set(await fromSet(paper(DEFECTS, WRITING_ON)))).toEqual(
1674
+ new Set(FIVE),
1675
+ );
1676
+ });
1677
+
1678
+ it("the set in the root paperlint.json reaches every paper", async () => {
1679
+ expect(
1680
+ new Set(
1681
+ await fromSet({
1682
+ ...paper(DEFECTS),
1683
+ "paperlint.json": JSON.stringify({
1684
+ rules: { "paperlint:writing": "warn" },
1685
+ }),
1686
+ }),
1687
+ ),
1688
+ ).toEqual(new Set(FIVE));
1689
+ });
1690
+
1691
+ it("a paper turns the root's set off for itself", async () => {
1692
+ expect(
1693
+ await fromSet({
1694
+ ...paper(DEFECTS, {
1695
+ [`${P}/paperlint.json`]: JSON.stringify({
1696
+ extends: null,
1697
+ rules: { "paperlint:writing": "off" },
1698
+ }),
1699
+ }),
1700
+ "paperlint.json": JSON.stringify({
1701
+ rules: { "paperlint:writing": "warn" },
1702
+ }),
1703
+ }),
1704
+ ).toEqual([]);
1705
+ });
1706
+ });
1707
+
1708
+ describe("the register bands are in the writing set, on AIDC too", () => {
1709
+ /**
1710
+ * A body against AIDC's real anchors (presets/aidc.jsonc, per 10,000 words): five contrast
1711
+ * frames and six bold claims over about 2,900 words are above their bands (0–10.4, 0–17.8), and
1712
+ * no relation marker is below 25.4.
1713
+ */
1714
+ const BODY = formalWith(
1715
+ 1,
1716
+ `${Array.from({ length: 5 }, () => "It reads the word, not the operation.").join(" ")} ${Array.from({ length: 6 }, () => "We find that \\textbf{the rule counts 46 sentences}.").join(" ")}`,
1717
+ );
1718
+ const BANDS = [
1719
+ "tex/contrast-frames",
1720
+ "tex/claim-emphasis",
1721
+ "tex/relation-markers",
1722
+ ];
1723
+ const onAidc = (
1724
+ rules: Record<string, string> | null,
1725
+ preset = "paperlint:aidc",
1726
+ ) =>
1727
+ paper(tex(`\\section{Introduction}\n${BODY}\n${STATEMENT}`, IEEE), {
1728
+ [`${P}/paperlint.json`]: JSON.stringify({
1729
+ extends: preset,
1730
+ ...(rules ? { rules } : {}),
1731
+ }),
1732
+ });
1733
+ const bands = async (tree: Record<string, string>) =>
1734
+ (await lintTree(tree))
1735
+ .map((m) => m.ruleId ?? "")
1736
+ .filter((id) => BANDS.includes(id));
1737
+
1738
+ it("🔴 an AIDC paper whose preset carries the anchors gets no band finding without the set", async () => {
1739
+ expect(await bands(onAidc(null))).toEqual([]);
1740
+ });
1741
+
1742
+ it("the same paper with the set on gets all three", async () => {
1743
+ expect(
1744
+ new Set(await bands(onAidc({ "paperlint:writing": "warn" }))),
1745
+ ).toEqual(new Set(BANDS));
1746
+ });
1747
+
1748
+ it("with the set on, a preset that records no anchors (ieee-conference) gives them nothing to judge", async () => {
1749
+ expect(
1750
+ await bands(
1751
+ onAidc({ "paperlint:writing": "warn" }, "paperlint:ieee-conference"),
1752
+ ),
1753
+ ).toEqual([]);
1754
+ });
1755
+ });
1756
+
1618
1757
  describe("tex/max-paragraph-words is off by default", () => {
1619
1758
  it("a 300-word paragraph produces nothing under the default config, and fires once the paper turns the rule on", async () => {
1620
1759
  const ids = async (tree: Record<string, string>) =>
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Named rule sets (src/rule-sets.ts): what `paperlint:writing` holds, that it holds only rules off by
3
+ * default, and how the parser of the `rules` key expands it — in place, so a later entry wins. What
4
+ * the set does to a paper through `paperlint lint` is in `rule-cases.test.ts` («the writing set») and
5
+ * `lint-fix.test.ts`.
6
+ */
7
+ import { describe, expect, it } from "vitest";
8
+ import { OPTIONAL_RULES, SHIPPED_RULES } from "./cli.ts";
9
+ import { presetProblemText } from "./presets.ts";
10
+ import { parseRuleBlocks, parseRuleEntries } from "./rules-config.ts";
11
+ import { RULE_SETS, setMembers, WRITING_SET } from "./rule-sets.ts";
12
+
13
+ const parse = (v: unknown) => parseRuleEntries(v, "S", SHIPPED_RULES);
14
+ const atWarn = Object.fromEntries(WRITING_SET.map((id) => [id, "warn"]));
15
+
16
+ describe("paperlint:writing", () => {
17
+ it("holds the writing-preference rules, and only those", () => {
18
+ expect(setMembers("paperlint:writing")).toEqual([
19
+ "paper/section-word",
20
+ "paper/leading-zero",
21
+ "paper/figure-ref-style",
22
+ "tex/claim-provenance",
23
+ "tex/register",
24
+ "tex/contrast-frames",
25
+ "tex/claim-emphasis",
26
+ "tex/relation-markers",
27
+ "tex/negated-sentences",
28
+ "tex/max-paragraph-words",
29
+ "tex/max-paragraph-numbers",
30
+ "tex/max-sentence-words",
31
+ "tex/max-caption-words",
32
+ ]);
33
+ expect([...RULE_SETS.keys()]).toEqual(["paperlint:writing"]);
34
+ });
35
+
36
+ it.each(WRITING_SET)(
37
+ "%s is a shipped rule that is off by default — turning the set off gives back the default set",
38
+ (id) => {
39
+ expect(SHIPPED_RULES.has(id)).toBe(true);
40
+ expect(OPTIONAL_RULES.has(id)).toBe(true);
41
+ },
42
+ );
43
+
44
+ it("a name that is no set has no members", () => {
45
+ expect(setMembers("paperlint:strict")).toBeNull();
46
+ expect(setMembers("constructor")).toBeNull();
47
+ });
48
+ });
49
+
50
+ describe("a set in the `rules` key expands where it is written", () => {
51
+ it("one line turns every member on at the set's severity", () => {
52
+ expect(parse({ "paperlint:writing": "warn" })).toEqual({
53
+ ok: true,
54
+ value: atWarn,
55
+ });
56
+ });
57
+
58
+ it("an entry after the set wins: one member off, another with its options", () => {
59
+ expect(
60
+ parse({
61
+ "paperlint:writing": "warn",
62
+ "tex/register": "off",
63
+ "tex/max-sentence-words": ["error", { max: 40 }],
64
+ }),
65
+ ).toEqual({
66
+ ok: true,
67
+ value: {
68
+ ...atWarn,
69
+ "tex/register": "off",
70
+ "tex/max-sentence-words": ["error", { max: 40 }],
71
+ },
72
+ });
73
+ });
74
+
75
+ it("the set after an entry wins over it, as a later ESLint entry does", () => {
76
+ expect(
77
+ parse({ "tex/register": "off", "paperlint:writing": "error" }),
78
+ ).toEqual({
79
+ ok: true,
80
+ value: Object.fromEntries(WRITING_SET.map((id) => [id, "error"])),
81
+ });
82
+ });
83
+
84
+ it('"off" turns every member off — how a paper undoes the root\'s set', () => {
85
+ expect(parse({ "paperlint:writing": "off" })).toEqual({
86
+ ok: true,
87
+ value: Object.fromEntries(WRITING_SET.map((id) => [id, "off"])),
88
+ });
89
+ });
90
+ });
91
+
92
+ describe("what a set refuses, and where else it is written", () => {
93
+ it("a set takes a severity alone: options would be one member's, so they are refused", () => {
94
+ expect(parse({ "paperlint:writing": ["warn", { max: 40 }] })).toEqual({
95
+ ok: false,
96
+ error:
97
+ 'S["paperlint:writing"]: ["warn",{"max":40}] — a rule set takes a severity alone ("off", "warn" or "error"); give one member its options in its own entry after the set',
98
+ });
99
+ });
100
+
101
+ it("a name that is neither a rule nor a set is refused, and the message names the sets", () => {
102
+ const r = parse({ "paperlint:strict": "warn" });
103
+ expect(r.ok).toBe(false);
104
+ expect(r.ok ? "" : r.error).toMatch(
105
+ /^S: "paperlint:strict" is not a rule paperlint ships — known: .*; rule sets: paperlint:writing$/,
106
+ );
107
+ });
108
+
109
+ it("in a block of the list form too", () => {
110
+ expect(
111
+ parseRuleBlocks(
112
+ [{ files: ["papers/a/**"], rules: { "paperlint:writing": "warn" } }],
113
+ "S",
114
+ SHIPPED_RULES,
115
+ "/consumer",
116
+ ),
117
+ ).toEqual({
118
+ ok: true,
119
+ value: [{ basePath: "/consumer", files: ["papers/a/**"], rules: atWarn }],
120
+ });
121
+ });
122
+ });
123
+
124
+ describe('"extends" naming a set', () => {
125
+ it("says the set goes in `rules`", () => {
126
+ expect(
127
+ presetProblemText({
128
+ kind: "not-found",
129
+ spec: "paperlint:writing",
130
+ file: "/pkg/presets/writing.jsonc",
131
+ shipped: ["aisec"],
132
+ }),
133
+ ).toBe(
134
+ '"extends": "paperlint:writing" names no preset (/pkg/presets/writing.jsonc); shipped presets (paperlint:<name>): aisec. paperlint:writing is a rule set, not a venue: turn it on in "rules": { "paperlint:writing": "warn" }',
135
+ );
136
+ });
137
+
138
+ it("any other unknown name gets the list alone", () => {
139
+ expect(
140
+ presetProblemText({
141
+ kind: "not-found",
142
+ spec: "paperlint:nope",
143
+ file: "/pkg/presets/nope.jsonc",
144
+ shipped: ["aisec"],
145
+ }),
146
+ ).toBe(
147
+ '"extends": "paperlint:nope" names no preset (/pkg/presets/nope.jsonc); shipped presets (paperlint:<name>): aisec',
148
+ );
149
+ });
150
+ });
@@ -0,0 +1,63 @@
1
+ /**
2
+ * NAMED RULE SETS — opt-in rules grouped so an author turns them on in one line (#524).
3
+ *
4
+ * "rules": { "paperlint:writing": "warn" }
5
+ *
6
+ * A set is written where a rule id is written, in the `rules` key of the root or a paper's
7
+ * `paperlint.json` (or in a block of it), and is expanded there, at the boundary
8
+ * (`parseRuleEntries`, src/rules-config.ts), into one entry per member at the set's severity. Nothing
9
+ * after the parser knows a set existed. The members keep the set's place among the entries, so a
10
+ * later entry wins, as in ESLint: `{ "paperlint:writing": "warn", "tex/register": "off" }` is the set
11
+ * without `tex/register`, and `["warn", { … }]` after the set gives one member its options.
12
+ *
13
+ * ── WHY A `rules` ENTRY AND NOT `extends` ─────────────────────────────────────────
14
+ * `extends` names the paper's venue preset: one string (an array is refused: «"extends" must be a
15
+ * non-empty string»), read as the venue by the build, the facts file, the folder-name rule and the
16
+ * cycles, and derived from the current cycle when a paper keeps `cycles`, where writing `extends` is
17
+ * refused. A set beside the venue there would need a second meaning for that key. textlint turns
18
+ * a preset on the same way, as an entry of `rules` (`"preset-example": true`); typescript-eslint
19
+ * keeps its style rules in `stylistic`, apart from `recommended` — as this set is apart from the
20
+ * default set.
21
+ *
22
+ * ── WHAT A SET HOLDS ──────────────────────────────────────────────────────────────
23
+ * Only rules that are off by default (`rule-sets.test.ts` holds it): turning a set off gives back
24
+ * the default set, never less. A rule a venue requires is not here: its preset turns it on with the
25
+ * venue's options and level (`tex/heading-case` on AgenticDev), and a set entry after the preset
26
+ * would lower it to the set's severity. Nor is a rule that holds only for papers of one markup
27
+ * convention: `tex/term-before-definition` and `tex/term-defined-twice` read `\emph` as a definition,
28
+ * and on a paper that uses it for stress, or not at all, they report that they check nothing
29
+ * (measured: one such warning on every paper of `paper-includes.test.ts` with them in the set).
30
+ */
31
+
32
+ /** The prefix a set's name shares with a shipped preset's spec: both are paperlint's own. */
33
+ export const SET_PREFIX = "paperlint:";
34
+
35
+ /**
36
+ * `paperlint:writing` — every rule that flags the WRITING rather than what the venue decides: the
37
+ * typography preferences `--fix` rewrites, register and provenance proxies, length and density
38
+ * caps. Each runs with its own default options.
39
+ */
40
+ export const WRITING_SET: readonly string[] = [
41
+ "paper/section-word",
42
+ "paper/leading-zero",
43
+ "paper/figure-ref-style",
44
+ "tex/claim-provenance",
45
+ "tex/register",
46
+ "tex/contrast-frames",
47
+ "tex/claim-emphasis",
48
+ "tex/relation-markers",
49
+ "tex/negated-sentences",
50
+ "tex/max-paragraph-words",
51
+ "tex/max-paragraph-numbers",
52
+ "tex/max-sentence-words",
53
+ "tex/max-caption-words",
54
+ ];
55
+
56
+ /** Every set, by the name written in `rules`. */
57
+ export const RULE_SETS: ReadonlyMap<string, readonly string[]> = new Map([
58
+ [`${SET_PREFIX}writing`, WRITING_SET],
59
+ ]);
60
+
61
+ /** The members of the set `name`, or null when `name` names no set. */
62
+ export const setMembers = (name: string): readonly string[] | null =>
63
+ RULE_SETS.get(name) ?? null;