paperlint 20.6.1 → 20.7.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 (70) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/default-levels.d.ts +5 -0
  3. package/dist/default-levels.d.ts.map +1 -0
  4. package/dist/default-levels.js +36 -0
  5. package/dist/default-levels.js.map +1 -0
  6. package/dist/domain/preset-submission-fields.d.ts +15 -0
  7. package/dist/domain/preset-submission-fields.d.ts.map +1 -0
  8. package/dist/domain/preset-submission-fields.js +25 -0
  9. package/dist/domain/preset-submission-fields.js.map +1 -0
  10. package/dist/domain/venue-scope.d.ts +29 -0
  11. package/dist/domain/venue-scope.d.ts.map +1 -0
  12. package/dist/domain/venue-scope.js +18 -0
  13. package/dist/domain/venue-scope.js.map +1 -0
  14. package/dist/folder-venue-rule.d.ts +1 -1
  15. package/dist/folder-venue-rule.d.ts.map +1 -1
  16. package/dist/folder-venue-rule.js.map +1 -1
  17. package/dist/preset-merge.d.ts +34 -0
  18. package/dist/preset-merge.d.ts.map +1 -0
  19. package/dist/preset-merge.js +89 -0
  20. package/dist/preset-merge.js.map +1 -0
  21. package/dist/presets.d.ts +3 -2
  22. package/dist/presets.d.ts.map +1 -1
  23. package/dist/presets.js +3 -84
  24. package/dist/presets.js.map +1 -1
  25. package/dist/tex-requirements.d.ts +4 -1
  26. package/dist/tex-requirements.d.ts.map +1 -1
  27. package/dist/tex-requirements.js +3 -20
  28. package/dist/tex-requirements.js.map +1 -1
  29. package/dist/tex-venue-rules.d.ts +4 -24
  30. package/dist/tex-venue-rules.d.ts.map +1 -1
  31. package/dist/tex-venue-rules.js +6 -84
  32. package/dist/tex-venue-rules.js.map +1 -1
  33. package/dist/venue-leftover.d.ts +50 -0
  34. package/dist/venue-leftover.d.ts.map +1 -0
  35. package/dist/venue-leftover.js +129 -0
  36. package/dist/venue-leftover.js.map +1 -0
  37. package/docs/rules/tex/venue-leftover.md +34 -3
  38. package/docs/rules.md +1 -1
  39. package/docs/venues.md +6 -4
  40. package/package.json +2 -1
  41. package/presets/acl-latex.md +1 -1
  42. package/presets/langcode-2027.jsonc +106 -0
  43. package/presets/langcode-2027.md +79 -0
  44. package/presets/naacl-2027.jsonc +19 -0
  45. package/presets/naacl-2027.md +42 -0
  46. package/presets/venue-profile.schema.json +22 -1
  47. package/scripts/eslint-file-length.mjs +5 -5
  48. package/scripts/release-config.test.ts +114 -0
  49. package/scripts/release-type.test.ts +86 -0
  50. package/scripts/release-type.ts +76 -0
  51. package/scripts/semantic-release-plugins.d.ts +20 -1
  52. package/src/default-levels.test.ts +43 -0
  53. package/src/default-levels.ts +53 -0
  54. package/src/domain/preset-submission-fields.ts +49 -0
  55. package/src/domain/venue-scope.test.ts +33 -0
  56. package/src/domain/venue-scope.ts +39 -0
  57. package/src/folder-venue-rule.ts +2 -1
  58. package/src/paper-settings-commands.test.ts +1 -1
  59. package/src/preset-card-rule.test.ts +2 -0
  60. package/src/preset-merge.ts +141 -0
  61. package/src/presets-scope.test.ts +177 -0
  62. package/src/presets.test.ts +17 -56
  63. package/src/presets.ts +5 -130
  64. package/src/rule-cases.test.ts +10 -3
  65. package/src/tex-requirements.ts +14 -45
  66. package/src/tex-venue-rules.test.ts +66 -154
  67. package/src/tex-venue-rules.ts +25 -146
  68. package/src/venue-leftover.test.ts +112 -0
  69. package/src/venue-leftover.ts +207 -0
  70. package/src/venue-rules.test.ts +2 -2
@@ -0,0 +1,86 @@
1
+ /**
2
+ * The release type the default rule set asks for (`scripts/release-type.ts`), which `.releaserc.json`
3
+ * runs through `@semantic-release/exec` beside the commit analyzer: semantic-release takes the
4
+ * higher of the two, so a pull request titled `feat:` or `chore:` that makes a default rule fail a
5
+ * build still releases a major version.
6
+ */
7
+ import { execFileSync } from "node:child_process";
8
+ import { mkdtempSync, realpathSync, writeFileSync } from "node:fs";
9
+ import { tmpdir } from "node:os";
10
+ import { join } from "node:path";
11
+ import { describe, expect, it } from "vitest";
12
+ import { breakingRules, breakingSince } from "./release-type.ts";
13
+
14
+ describe("breakingRules", () => {
15
+ it("names a rule that joins the set at error, and one raised from warn to error", () => {
16
+ // Guards: both ways a default rule starts failing a build that passed.
17
+ expect(
18
+ breakingRules(
19
+ { "a/kept": "error", "a/raised": "warn" },
20
+ { "a/kept": "error", "a/raised": "error", "a/new": "error" },
21
+ ),
22
+ ).toEqual(["a/new", "a/raised"]);
23
+ });
24
+
25
+ it("names nothing for a rule that joins at warn, is lowered, or leaves the set", () => {
26
+ // Guards: a warning never fails a build (`--max-warnings` defaults to -1), so none of these
27
+ // breaks a consumer.
28
+ expect(
29
+ breakingRules(
30
+ { "a/lowered": "error", "a/gone": "error" },
31
+ { "a/lowered": "warn", "a/new": "warn" },
32
+ ),
33
+ ).toEqual([]);
34
+ });
35
+ });
36
+
37
+ /** A git repository whose tag `v1.0.0` holds `before` as the snapshot, or no snapshot at all. */
38
+ function repoWith(before: string | undefined): string {
39
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), "release-type-")));
40
+ const git = (...args: string[]) =>
41
+ execFileSync("git", args, { cwd: dir, stdio: "pipe" });
42
+ git("init", "-q");
43
+ writeFileSync(
44
+ join(dir, before === undefined ? "README.md" : "default-rules.json"),
45
+ before ?? "no snapshot yet\n",
46
+ );
47
+ git("add", ".");
48
+ git(
49
+ "-c",
50
+ "user.name=t",
51
+ "-c",
52
+ "user.email=t@example.com",
53
+ "commit",
54
+ "-qm",
55
+ "init",
56
+ );
57
+ git("tag", "v1.0.0");
58
+ return dir;
59
+ }
60
+
61
+ describe("breakingSince", () => {
62
+ const now = { "a/x": "error" } as const;
63
+
64
+ it("names the rule the tagged snapshot had at warn", () => {
65
+ const repo = repoWith(JSON.stringify({ "a/x": "warn" }));
66
+ expect(breakingSince(repo, "v1.0.0", now)).toEqual(["a/x"]);
67
+ });
68
+
69
+ it("names nothing when the set did not break", () => {
70
+ const repo = repoWith(JSON.stringify({ "a/x": "error" }));
71
+ expect(breakingSince(repo, "v1.0.0", now)).toEqual([]);
72
+ });
73
+
74
+ it("names nothing for a first release, or a tag from before the snapshot existed", () => {
75
+ // Guards: `${lastRelease.gitTag}` renders empty on a first release, and every tag before this
76
+ // file has no snapshot; neither may stop the release.
77
+ expect(breakingSince(repoWith(undefined), "", now)).toEqual([]);
78
+ expect(breakingSince(repoWith(undefined), "v1.0.0", now)).toEqual([]);
79
+ });
80
+
81
+ it("refuses a tagged snapshot that is not a rule set", () => {
82
+ // Guards: a corrupt snapshot fails the release loudly instead of reading as "nothing broke".
83
+ const repo = repoWith(JSON.stringify({ "a/x": "loud" }));
84
+ expect(() => breakingSince(repo, "v1.0.0", now)).toThrow();
85
+ });
86
+ });
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Prints `major` when the default rule set breaks a build that passed at the last release, and
3
+ * nothing otherwise. `.releaserc.json` runs it through `@semantic-release/exec` (`analyzeCommitsCmd`),
4
+ * whose contract is exactly that: a release type on stdout, or no output for "no release from me".
5
+ * semantic-release keeps the highest type any analyzer returns, so the commit analyzer still decides
6
+ * every other release.
7
+ *
8
+ * Breaking means a rule that a project with no configuration now gets at `error` and did not before:
9
+ * one that joins the set at `error`, or one raised from `warn`. A warning never fails a build
10
+ * (`--max-warnings` defaults to -1), so a rule that joins at `warn`, is lowered or leaves is not.
11
+ *
12
+ * The set at each point is `default-rules.json`, which `src/default-levels.test.ts` keeps equal to
13
+ * the real config on every CI run. Usage: `node scripts/release-type.ts <last release tag>`.
14
+ */
15
+ import { execFileSync } from "node:child_process";
16
+ import { readFileSync } from "node:fs";
17
+ import { dirname, join } from "node:path";
18
+ import { fileURLToPath } from "node:url";
19
+ import { z } from "zod";
20
+
21
+ const SNAPSHOT = "default-rules.json";
22
+
23
+ const RuleSet = z.record(z.string(), z.enum(["warn", "error"]));
24
+ type RuleSet = z.infer<typeof RuleSet>;
25
+
26
+ /** The rules at `error` in `after` that were not at `error` in `before`, sorted. */
27
+ export const breakingRules = (
28
+ before: Readonly<RuleSet>,
29
+ after: Readonly<RuleSet>,
30
+ ): readonly string[] =>
31
+ Object.keys(after)
32
+ .filter((id) => after[id] === "error" && before[id] !== "error")
33
+ .sort();
34
+
35
+ /** The snapshot as it was at `tag` in `repo`, or none when the tag predates it. */
36
+ function snapshotAt(repo: string, tag: string): RuleSet | undefined {
37
+ const ls = execFileSync("git", ["ls-tree", "--name-only", tag, SNAPSHOT], {
38
+ cwd: repo,
39
+ encoding: "utf8",
40
+ });
41
+ if (ls.trim() === "") return undefined;
42
+ return RuleSet.parse(
43
+ JSON.parse(
44
+ execFileSync("git", ["show", `${tag}:${SNAPSHOT}`], {
45
+ cwd: repo,
46
+ encoding: "utf8",
47
+ }),
48
+ ),
49
+ );
50
+ }
51
+
52
+ /** The rules that break since `tag` in `repo`; none for no tag, or a tag from before the snapshot. */
53
+ export function breakingSince(
54
+ repo: string,
55
+ tag: string,
56
+ now: Readonly<RuleSet>,
57
+ ): readonly string[] {
58
+ const before = tag === "" ? undefined : snapshotAt(repo, tag);
59
+ return before === undefined ? [] : breakingRules(before, now);
60
+ }
61
+
62
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
63
+ const repo = dirname(dirname(fileURLToPath(import.meta.url)));
64
+ const now = RuleSet.parse(
65
+ JSON.parse(readFileSync(join(repo, SNAPSHOT), "utf8")),
66
+ );
67
+ const tag = process.argv[2] ?? "";
68
+ const broken = breakingSince(repo, tag, now);
69
+ if (broken.length > 0) {
70
+ // stderr reaches the release log; stdout carries the release type alone.
71
+ process.stderr.write(
72
+ `now at error by default since ${tag}: ${broken.join(", ")}\n`,
73
+ );
74
+ process.stdout.write("major");
75
+ }
76
+ }
@@ -1,4 +1,4 @@
1
- // The two semantic-release plugins ship no types. Only what scripts/release-config.test.ts calls
1
+ // The three semantic-release plugins ship no types. Only what scripts/release-config.test.ts calls
2
2
  // is declared: the plugin step functions, taking the plugin's options and semantic-release's
3
3
  // context, as their READMEs document them.
4
4
  declare module "@semantic-release/commit-analyzer" {
@@ -14,3 +14,22 @@ declare module "@semantic-release/release-notes-generator" {
14
14
  context: Record<string, unknown>,
15
15
  ): Promise<string>;
16
16
  }
17
+
18
+ declare module "@semantic-release/exec" {
19
+ export function analyzeCommits(
20
+ pluginConfig: Record<string, unknown>,
21
+ context: Record<string, unknown>,
22
+ ): Promise<string | undefined>;
23
+ }
24
+
25
+ // semantic-release's own step definitions: how it merges what several analyzers return.
26
+ declare module "semantic-release/lib/definitions/plugins.js" {
27
+ const definitions: {
28
+ readonly analyzeCommits: {
29
+ readonly postprocess: (
30
+ results: readonly (string | undefined | null)[],
31
+ ) => string | undefined;
32
+ };
33
+ };
34
+ export default definitions;
35
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The default rule set, kept in `default-rules.json` at the repository root. The release compares the
3
+ * file at the last release tag with HEAD (`scripts/release-type.ts`), so a change here that the file
4
+ * does not show would release without its version bump. After an intended change:
5
+ * `npx vitest run src/default-levels.test.ts -u`, and commit the file.
6
+ */
7
+ import { describe, expect, it } from "vitest";
8
+ import { buildConfig } from "./cli.ts";
9
+ import { defaultLevels } from "./default-levels.ts";
10
+
11
+ describe("defaultLevels", () => {
12
+ it("keeps each rule's highest level, in every severity form, and drops what is off", () => {
13
+ // Guards: a rule at warn in one block and error in another is an error rule.
14
+ expect(
15
+ defaultLevels([
16
+ { rules: { "a/x": "warn", "a/off": "off", "b/y": 1 } },
17
+ { rules: { "a/x": ["error", { n: 1 }], "a/off": 0, "c/z": 2 } },
18
+ ]),
19
+ ).toEqual({ "a/x": "error", "b/y": "warn", "c/z": "error" });
20
+ });
21
+
22
+ it("refuses a value that is no severity", () => {
23
+ // Guards: ESLint refuses it too; read as "off", it would drop a rule from the snapshot unseen.
24
+ expect(() => defaultLevels([{ rules: { "a/x": "loud" } }])).toThrow(
25
+ "not an ESLint severity: loud",
26
+ );
27
+ });
28
+
29
+ it("an empty config has no default rules", () => {
30
+ expect(defaultLevels([{}, { rules: {} }])).toEqual({});
31
+ });
32
+ });
33
+
34
+ describe("default-rules.json", () => {
35
+ it("is the default rule set of a project with no configuration", async () => {
36
+ const levels = defaultLevels(buildConfig({}, { sentinel: "tex language" }));
37
+ // Guards: a broken read of the config would snapshot nothing and pass.
38
+ expect(Object.keys(levels).length).toBeGreaterThan(30);
39
+ await expect(`${JSON.stringify(levels, null, 2)}\n`).toMatchFileSnapshot(
40
+ "../default-rules.json",
41
+ );
42
+ });
43
+ });
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The default rule set as a record: each rule a project gets with no configuration, at the highest
3
+ * level any of paperlint's own config blocks gives it. `default-levels.test.ts` keeps it in
4
+ * `default-rules.json`, and the release reads that file (`scripts/release-type.ts`): a rule that
5
+ * joins the set at `error`, or rises to `error`, makes the release a major one.
6
+ */
7
+ import { pipe, flatMap, groupBy, mapValues, firstBy, entries } from "remeda";
8
+ import type { ConfigBlock } from "./rules-config.ts";
9
+
10
+ export type Level = "warn" | "error";
11
+
12
+ const LEVEL_OF: Readonly<Record<string, Level | "off">> = {
13
+ off: "off",
14
+ warn: "warn",
15
+ error: "error",
16
+ "0": "off",
17
+ "1": "warn",
18
+ "2": "error",
19
+ };
20
+
21
+ const RANK: Readonly<Record<Level | "off", number>> = {
22
+ off: 0,
23
+ warn: 1,
24
+ error: 2,
25
+ };
26
+
27
+ /** A rule entry's level: `"error"`, `2` or `["error", options]` alike; any other value is refused. */
28
+ const levelOf = (entry: unknown): Level | "off" => {
29
+ const severity = String(Array.isArray(entry) ? entry[0] : entry);
30
+ const level = LEVEL_OF[severity];
31
+ if (level === undefined)
32
+ throw new Error(`not an ESLint severity: ${severity}`);
33
+ return level;
34
+ };
35
+
36
+ /** Every rule the blocks turn on, by id, at its highest level; ids in order. */
37
+ export const defaultLevels = (
38
+ blocks: readonly ConfigBlock[],
39
+ ): Readonly<Record<string, Level>> => {
40
+ const highest = pipe(
41
+ blocks,
42
+ flatMap((b) =>
43
+ entries(b.rules ?? {}).map(([id, e]) => ({ id, level: levelOf(e) })),
44
+ ),
45
+ groupBy((r) => r.id),
46
+ mapValues((rs) => firstBy(rs, [(r) => RANK[r.level], "desc"]).level),
47
+ );
48
+ return Object.fromEntries(
49
+ Object.entries(highest)
50
+ .filter((pair): pair is [string, Level] => pair[1] !== "off")
51
+ .sort(([a], [b]) => a.localeCompare(b)),
52
+ );
53
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * A preset's `submission_fields` block, after the schema accepted it, as the typed preset holds it
3
+ * (`src/tex-requirements.ts` parses the rest of the file).
4
+ */
5
+ import {
6
+ declareField,
7
+ RESERVED_FIELD_KEYS,
8
+ reservedKey,
9
+ type FieldDeclaration,
10
+ type FieldJson,
11
+ type VenueFields,
12
+ } from "./submission-fields.ts";
13
+
14
+ /** A preset's `submission_fields` after the schema accepted it. */
15
+ export interface SubmissionFieldsJson {
16
+ readonly source: VenueFields["source"];
17
+ readonly url: string;
18
+ readonly read: string;
19
+ readonly fields: Readonly<Record<string, FieldJson>>;
20
+ }
21
+
22
+ /** A preset's `submission_fields`, or null when it records none; a reserved field name, or a field that contradicts its kind, is refused. */
23
+ export function submissionFieldsOf(
24
+ j: SubmissionFieldsJson | undefined,
25
+ file: string,
26
+ ): VenueFields | null {
27
+ if (j === undefined) return null;
28
+ const reserved = reservedKey(Object.keys(j.fields));
29
+ if (reserved !== null)
30
+ throw new Error(
31
+ `${file}: "submission_fields" names "${reserved}", which paperlint sends itself (${RESERVED_FIELD_KEYS.join(", ")}) — a field of that name would overwrite it`,
32
+ );
33
+ const declared = Object.entries(j.fields).map(
34
+ ([key, f]) => [key, declareField(f)] as const,
35
+ );
36
+ const fields: readonly (readonly [string, FieldDeclaration])[] =
37
+ declared.flatMap(([key, d]) => (d.ok ? [[key, d.value] as const] : []));
38
+ const errors = declared.flatMap(([key, d]) =>
39
+ d.ok ? [] : [`field "${key}": ${d.error}`],
40
+ );
41
+ if (errors.length > 0)
42
+ throw new Error(`${file}: "submission_fields" ${errors.join("; ")}`);
43
+ return {
44
+ source: j.source,
45
+ url: j.url,
46
+ read: j.read,
47
+ fields: Object.fromEntries(fields),
48
+ };
49
+ }
@@ -0,0 +1,33 @@
1
+ import { expect, it } from "vitest";
2
+ import { scopeOf } from "./venue-scope.ts";
3
+
4
+ it("a preset with no scope has none", () => {
5
+ expect(scopeOf(undefined)).toBeNull();
6
+ });
7
+
8
+ it("a scope without topics carries an empty topic list, the rest as written", () => {
9
+ // Guards: a reader can print topics without asking whether the call gave any.
10
+ expect(
11
+ scopeOf({
12
+ url: "https://example.org/cfp",
13
+ read: "2026-11-25",
14
+ sentences: ["Papers on X."],
15
+ }),
16
+ ).toEqual({
17
+ url: "https://example.org/cfp",
18
+ read: "2026-11-25",
19
+ sentences: ["Papers on X."],
20
+ topics: [],
21
+ });
22
+ });
23
+
24
+ it("a scope's topics are kept verbatim and in order", () => {
25
+ expect(
26
+ scopeOf({
27
+ url: "https://example.org/cfp",
28
+ read: "2026-11-25",
29
+ sentences: ["Papers on X."],
30
+ topics: ["B topic", "A topic"],
31
+ })?.topics,
32
+ ).toEqual(["B topic", "A topic"]);
33
+ });
@@ -0,0 +1,39 @@
1
+ /**
2
+ * A venue's SCOPE: what its call for papers says the venue is for, verbatim, with the page it was
3
+ * read from and the day (`scope` in a venue preset, `presets/venue-profile.schema.json`).
4
+ *
5
+ * It is data for a reader. No rule judges a paper against it: whether a paper fits a call is a
6
+ * judgement, and a judgement made by a rule would be a default finding a careful author could
7
+ * dispute.
8
+ */
9
+
10
+ /** A preset's `scope` after the schema accepted it. */
11
+ export interface VenueScopeJson {
12
+ readonly url: string;
13
+ readonly read: string;
14
+ readonly sentences: readonly string[];
15
+ readonly topics?: readonly string[];
16
+ }
17
+
18
+ /** A venue's scope, as the call states it. */
19
+ export interface VenueScope {
20
+ /** The page the sentences were read from. */
21
+ readonly url: string;
22
+ /** The day they were read, `YYYY-MM-DD`. */
23
+ readonly read: string;
24
+ /** The call's scope sentences, verbatim; at least one. */
25
+ readonly sentences: readonly string[];
26
+ /** The call's topic list, verbatim; empty when the call gives none. */
27
+ readonly topics: readonly string[];
28
+ }
29
+
30
+ /** A preset's `scope`, or null when the file records none. Pure. */
31
+ export const scopeOf = (j: VenueScopeJson | undefined): VenueScope | null =>
32
+ j === undefined
33
+ ? null
34
+ : {
35
+ url: j.url,
36
+ read: j.read,
37
+ sentences: j.sentences,
38
+ topics: j.topics ?? [],
39
+ };
@@ -29,7 +29,8 @@ import { basename, dirname } from "node:path";
29
29
  import { venuesNamedBy, type NamedIn } from "./domain/venue-name.ts";
30
30
  import { editionLabel } from "./domain/edition.ts";
31
31
  import { folderNamesOf, paperPreset, type Preset } from "./presets.ts";
32
- import { otherVenues, type OtherVenue } from "./tex-venue-rules.ts";
32
+ import { otherVenues } from "./tex-venue-rules.ts";
33
+ import type { OtherVenue } from "./venue-leftover.ts";
33
34
  import type { Finding, VenueRuleDeps } from "./venue-rules.ts";
34
35
 
35
36
  /** The file the rule reports on: one per paper folder. */
@@ -317,7 +317,7 @@ describe("paperlint lint — the paper over its preset, and the project's own pr
317
317
  const r = await lint(root);
318
318
  expect(r.code).toBe(1);
319
319
  expect(r.out).toMatch(
320
- /aaai-2027, aaai-press, acl-latex, acm-acmsmall, acm-sigconf, acsac-2026, agent-2027, agenticdev-2026, agentverify-2027, aidc-2026, aisec-2026, ase-2026, ccs-2026, emnlp-2026, fse-2027, icml-2027, icml-style, icse-2027, icse-2028, ieee-conference, msr-2027, neurips-2026, neurips-style, nlbse-2027, realm-2026, sp-2027/,
320
+ /aaai-2027, aaai-press, acl-latex, acm-acmsmall, acm-sigconf, acsac-2026, agent-2027, agenticdev-2026, agentverify-2027, aidc-2026, aisec-2026, ase-2026, ccs-2026, emnlp-2026, fse-2027, icml-2027, icml-style, icse-2027, icse-2028, ieee-conference, langcode-2027, msr-2027, naacl-2027, neurips-2026, neurips-style, nlbse-2027, realm-2026, sp-2027/,
321
321
  );
322
322
  });
323
323
  });
@@ -111,7 +111,9 @@ const SHIPPED_CARDS = [
111
111
  "icse-2027.md",
112
112
  "icse-2028.md",
113
113
  "ieee-conference.md",
114
+ "langcode-2027.md",
114
115
  "msr-2027.md",
116
+ "naacl-2027.md",
115
117
  "neurips-2026.md",
116
118
  "neurips-style.md",
117
119
  "nlbse-2027.md",
@@ -0,0 +1,141 @@
1
+ /**
2
+ * THE MERGE OF A PRESET CHAIN, one file at a time, root first (`src/presets.ts` resolves the chain).
3
+ * Block by block:
4
+ * tex union — a child never removes a package its parent needs
5
+ * format per key, the child wins; `kinds` by kind name, a child's kind replaces that kind
6
+ * rules per rule id, the child wins; `ruleOrigins` keeps which file set each
7
+ * template the child wins, with its `template_forbids`; so does `name`, and `required_sections`, `register`, `talk`,
8
+ * `portal`, `deadlines`, `submission_fields` and `scope` (each whole)
9
+ * aliases union, with every `name` — what the venue is called along the chain
10
+ * parent the child wins: the conference a workshop is held at, a spec resolved from the
11
+ * file that names it
12
+ */
13
+ import {
14
+ mergeRequirements,
15
+ NO_FORMAT,
16
+ NO_REQUIREMENTS,
17
+ type PresetFile,
18
+ type PresetIdentity,
19
+ type VenueFormat,
20
+ } from "./tex-requirements.ts";
21
+ import type { Preset } from "./presets.ts";
22
+
23
+ /** A child's format over its parent's: per key the child wins, kinds by name. Pure. */
24
+ export function mergeFormat(
25
+ parent: VenueFormat,
26
+ child: VenueFormat,
27
+ ): VenueFormat {
28
+ // Every field listed: a VenueFormat literal missing one is a compile error.
29
+ const pick = <K extends Exclude<keyof VenueFormat, "kinds">>(
30
+ k: K,
31
+ ): VenueFormat[K] => child[k] ?? parent[k];
32
+ return {
33
+ pageWidthIn: pick("pageWidthIn"),
34
+ pageHeightIn: pick("pageHeightIn"),
35
+ columns: pick("columns"),
36
+ bodyPt: pick("bodyPt"),
37
+ bodyPtTol: pick("bodyPtTol"),
38
+ refPtMin: pick("refPtMin"),
39
+ refPtMax: pick("refPtMax"),
40
+ fontsText: pick("fontsText"),
41
+ fontsTitle: pick("fontsTitle"),
42
+ bodyEndsAt: pick("bodyEndsAt"),
43
+ appendixInBody: pick("appendixInBody"),
44
+ kinds: new Map([...parent.kinds, ...child.kinds]),
45
+ };
46
+ }
47
+
48
+ /** A venue's name; a family and the base set have none. Pure. */
49
+ const nameOf = (i: PresetIdentity): string | null =>
50
+ i.type === "venue" ? i.name : null;
51
+
52
+ /** A venue's name as a list, empty for a family and the base set. Pure. */
53
+ const namesOf = (i: PresetIdentity): readonly string[] =>
54
+ i.type === "venue" ? [i.name] : [];
55
+
56
+ /** What the merge carries from file to file: the preset without what only the whole chain knows. */
57
+ type Merging = Omit<
58
+ Preset,
59
+ "id" | "label" | "chain" | "identity" | "parentNames" | "year"
60
+ > & {
61
+ readonly name: string | null;
62
+ readonly parent: ParentLink | null;
63
+ };
64
+
65
+ /** A `parent` as a file of the chain names it: the spec, and the file it is resolved from. */
66
+ export interface ParentLink {
67
+ readonly spec: string;
68
+ readonly file: string;
69
+ }
70
+
71
+ export const NOTHING_MERGED: Merging = {
72
+ name: null,
73
+ parent: null,
74
+ template: null,
75
+ templateStyle: null,
76
+ aliases: [],
77
+ declaredAliases: [],
78
+ blind: false,
79
+ requiredSections: [],
80
+ tex: NO_REQUIREMENTS,
81
+ format: NO_FORMAT,
82
+ rules: {},
83
+ ruleOrigins: {},
84
+ registerAnchors: [],
85
+ talk: null,
86
+ portal: null,
87
+ deadlines: [],
88
+ submissionFields: null,
89
+ scope: null,
90
+ };
91
+
92
+ /** The blocks a child replaces whole: the child's when it names one, else its parents'. Pure. */
93
+ const wholeBlocks = (
94
+ acc: Merging,
95
+ p: PresetFile,
96
+ ): Pick<
97
+ Merging,
98
+ | "requiredSections"
99
+ | "registerAnchors"
100
+ | "talk"
101
+ | "portal"
102
+ | "deadlines"
103
+ | "submissionFields"
104
+ | "scope"
105
+ > => ({
106
+ requiredSections: p.requiredSections ?? acc.requiredSections,
107
+ registerAnchors: p.registerAnchors ?? acc.registerAnchors,
108
+ talk: p.talk ?? acc.talk,
109
+ portal: p.portal ?? acc.portal,
110
+ deadlines: p.deadlines ?? acc.deadlines,
111
+ submissionFields: p.submissionFields ?? acc.submissionFields,
112
+ scope: p.scope ?? acc.scope,
113
+ });
114
+
115
+ /** One file of the chain, `file`, merged over what its parents gave. Pure. */
116
+ export const mergeOne = (
117
+ acc: Merging,
118
+ { preset: p, file }: { readonly preset: PresetFile; readonly file: string },
119
+ ): Merging => ({
120
+ name: nameOf(p.identity) ?? acc.name,
121
+ parent: p.parent === null ? acc.parent : { spec: p.parent, file },
122
+ template:
123
+ p.template === null
124
+ ? acc.template
125
+ : { text: p.template, file, forbids: p.templateForbids },
126
+ templateStyle:
127
+ p.templateStyle === null
128
+ ? acc.templateStyle
129
+ : { text: p.templateStyle, file },
130
+ aliases: [...new Set([...acc.aliases, ...namesOf(p.identity), ...p.aliases])],
131
+ declaredAliases: [...new Set([...acc.declaredAliases, ...p.aliases])],
132
+ blind: p.blind ?? acc.blind,
133
+ tex: p.tex ? mergeRequirements(acc.tex, p.tex) : acc.tex,
134
+ format: mergeFormat(acc.format, p.format),
135
+ rules: { ...acc.rules, ...p.rules },
136
+ ruleOrigins: {
137
+ ...acc.ruleOrigins,
138
+ ...Object.fromEntries(Object.keys(p.rules).map((id) => [id, file])),
139
+ },
140
+ ...wholeBlocks(acc, p),
141
+ });