paperlint 20.6.1 → 20.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/default-levels.d.ts +5 -0
- package/dist/default-levels.d.ts.map +1 -0
- package/dist/default-levels.js +36 -0
- package/dist/default-levels.js.map +1 -0
- package/dist/folder-venue-rule.d.ts +1 -1
- package/dist/folder-venue-rule.d.ts.map +1 -1
- package/dist/folder-venue-rule.js.map +1 -1
- package/dist/tex-venue-rules.d.ts +4 -24
- package/dist/tex-venue-rules.d.ts.map +1 -1
- package/dist/tex-venue-rules.js +6 -84
- package/dist/tex-venue-rules.js.map +1 -1
- package/dist/venue-leftover.d.ts +50 -0
- package/dist/venue-leftover.d.ts.map +1 -0
- package/dist/venue-leftover.js +129 -0
- package/dist/venue-leftover.js.map +1 -0
- package/docs/rules/tex/venue-leftover.md +34 -3
- package/docs/rules.md +1 -1
- package/package.json +2 -1
- package/scripts/eslint-file-length.mjs +2 -2
- package/scripts/release-config.test.ts +114 -0
- package/scripts/release-type.test.ts +86 -0
- package/scripts/release-type.ts +76 -0
- package/scripts/semantic-release-plugins.d.ts +20 -1
- package/src/default-levels.test.ts +43 -0
- package/src/default-levels.ts +53 -0
- package/src/folder-venue-rule.ts +2 -1
- package/src/rule-cases.test.ts +10 -3
- package/src/tex-venue-rules.test.ts +63 -129
- package/src/tex-venue-rules.ts +25 -146
- package/src/venue-leftover.test.ts +112 -0
- package/src/venue-leftover.ts +207 -0
|
@@ -12,6 +12,25 @@ It only knows the venues paperlint ships a preset for, by each preset's `name` a
|
|
|
12
12
|
year of each edition, which is the preset's id (`icse-2028` is ICSE 2028). A venue with no preset is
|
|
13
13
|
not recognized.
|
|
14
14
|
|
|
15
|
+
It runs only when the paper extends a venue preset. A template family (`paperlint:acm-sigconf`,
|
|
16
|
+
`paperlint:ieee-conference`) names no venue, so no venue is "another" one, and the rule is silent.
|
|
17
|
+
|
|
18
|
+
## Where it looks
|
|
19
|
+
|
|
20
|
+
| part of the paper | read |
|
|
21
|
+
| ---------------------------------------------------------------- | ---------------------------- |
|
|
22
|
+
| a venue-stating command (`\acmConference` …), wherever it stands | always |
|
|
23
|
+
| the front matter: everything before the first `\section` | always |
|
|
24
|
+
| the body: from the first `\section` on | only with `{ "body": true }` |
|
|
25
|
+
| a paper with no `\section` | all of it, as front matter |
|
|
26
|
+
|
|
27
|
+
The body is off by default because related work names venues with recent years on every page:
|
|
28
|
+
«Lam et al. (CodeCrash, NeurIPS 2025)», «A separate ASE 2026 study examines …». On the 206 papers of
|
|
29
|
+
the real-paper corpus, every one of the 18 findings the rule gave in the body or under a family preset
|
|
30
|
+
was such a citation or the paper's own venue line; with this scope it gives none. A leftover from an
|
|
31
|
+
earlier submission sits in the author block, the venue line, a footnote on the title page or the
|
|
32
|
+
abstract, which the default still reads.
|
|
33
|
+
|
|
15
34
|
## When a name counts
|
|
16
35
|
|
|
17
36
|
A venue preset is one edition, and its year has one source: the id. A name never carries a year
|
|
@@ -31,7 +50,7 @@ year: any year beside another venue's name counts, and its own names never do.
|
|
|
31
50
|
ACL's template has no venue-stating command; IEEEtran states the venue, when at all, in the
|
|
32
51
|
`\IEEEpubid` copyright line.
|
|
33
52
|
|
|
34
|
-
It reads
|
|
53
|
+
It reads `paper.tex` with the files it `\input`s, `\include`s or `\subfile`s
|
|
35
54
|
spliced in; a name found in an included file is reported at that include, with the file and line at
|
|
36
55
|
the front of the message. It looks at what a reader sees — prose, the author block, captions,
|
|
37
56
|
footnotes, a citation's note in square brackets, and the venue-stating commands — and ignores
|
|
@@ -59,7 +78,11 @@ the definition, whether or not the macro is used: the rule does not expand macro
|
|
|
59
78
|
and the exit code stays 0
|
|
60
79
|
```
|
|
61
80
|
|
|
62
|
-
What the machine cannot see: a venue without a shipped preset; a
|
|
81
|
+
What the machine cannot see: a venue without a shipped preset; a leftover in the body, unless
|
|
82
|
+
`body` is on; an abstract set as `\section*{Abstract}` (the front matter ends at the first section,
|
|
83
|
+
starred or not, so such an abstract is body); a `\section` token that is no heading
|
|
84
|
+
(`\titlespacing*{\section}`, `\let\oldsection\section`) standing before the abstract, which ends the
|
|
85
|
+
front matter early; a year written apart from the name
|
|
63
86
|
(«MSR, in 2027»); a name split by markup (`\textbf{AI}Sec`); a venue named in a sentence on purpose,
|
|
64
87
|
which only a disable directive tells apart.
|
|
65
88
|
|
|
@@ -95,7 +118,13 @@ edition.
|
|
|
95
118
|
|
|
96
119
|
## Preset fields
|
|
97
120
|
|
|
98
|
-
|
|
121
|
+
One rule option, `body` (default `false`): also read the body, from the first `\section` on.
|
|
122
|
+
|
|
123
|
+
```jsonc
|
|
124
|
+
"rules": { "tex/venue-leftover": ["warn", { "body": true }] }
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
It reads every shipped preset's `name` and `aliases`, collected along `extends`,
|
|
99
128
|
and the year of its id:
|
|
100
129
|
|
|
101
130
|
```jsonc
|
|
@@ -121,6 +150,8 @@ venue preset, a parent of another year, or parents that name each other, are ref
|
|
|
121
150
|
## What it does not check
|
|
122
151
|
|
|
123
152
|
- A venue no shipped preset describes.
|
|
153
|
+
- A paper that extends a template family rather than a venue.
|
|
154
|
+
- The body, from the first `\section` on, unless `body` is on.
|
|
124
155
|
- A name split by markup (`\textbf{AI}Sec`).
|
|
125
156
|
- A name in prose with no year beside it («submitted to MSR»): the rule cannot tell it from an
|
|
126
157
|
acronym or a mention of the series.
|
package/docs/rules.md
CHANGED
|
@@ -48,7 +48,7 @@ reads and when it fails. Errors fail `paperlint lint`; warnings print and do not
|
|
|
48
48
|
| [`tex/heading-case`](rules/tex/heading-case.md) | optional; the AgenticDev preset sets `error` | `paper.tex` and the files it includes | a word in the paper's `\title` or in a `\section`, `\subsection`, `\subsubsection`, `\paragraph` or `\subparagraph` title is not in the style its scope asks: `{ "title", "headings", "levels"? }`, each `chicago-headline` (Conference Publishing's quote of the Chicago Manual of Style), `sentence` (first word only) or `any`. Words that are a preposition in one title and a particle in another (`up`, `on`, `in`) are not read mid-title. **Fixable:** `--fix` — [page](rules/tex/heading-case.md) |
|
|
49
49
|
| [`format/layout-override`](rules/format/layout-override.md) | error | `paper.tex` → `paperlint.json` | the source changes the page layout the venue's template sets for the whole document — `geometry`, a layout `\setlength`, `\linespread`, `\baselinestretch` — [page](rules/format/layout-override.md) |
|
|
50
50
|
| [`anonymity/identity`](rules/anonymity/identity.md) | error | `paper.tex` → `_build/paper.facts.json` | a double-blind venue (`"blind": true`) and no `identity` declared, or a declared name, handle, email or project in the PDF's text, metadata or link targets — [page](rules/anonymity/identity.md) |
|
|
51
|
-
| [`tex/venue-leftover`](rules/tex/venue-leftover.md) | warn | `paper.tex` → `paperlint.json` | the text names another shipped venue than the edition the paper extends («Submission to VenueA 2026» in a paper now set for VenueB 2027): in prose beside a year no older than the paper's own minus one, in a venue-stating command (`\acmConference` …) always — [page](rules/tex/venue-leftover.md)
|
|
51
|
+
| [`tex/venue-leftover`](rules/tex/venue-leftover.md) | warn | `paper.tex` → `paperlint.json` | the text names another shipped venue than the edition the paper extends («Submission to VenueA 2026» in a paper now set for VenueB 2027): in prose beside a year no older than the paper's own minus one, in a venue-stating command (`\acmConference` …) always; reads the front matter (the body with `body: true`), silent under a template family — [page](rules/tex/venue-leftover.md) |
|
|
52
52
|
| [`tex/claim-provenance`](rules/tex/claim-provenance.md) | opt-in: `paperlint:writing` | `paper.tex` | a sentence of the body states a number and does not say whose it is — no citation or link, no _we_/_our_, no `\ref` or "Table 2", no sample ("n = 134", "48 runs") — [page](rules/tex/claim-provenance.md) |
|
|
53
53
|
| [`tex/register`](rules/tex/register.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes | the body runs to a post's register: more than 0.8 sentences per 1000 words open with _And_, _So_, _But_, _Nor_, _Or_ or _Yet_ — the limit is an option — [page](rules/tex/register.md) |
|
|
54
54
|
| [`tex/contrast-frames`](rules/tex/contrast-frames.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes → `paperlint.json` | contrast frames (_X, not Y_, _not X but Y_, _rather than_, _instead of_, _as opposed to_) per 10,000 words fall outside the band the venue preset's anchors set (AIDC: 0–10.4, from five accepted ACSAC papers); above it, each frame is reported too — [page](rules/tex/contrast-frames.md) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paperlint",
|
|
3
|
-
"version": "20.6.
|
|
3
|
+
"version": "20.6.2",
|
|
4
4
|
"description": "A linter for scientific papers written in LaTeX: catches mistakes before you submit to a conference or journal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@semantic-release/commit-analyzer": "13.0.1",
|
|
57
|
+
"@semantic-release/exec": "7.1.0",
|
|
57
58
|
"@semantic-release/release-notes-generator": "14.1.1",
|
|
58
59
|
"@types/js-yaml": "^4.0.9",
|
|
59
60
|
"@types/markdown-it": "^14.2.0",
|
|
@@ -90,8 +90,8 @@ const legacyCeilings = {
|
|
|
90
90
|
"src/talk-rules.test.ts": 427,
|
|
91
91
|
"src/talk-rules.ts": 562,
|
|
92
92
|
"src/tex-requirements.ts": 482,
|
|
93
|
-
"src/tex-venue-rules.test.ts":
|
|
94
|
-
"src/tex-venue-rules.ts":
|
|
93
|
+
"src/tex-venue-rules.test.ts": 2090,
|
|
94
|
+
"src/tex-venue-rules.ts": 615,
|
|
95
95
|
"src/toolchain-mirror.test.mjs": 631,
|
|
96
96
|
"src/toolchain.ts": 605,
|
|
97
97
|
"src/venue-rules.test.ts": 1684,
|
|
@@ -13,7 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { describe, expect, test } from "vitest";
|
|
15
15
|
import { readFileSync } from "node:fs";
|
|
16
|
+
import { execFileSync } from "node:child_process";
|
|
17
|
+
import { mkdtempSync, realpathSync } from "node:fs";
|
|
18
|
+
import { tmpdir } from "node:os";
|
|
19
|
+
import { join, resolve } from "node:path";
|
|
20
|
+
import { PassThrough } from "node:stream";
|
|
16
21
|
import { analyzeCommits } from "@semantic-release/commit-analyzer";
|
|
22
|
+
import { analyzeCommits as runAnalyzeCmd } from "@semantic-release/exec";
|
|
23
|
+
import steps from "semantic-release/lib/definitions/plugins.js";
|
|
17
24
|
import { generateNotes } from "@semantic-release/release-notes-generator";
|
|
18
25
|
import { z } from "zod";
|
|
19
26
|
|
|
@@ -96,3 +103,110 @@ describe("release config (.releaserc.json) with the installed toolchain", () =>
|
|
|
96
103
|
expect(notes).toContain("resolve the paper from the config root");
|
|
97
104
|
});
|
|
98
105
|
});
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A commit whose tree holds only `default-rules.json` with `snapshot` in it, written to a throwaway
|
|
109
|
+
* object directory that reads this repository's objects but never writes to them. The returned `env`
|
|
110
|
+
* makes git see the commit.
|
|
111
|
+
*/
|
|
112
|
+
function releaseWithSnapshot(snapshot: string): {
|
|
113
|
+
readonly sha: string;
|
|
114
|
+
readonly env: NodeJS.ProcessEnv;
|
|
115
|
+
} {
|
|
116
|
+
const repo = resolve(import.meta.dirname, "..");
|
|
117
|
+
const shared = resolve(
|
|
118
|
+
repo,
|
|
119
|
+
execFileSync("git", ["rev-parse", "--git-common-dir"], {
|
|
120
|
+
cwd: repo,
|
|
121
|
+
encoding: "utf8",
|
|
122
|
+
}).trim(),
|
|
123
|
+
"objects",
|
|
124
|
+
);
|
|
125
|
+
const env = {
|
|
126
|
+
...process.env,
|
|
127
|
+
GIT_OBJECT_DIRECTORY: realpathSync(
|
|
128
|
+
mkdtempSync(join(tmpdir(), "release-objects-")),
|
|
129
|
+
),
|
|
130
|
+
GIT_ALTERNATE_OBJECT_DIRECTORIES: shared,
|
|
131
|
+
};
|
|
132
|
+
const git = (args: readonly string[], input?: string): string =>
|
|
133
|
+
execFileSync("git", args, {
|
|
134
|
+
cwd: repo,
|
|
135
|
+
env,
|
|
136
|
+
input,
|
|
137
|
+
encoding: "utf8",
|
|
138
|
+
}).trim();
|
|
139
|
+
const blob = git(["hash-object", "-w", "--stdin"], snapshot);
|
|
140
|
+
const tree = git(["mktree"], `100644 blob ${blob}\tdefault-rules.json\n`);
|
|
141
|
+
const sha = git([
|
|
142
|
+
"-c",
|
|
143
|
+
"user.name=t",
|
|
144
|
+
"-c",
|
|
145
|
+
"user.email=t@example.com",
|
|
146
|
+
"commit-tree",
|
|
147
|
+
tree,
|
|
148
|
+
"-m",
|
|
149
|
+
"v1",
|
|
150
|
+
]);
|
|
151
|
+
return { sha, env };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
describe("the default rule set's analyzer (@semantic-release/exec)", () => {
|
|
155
|
+
const run = (gitTag: string, env: NodeJS.ProcessEnv) =>
|
|
156
|
+
runAnalyzeCmd(optionsFor("@semantic-release/exec"), {
|
|
157
|
+
...context,
|
|
158
|
+
cwd: resolve(import.meta.dirname, ".."),
|
|
159
|
+
env,
|
|
160
|
+
stdout: new PassThrough(),
|
|
161
|
+
stderr: new PassThrough(),
|
|
162
|
+
lastRelease: { gitTag, version: "1.0.0" },
|
|
163
|
+
commits: [feature],
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test("runs beside the commit analyzer, so semantic-release keeps the higher of the two", () => {
|
|
167
|
+
// Guards: an analyzer placed in no step, or removed, would let a breaking default set out as a minor.
|
|
168
|
+
const names = releaserc.plugins.map((p) => (Array.isArray(p) ? p[0] : p));
|
|
169
|
+
expect(names.slice(0, 2)).toEqual([
|
|
170
|
+
"@semantic-release/commit-analyzer",
|
|
171
|
+
"@semantic-release/exec",
|
|
172
|
+
]);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("semantic-release keeps the highest type the analyzers return", () => {
|
|
176
|
+
// Guards: the whole mechanism rests on this merge; a semantic-release that took the first answer
|
|
177
|
+
// instead would release a breaking default set as whatever the PR title says.
|
|
178
|
+
const merge = steps.analyzeCommits.postprocess;
|
|
179
|
+
expect(merge(["minor", "major"])).toBe("major");
|
|
180
|
+
expect(merge([null, "major"])).toBe("major");
|
|
181
|
+
expect(merge(["minor", undefined])).toBe("minor");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("says major when a rule the last release had at warn is at error now", async () => {
|
|
185
|
+
// Guards: the command semantic-release renders from .releaserc.json reaches the script and its
|
|
186
|
+
// answer comes back, end to end through the installed plugin.
|
|
187
|
+
const now = z
|
|
188
|
+
.record(z.string(), z.string())
|
|
189
|
+
.parse(
|
|
190
|
+
JSON.parse(
|
|
191
|
+
readFileSync(
|
|
192
|
+
new URL("../default-rules.json", import.meta.url),
|
|
193
|
+
"utf8",
|
|
194
|
+
),
|
|
195
|
+
),
|
|
196
|
+
);
|
|
197
|
+
const anError = Object.keys(now).find((id) => now[id] === "error");
|
|
198
|
+
expect(anError).toBeDefined();
|
|
199
|
+
const release = releaseWithSnapshot(
|
|
200
|
+
JSON.stringify({ ...now, [String(anError)]: "warn" }),
|
|
201
|
+
);
|
|
202
|
+
expect(await run(release.sha, release.env)).toBe("major");
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test("says nothing when the last release had the same set, and on a first release", async () => {
|
|
206
|
+
const same = releaseWithSnapshot(
|
|
207
|
+
readFileSync(new URL("../default-rules.json", import.meta.url), "utf8"),
|
|
208
|
+
);
|
|
209
|
+
expect(await run(same.sha, same.env)).toBeUndefined();
|
|
210
|
+
expect(await run("", process.env)).toBeUndefined();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
@@ -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
|
|
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
|
+
};
|
package/src/folder-venue-rule.ts
CHANGED
|
@@ -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
|
|
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. */
|
package/src/rule-cases.test.ts
CHANGED
|
@@ -1408,13 +1408,20 @@ const CASES: Readonly<Record<string, RuleCases>> = {
|
|
|
1408
1408
|
}),
|
|
1409
1409
|
}),
|
|
1410
1410
|
},
|
|
1411
|
-
// EMNLP 2026, a shipped venue (REALM's conference), named with its year in a BlindConf paper's
|
|
1411
|
+
// EMNLP 2026, a shipped venue (REALM's conference), named with its year in a BlindConf paper's
|
|
1412
|
+
// front matter: the default reads prose before the first \section only (#552).
|
|
1412
1413
|
"tex/venue-leftover": {
|
|
1413
1414
|
reports: {
|
|
1414
|
-
tree:
|
|
1415
|
+
tree: paper(
|
|
1416
|
+
tex(
|
|
1417
|
+
`First written for EMNLP 2026.\n\\section{Introduction}\nText.\n${STATEMENT}`,
|
|
1418
|
+
IEEE,
|
|
1419
|
+
),
|
|
1420
|
+
BLIND_PAPER,
|
|
1421
|
+
),
|
|
1415
1422
|
file: TEX_FILE,
|
|
1416
1423
|
severity: 1,
|
|
1417
|
-
line:
|
|
1424
|
+
line: 3,
|
|
1418
1425
|
},
|
|
1419
1426
|
silent: blind("Text."),
|
|
1420
1427
|
},
|