paperlint 20.1.1 → 20.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/ci.yml +7 -0
- package/CLAUDE.md +6 -2
- package/CONTRIBUTING.md +2 -2
- package/{action.harness.mjs → action.test.mjs} +147 -138
- package/dist/adapters/venue-corpus/index.d.ts +345 -0
- package/dist/adapters/venue-corpus/index.d.ts.map +1 -0
- package/dist/adapters/venue-corpus/index.js +205 -0
- package/dist/adapters/venue-corpus/index.js.map +1 -0
- package/dist/domain/licence.d.ts +51 -0
- package/dist/domain/licence.d.ts.map +1 -0
- package/dist/domain/licence.js +61 -0
- package/dist/domain/licence.js.map +1 -0
- package/dist/domain/venue-corpus.d.ts +120 -0
- package/dist/domain/venue-corpus.d.ts.map +1 -0
- package/dist/domain/venue-corpus.js +13 -0
- package/dist/domain/venue-corpus.js.map +1 -0
- package/dist/eslint-rules/CLAUDE.md.spec.d.ts.map +1 -1
- package/dist/eslint-rules/CLAUDE.md.spec.js +1 -0
- package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
- package/dist/eslint-rules/papers.js +1 -1
- package/dist/latex-log.d.ts +1 -1
- package/dist/latex-log.js +1 -1
- package/dist/latex-loop.d.ts +1 -1
- package/dist/latex-loop.js +1 -1
- package/dist/lib/paper-config.d.ts +3 -3
- package/dist/lib/paper-config.js +3 -3
- package/dist/ports/venue-corpus-codec.d.ts +11 -0
- package/dist/ports/venue-corpus-codec.d.ts.map +1 -0
- package/dist/ports/venue-corpus-codec.js +2 -0
- package/dist/ports/venue-corpus-codec.js.map +1 -0
- package/dist/skill-chunks/chunk-5KCU4WTN.js +108 -0
- package/dist/skill-chunks/{chunk-X4VKG4KT.js → chunk-6YEM4VDI.js} +11 -9
- package/dist/skill-chunks/{chunk-L3NJUJUP.js → chunk-CXAGKT44.js} +5 -3
- package/dist/skill-chunks/{chunk-6NU6CXUS.js → chunk-J5XYPERO.js} +12 -72
- package/dist/skill-chunks/{chunk-IREAROCV.js → chunk-Z5YMDZYW.js} +4 -0
- package/dist/skills/study-accepted-papers/scripts/corpus-licences-core.d.ts +54 -0
- package/dist/skills/study-accepted-papers/scripts/corpus-licences.d.ts +2 -0
- package/docs/design/venue-corpus.md +250 -0
- package/docs/e2e.md +9 -9
- package/docs/testing.md +3 -4
- package/docs/venues.md +144 -21
- package/eslint-rules/CLAUDE.md +5 -1
- package/eslint-rules/CLAUDE.md.spec.ts +3 -0
- package/eslint-rules/{install-path-literals.harness.mjs → install-path-literals.test.mjs} +14 -13
- package/eslint-rules/{latex-language.harness.mjs → latex-language-rules.test.mjs} +61 -51
- package/eslint-rules/{paper-stages.harness.mjs → paper-stages-rule.test.mjs} +66 -69
- package/eslint-rules/{papers.harness.mjs → papers.test.mjs} +41 -30
- package/eslint-rules/papers.ts +1 -1
- package/eslint-rules/{pdf-last-page-balance.harness.mjs → pdf-last-page-balance.test.mjs} +27 -15
- package/eslint-rules/{temp-root-realpath.harness.mjs → temp-root-realpath.test.mjs} +24 -24
- package/eslint-rules/{tex-build.harness.mjs → tex-build.test.mjs} +292 -271
- package/eslint.config.mjs +15 -2
- package/fixtures/pdf-facts/README.md +1 -1
- package/fixtures/render-paper/build-clean.sh +1 -1
- package/fixtures/toolchain-mirror/install-tl +1 -1
- package/lib/{agent-cli-version.harness.mjs → agent-cli-version.test.mjs} +17 -18
- package/lib/{paper-config.harness.mjs → paper-config.test.mjs} +21 -20
- package/lib/paper-config.ts +3 -3
- package/lib/{skill-trigger-cases.harness.mjs → skill-trigger-cases-carrier.test.mjs} +78 -115
- package/package.json +4 -3
- package/presets/acm-acmsmall.jsonc +1 -1
- package/scripts/bundle-skills.ts +1 -0
- package/scripts/check-workflow.test.ts +368 -0
- package/scripts/check.ts +2 -2
- package/scripts/eslint-file-length.mjs +9 -9
- package/scripts/eslint-report-guard.mjs +1 -1
- package/scripts/eslint-report-guard.test.mjs +1 -1
- package/scripts/harness-api.test.ts +7 -46
- package/scripts/{rules-see-files.harness.mjs → rules-see-files-rule.test.mjs} +10 -6
- package/scripts/rules-see-files.mjs +1 -1
- package/scripts/venue-corpus-schema.test.ts +39 -0
- package/scripts/venue-corpus-schema.ts +17 -0
- package/skills/argument-arc/scripts/headings.js +6 -4
- package/skills/cold-read-diff/scripts/cold-read.js +6 -4
- package/skills/paper-pipeline/{paper-pipeline.harness.mjs → paper-pipeline.test.mjs} +45 -46
- package/skills/paper-pipeline/scripts/{consumer.harness.mjs → consumer-paths.test.mjs} +66 -59
- package/skills/paper-pipeline/scripts/consumer.mjs +3 -3
- package/skills/paper-pipeline/scripts/{extract-ref-facts.harness.mjs → extract-ref-facts-cli.test.mjs} +29 -31
- package/skills/paper-pipeline/scripts/extract-ref-facts.js +6 -5
- package/skills/paper-pipeline/scripts/fixtures/real-bib/refs.bib +1 -1
- package/skills/paper-pipeline/scripts/{generated-code.harness.mjs → generated-code-fixtures.test.mjs} +39 -46
- package/skills/pc-panel-review/scripts/prior-reviews.js +7 -5
- package/skills/render-paper/{extract-pdf-facts.harness.ts → extract-pdf-facts.test.ts} +20 -13
- package/skills/render-paper/{render-paper.harness.mjs → render-paper.test.mjs} +41 -40
- package/skills/study-accepted-papers/SKILL.md +28 -2
- package/skills/study-accepted-papers/SKILL.md.spec.ts +27 -1
- package/skills/study-accepted-papers/papers.schema.json +427 -0
- package/skills/study-accepted-papers/scripts/corpus-licences-core.js +180 -0
- package/skills/study-accepted-papers/scripts/corpus-licences-core.ts +302 -0
- package/skills/study-accepted-papers/scripts/corpus-licences.js +383 -0
- package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +485 -0
- package/skills/study-accepted-papers/scripts/corpus-licences.ts +27 -0
- package/skills/verify-citations/scripts/bib-authors.js +6 -5
- package/skills/verify-citations/scripts/verify-cites.js +6 -5
- package/src/adapters/pdfjs/fill.test.ts +1 -1
- package/src/adapters/venue-corpus/index.test.ts +279 -0
- package/src/adapters/venue-corpus/index.ts +286 -0
- package/src/{build-engine.harness.mjs → build-engine-prepare.test.mjs} +98 -81
- package/src/{build.harness.mjs → build-fake-tex.test.mjs} +61 -28
- package/src/{cli.harness.mjs → cli-e2e.test.mjs} +108 -102
- package/src/cli.test.ts +1 -1
- package/src/{doctor.harness.mjs → doctor-install.test.mjs} +28 -29
- package/src/domain/licence.test.ts +122 -0
- package/src/domain/licence.ts +95 -0
- package/src/domain/venue-corpus.ts +130 -0
- package/src/{engine.harness.mjs → engine.test.mjs} +120 -106
- package/src/facts-file.test.ts +1 -1
- package/src/{hooks-settings.harness.ts → hooks-settings.test.ts} +161 -146
- package/src/latex-log.test.ts +395 -0
- package/src/latex-log.ts +1 -1
- package/src/latex-loop.test.ts +553 -0
- package/src/latex-loop.ts +1 -1
- package/src/{link-skills.harness.ts → link-skills-fs.test.ts} +26 -26
- package/src/{new-paper.harness.mjs → new-paper-scaffold.test.mjs} +31 -19
- package/src/{pdf-facts.harness.ts → pdf-facts-tables.test.ts} +28 -22
- package/src/{pdf-geometry.harness.ts → pdf-geometry.test.ts} +93 -75
- package/src/ports/venue-corpus-codec.ts +11 -0
- package/src/{rules-config.harness.ts → rules-config.test.ts} +41 -31
- package/src/{structure.harness.ts → structure.test.ts} +12 -10
- package/src/{tex-requirements.harness.ts → tex-requirements-tables.test.ts} +106 -85
- package/src/{toolchain.harness.mjs → toolchain-mirror.test.mjs} +204 -186
- package/scripts/check.harness.ts +0 -343
- package/scripts/harness-api.frozen.json +0 -41
- package/src/latex-log.harness.ts +0 -382
- package/src/latex-loop.harness.ts +0 -515
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Both halves for `npm run check` — and the half that matters is not "does it run the gates",
|
|
3
|
+
* it is "does its list still describe the CI it claims to mirror".
|
|
4
|
+
*
|
|
5
|
+
* 🔴 A HANDWRITTEN LIST OF GATES IS A FOSSIL THE DAY AFTER IT IS WRITTEN. That is measured, not
|
|
6
|
+
* feared: on 2026-09-19 eleven scripts existed with no aggregate, a subset was run from memory,
|
|
7
|
+
* and a suite-breaking change was pushed. Writing the subset down in a doc would have produced
|
|
8
|
+
* the same outcome one release later — the list would simply have been wrong instead of absent.
|
|
9
|
+
*
|
|
10
|
+
* So the assertions below do not check that `check.ts` contains the right strings. They pull
|
|
11
|
+
* the job names OUT OF `.github/workflows/ci.yml` and require every one to be accounted for.
|
|
12
|
+
* Add a job to CI and this goes red the same day, naming the job nobody covered.
|
|
13
|
+
*
|
|
14
|
+
* Each part below is one vitest `it`; the checks inside it are soft, so one failure does not hide
|
|
15
|
+
* the ones after it.
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
18
|
+
import { dirname, join } from "node:path";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
20
|
+
import { load } from "js-yaml";
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
import { expect, it, vi } from "vitest";
|
|
23
|
+
import type { Gate } from "./check.ts";
|
|
24
|
+
|
|
25
|
+
// Several tests here run real ESLint, spawn processes or walk the repository.
|
|
26
|
+
vi.setConfig({ testTimeout: 120_000 });
|
|
27
|
+
|
|
28
|
+
/** A workflow file, as far as these checks read it. `on` is a plain key: js-yaml reads YAML 1.2. */
|
|
29
|
+
const Step = z.looseObject({
|
|
30
|
+
name: z.string().optional(),
|
|
31
|
+
run: z.string().optional(),
|
|
32
|
+
uses: z.string().optional(),
|
|
33
|
+
});
|
|
34
|
+
const Workflow = z.looseObject({
|
|
35
|
+
on: z
|
|
36
|
+
.looseObject({
|
|
37
|
+
pull_request: z
|
|
38
|
+
.looseObject({ types: z.array(z.string()).optional() })
|
|
39
|
+
.nullish(),
|
|
40
|
+
})
|
|
41
|
+
.optional(),
|
|
42
|
+
jobs: z
|
|
43
|
+
.record(
|
|
44
|
+
z.string(),
|
|
45
|
+
z.looseObject({
|
|
46
|
+
"runs-on": z.string().optional(),
|
|
47
|
+
steps: z.array(Step).optional(),
|
|
48
|
+
strategy: z
|
|
49
|
+
.looseObject({
|
|
50
|
+
matrix: z
|
|
51
|
+
.looseObject({
|
|
52
|
+
os: z.array(z.string()).optional(),
|
|
53
|
+
shard: z.array(z.number()).optional(),
|
|
54
|
+
})
|
|
55
|
+
.optional(),
|
|
56
|
+
})
|
|
57
|
+
.optional(),
|
|
58
|
+
}),
|
|
59
|
+
)
|
|
60
|
+
.optional(),
|
|
61
|
+
});
|
|
62
|
+
type Workflow = z.infer<typeof Workflow>;
|
|
63
|
+
const PackageJson = z.looseObject({
|
|
64
|
+
scripts: z.record(z.string(), z.string()).optional(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
68
|
+
const ROOT = dirname(HERE);
|
|
69
|
+
|
|
70
|
+
const { GATES, NOT_COVERED, outcome, skippedIn, commandOf } =
|
|
71
|
+
await import("./check.ts");
|
|
72
|
+
|
|
73
|
+
/** One soft assertion: a failed check does not stop the checks after it in the same test. */
|
|
74
|
+
const check = (label: string, cond: unknown, detail?: unknown): void => {
|
|
75
|
+
const shown = typeof detail === "string" ? detail : JSON.stringify(detail);
|
|
76
|
+
expect
|
|
77
|
+
.soft(cond, detail === undefined ? label : `${label}\n${shown}`)
|
|
78
|
+
.toBe(true);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// ── the workflow is the ORACLE, not a copy of it ───────────────────────────────────────────
|
|
82
|
+
// A skip is a THIRD outcome. Folding it into "pass" printed "all gates passed" on a machine where
|
|
83
|
+
// the e2e never ran (Codex review on #45); folding it into "fail" would make the command red for
|
|
84
|
+
// anyone without pnpm or TeX, and it would be ignored. The count is vitest's own, from its report.
|
|
85
|
+
it("the workflow is the ORACLE, not a copy of it: the gate outcomes", () => {
|
|
86
|
+
check("exit 0 of a plain gate is a pass", outcome(0) === "pass");
|
|
87
|
+
check(
|
|
88
|
+
"exit 0 of a vitest gate whose report counts no skip is a pass",
|
|
89
|
+
outcome(0, { skipped: 0 }) === "pass",
|
|
90
|
+
);
|
|
91
|
+
check(
|
|
92
|
+
"exit 0 of a vitest gate whose report counts skipped tests is a SKIP — neither a pass nor a failure",
|
|
93
|
+
outcome(0, { skipped: 2 }) === "skip",
|
|
94
|
+
);
|
|
95
|
+
check(
|
|
96
|
+
"🔴 exit 0 of a vitest gate with no readable report is a FAILURE — an unread count cannot be a pass",
|
|
97
|
+
outcome(0, { skipped: null }) === "fail",
|
|
98
|
+
);
|
|
99
|
+
check(
|
|
100
|
+
"any nonzero exit is a failure, skips or not",
|
|
101
|
+
outcome(1) === "fail" &&
|
|
102
|
+
outcome(2, { skipped: 0 }) === "fail" &&
|
|
103
|
+
outcome(1, { skipped: 3 }) === "fail",
|
|
104
|
+
);
|
|
105
|
+
check(
|
|
106
|
+
"a process killed by a signal (status null) is a failure, not a skip",
|
|
107
|
+
outcome(null) === "fail",
|
|
108
|
+
);
|
|
109
|
+
check(
|
|
110
|
+
"skippedIn counts skipped and todo tests from vitest's JSON report",
|
|
111
|
+
skippedIn(
|
|
112
|
+
JSON.stringify({ numTotalTests: 9, numPendingTests: 3, numTodoTests: 1 }),
|
|
113
|
+
) === 4 &&
|
|
114
|
+
skippedIn(JSON.stringify({ numPendingTests: 0, numTodoTests: 0 })) === 0,
|
|
115
|
+
);
|
|
116
|
+
check(
|
|
117
|
+
"skippedIn: no report, not JSON, or not vitest's shape is null — never zero",
|
|
118
|
+
skippedIn(null) === null &&
|
|
119
|
+
skippedIn("not json") === null &&
|
|
120
|
+
skippedIn("{}") === null,
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Every workflow, not just ci.yml: a harness reading one file would stop seeing a job added to
|
|
125
|
+
// another without a sound. (macOS lived in platform.yml from 2026-09-23 to 2026-09-24; it is now
|
|
126
|
+
// a cell of ci.yml's build-e2e matrix.)
|
|
127
|
+
const WF_DIR = join(ROOT, ".github", "workflows");
|
|
128
|
+
const workflows = Object.fromEntries(
|
|
129
|
+
readdirSync(WF_DIR)
|
|
130
|
+
.filter((f) => f.endsWith(".yml"))
|
|
131
|
+
.map((f) => [
|
|
132
|
+
f,
|
|
133
|
+
Workflow.parse(load(readFileSync(join(WF_DIR, f), "utf-8"))),
|
|
134
|
+
]),
|
|
135
|
+
);
|
|
136
|
+
const ciJobs = Object.values(workflows).flatMap((wf) =>
|
|
137
|
+
Object.keys(wf.jobs ?? {}),
|
|
138
|
+
);
|
|
139
|
+
it("the workflow is the ORACLE, not a copy of it: the workflows parse and declare jobs", () => {
|
|
140
|
+
check(
|
|
141
|
+
"the workflows parse and declare jobs — without this every assertion below is vacuous",
|
|
142
|
+
ciJobs.length > 0 && "ci.yml" in workflows,
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// ── macOS: a cell of the TeX job, on every push ─────────────────────────────────────────
|
|
147
|
+
// install-tl-unx must work there, and issue #9 appears there alone. The trigger used to be a
|
|
148
|
+
// separate once-per-PR workflow; the repository is public, so the minutes are free.
|
|
149
|
+
const prTypes = (wf: Workflow | undefined): string[] =>
|
|
150
|
+
wf?.on?.pull_request?.types ?? [];
|
|
151
|
+
const buildOs =
|
|
152
|
+
workflows["ci.yml"]?.jobs?.["build-e2e"]?.strategy?.matrix?.os ?? [];
|
|
153
|
+
it("macOS: a cell of the TeX job, on every push", () => {
|
|
154
|
+
check(
|
|
155
|
+
"build-e2e runs on Linux AND macOS — one job, two operating systems",
|
|
156
|
+
buildOs.includes("ubuntu-latest") && buildOs.includes("macos-latest"),
|
|
157
|
+
JSON.stringify(buildOs),
|
|
158
|
+
);
|
|
159
|
+
const unitMacos = workflows["ci.yml"]?.jobs?.["unit-macos"];
|
|
160
|
+
check(
|
|
161
|
+
"unit-macos runs npm test on macOS in two shards — issue #9's platform, beside the TeX cell, every test once",
|
|
162
|
+
unitMacos?.["runs-on"] === "macos-latest" &&
|
|
163
|
+
JSON.stringify(unitMacos.strategy?.matrix?.shard) === "[1,2]" &&
|
|
164
|
+
(unitMacos.steps ?? []).some(
|
|
165
|
+
(s) => s.run?.trim() === "npm test -- --shard=${{ matrix.shard }}/2",
|
|
166
|
+
),
|
|
167
|
+
JSON.stringify({
|
|
168
|
+
on: unitMacos?.["runs-on"] ?? null,
|
|
169
|
+
shard: unitMacos?.strategy?.matrix?.shard ?? null,
|
|
170
|
+
}),
|
|
171
|
+
);
|
|
172
|
+
check(
|
|
173
|
+
"no workflow listens to `labeled` — a label trigger re-fires on every push and can pass by skipping",
|
|
174
|
+
Object.values(workflows).every((wf) => !prTypes(wf).includes("labeled")),
|
|
175
|
+
);
|
|
176
|
+
check(
|
|
177
|
+
"ci.yml listens to ready_for_review — otherwise marking a draft ready runs NOTHING",
|
|
178
|
+
prTypes(workflows["ci.yml"]).includes("ready_for_review"),
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// ── HALF ONE: every CI job is accounted for ────────────────────────────────────────────────
|
|
183
|
+
it("HALF ONE: every CI job is accounted for", () => {
|
|
184
|
+
const covered = new Set(GATES.map((g) => g.job).filter(Boolean));
|
|
185
|
+
for (const job of ciJobs) {
|
|
186
|
+
check(
|
|
187
|
+
`CI job «${job}» is either reproduced by a gate or named in NOT_COVERED with a reason — ` +
|
|
188
|
+
`an unexplained gap is indistinguishable from an oversight`,
|
|
189
|
+
covered.has(job) || typeof NOT_COVERED[job] === "string",
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// ── HALF TWO: the list names nothing that does not exist ───────────────────────────────────
|
|
195
|
+
it("HALF TWO: the list names nothing that does not exist", () => {
|
|
196
|
+
// A dead job name is worse than a missing one: it reads as coverage and delivers nothing.
|
|
197
|
+
for (const g of GATES) {
|
|
198
|
+
if (g.job === null) continue;
|
|
199
|
+
check(
|
|
200
|
+
`gate «${g.name}» names a job that really exists in a workflow (${g.job})`,
|
|
201
|
+
ciJobs.includes(g.job),
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
for (const job of Object.keys(NOT_COVERED)) {
|
|
205
|
+
check(
|
|
206
|
+
`NOT_COVERED names a job that really exists in a workflow (${job})`,
|
|
207
|
+
ciJobs.includes(job),
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// ── HALF THREE: every gate is runnable ─────────────────────────────────────────────────────
|
|
213
|
+
// A gate whose script or file was renamed fails at the moment someone runs it — which is
|
|
214
|
+
// exactly the moment they are trusting it. Catch it here instead.
|
|
215
|
+
const scripts =
|
|
216
|
+
PackageJson.parse(
|
|
217
|
+
JSON.parse(readFileSync(join(ROOT, "package.json"), "utf-8")),
|
|
218
|
+
).scripts ?? {};
|
|
219
|
+
it("HALF THREE: every gate is runnable", () => {
|
|
220
|
+
for (const g of GATES) {
|
|
221
|
+
check(
|
|
222
|
+
`gate «${g.name}» says how to run it in exactly one way (script or run)`,
|
|
223
|
+
Boolean(g.script) !== Array.isArray(g.run),
|
|
224
|
+
);
|
|
225
|
+
if (g.script) {
|
|
226
|
+
check(
|
|
227
|
+
`gate «${g.name}» maps to a script that exists (npm run ${g.script})`,
|
|
228
|
+
typeof scripts[g.script] === "string",
|
|
229
|
+
);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
// A `run` gate names files and programs directly. Every file it names must be on disk, and
|
|
233
|
+
// every program other than `node` must be installed in node_modules/.bin.
|
|
234
|
+
const argv = commandOf(g);
|
|
235
|
+
const files = argv.filter((a) => /\.[cm]?[jt]s$/.test(a));
|
|
236
|
+
const programs = [argv[0]];
|
|
237
|
+
// Guards: a gate runs SOMETHING — a script of ours, or an installed program such as `tsc`.
|
|
238
|
+
check(
|
|
239
|
+
`gate «${g.name}» runs files that exist (${files.join(", ")})`,
|
|
240
|
+
(files.length > 0 || programs.some((p) => p !== "node")) &&
|
|
241
|
+
files.every((f) => existsSync(join(ROOT, f))),
|
|
242
|
+
);
|
|
243
|
+
check(
|
|
244
|
+
`gate «${g.name}» runs programs that are installed (${programs.join(", ")})`,
|
|
245
|
+
programs.every(
|
|
246
|
+
(p) =>
|
|
247
|
+
p === "node" || existsSync(join(ROOT, "node_modules", ".bin", p)),
|
|
248
|
+
),
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
for (const g of GATES.filter((x) => x.vitest)) {
|
|
252
|
+
// Guards: the skip count is read from vitest's JSON report, so the script must BE a vitest run.
|
|
253
|
+
check(
|
|
254
|
+
`gate «${g.name}» is marked vitest, and its script is a vitest run (npm run ${String(g.script)})`,
|
|
255
|
+
(scripts[g.script ?? ""] ?? "").startsWith("vitest run"),
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
check(
|
|
259
|
+
"`check` itself is wired as a script, or nobody can run any of this",
|
|
260
|
+
typeof scripts.check === "string",
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// ── HALF FOUR: a local-only gate must say WHY ──────────────────────────────────────────────
|
|
265
|
+
// Without this, `job: null` becomes the quiet way to drop something out of CI.
|
|
266
|
+
it("HALF FOUR: a local-only gate must say WHY", () => {
|
|
267
|
+
for (const g of GATES.filter((g) => g.job === null)) {
|
|
268
|
+
check(
|
|
269
|
+
`local-only gate «${g.name}» carries a reason`,
|
|
270
|
+
typeof g.reason === "string" && g.reason.length > 20,
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// ── HALF FIVE: the gate's command RUNS in the job it names ─────────────────────────────────
|
|
276
|
+
// Half two proves the job exists; it does not prove the job runs the gate. `the tests type-check`
|
|
277
|
+
// claimed `gates` for weeks while no step of that job ran tsc — the claim was the only coverage.
|
|
278
|
+
// So each step's `run` is split into commands (lines, `&&`, `||`, `;`) and each command into
|
|
279
|
+
// tokens, and the gate's own command has to be one of them: `npm run <script>` (flags and extra
|
|
280
|
+
// arguments allowed) for a script gate, its argv (an `npx` in front and extra arguments allowed)
|
|
281
|
+
// for a run gate. Tokens, not a substring: `npm run lint` must not be found inside
|
|
282
|
+
// `npm run lint:skills`, nor a path inside a comment.
|
|
283
|
+
const commandsIn = (run: string | undefined): string[][] =>
|
|
284
|
+
(run ?? "")
|
|
285
|
+
.split(/\n|&&|\|\||;/)
|
|
286
|
+
.map((c) => c.trim().split(/\s+/).filter(Boolean))
|
|
287
|
+
.filter((t) => t.length > 0);
|
|
288
|
+
const stepsOf = (job: string) =>
|
|
289
|
+
Object.values(workflows).flatMap((wf) => wf.jobs?.[job]?.steps ?? []);
|
|
290
|
+
const startsWith = (tokens: readonly string[], prefix: readonly string[]) =>
|
|
291
|
+
prefix.every((p, i) => tokens[i] === p);
|
|
292
|
+
const runsGate = (tokens: readonly string[], g: Gate): boolean => {
|
|
293
|
+
if (g.script)
|
|
294
|
+
return (
|
|
295
|
+
tokens[0] === "npm" &&
|
|
296
|
+
tokens[1] === "run" &&
|
|
297
|
+
tokens.slice(2).find((t) => !t.startsWith("-")) === g.script
|
|
298
|
+
);
|
|
299
|
+
const argv = commandOf(g);
|
|
300
|
+
return (
|
|
301
|
+
startsWith(tokens, argv) ||
|
|
302
|
+
(tokens[0] === "npx" && startsWith(tokens.slice(1), argv))
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
it("HALF FIVE: the gate's command RUNS in the job it names", () => {
|
|
306
|
+
for (const g of GATES) {
|
|
307
|
+
if (g.job === null) continue;
|
|
308
|
+
const steps = stepsOf(g.job);
|
|
309
|
+
const { inCi } = g;
|
|
310
|
+
if (inCi) {
|
|
311
|
+
// A gate CI runs as a side effect of another step, through an npm lifecycle script: the step
|
|
312
|
+
// it names must exist in the job and install the package (npm runs lifecycle scripts there),
|
|
313
|
+
// and the lifecycle script must be the gate's own command, so the two cannot drift apart.
|
|
314
|
+
const step = steps.find((s) => s.name === inCi.step);
|
|
315
|
+
const tokens = commandsIn(step?.run)[0] ?? [];
|
|
316
|
+
check(
|
|
317
|
+
`gate «${g.name}» runs in CI job «${g.job}» through step «${inCi.step}», whose ${inCi.lifecycle} script is the gate's command`,
|
|
318
|
+
step !== undefined &&
|
|
319
|
+
tokens[0] === "npm" &&
|
|
320
|
+
["ci", "install"].includes(tokens[1] ?? "") &&
|
|
321
|
+
typeof scripts[g.script] === "string" &&
|
|
322
|
+
scripts[inCi.lifecycle] === scripts[g.script],
|
|
323
|
+
JSON.stringify({ run: step?.run, lifecycle: scripts[inCi.lifecycle] }),
|
|
324
|
+
);
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
check(
|
|
328
|
+
`gate «${g.name}» runs its command (${commandOf(g).join(" ")}) in a step of CI job «${g.job}»`,
|
|
329
|
+
steps.some((s) => commandsIn(s.run).some((t) => runsGate(t, g))),
|
|
330
|
+
steps.map((s) => s.run ?? `(uses ${String(s.uses)})`).join(" | "),
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// ── the e2e runs are found by vitest's projects, never listed ──────────────────────────────
|
|
336
|
+
// A list of e2e files is a second copy of the directory, and the three copies that existed
|
|
337
|
+
// (package.json, this script, CI) disagreed: two of four, four of four, a step per file (#132).
|
|
338
|
+
const namesE2eFile = (run: string | undefined): string[] =>
|
|
339
|
+
commandsIn(run)
|
|
340
|
+
.flat()
|
|
341
|
+
.filter((t) => /(^|\/)test\/e2e\//.test(t));
|
|
342
|
+
it("the e2e runs are found by vitest's projects, never listed", () => {
|
|
343
|
+
check(
|
|
344
|
+
"no npm script names a file under test/e2e/ — the vitest projects find them",
|
|
345
|
+
Object.values(scripts).flatMap(namesE2eFile).length === 0,
|
|
346
|
+
JSON.stringify(scripts),
|
|
347
|
+
);
|
|
348
|
+
check(
|
|
349
|
+
"no workflow step names a file under test/e2e/",
|
|
350
|
+
Object.values(workflows)
|
|
351
|
+
.flatMap((wf) => Object.values(wf.jobs ?? {}))
|
|
352
|
+
.flatMap((j) => j.steps ?? [])
|
|
353
|
+
.flatMap((st) => namesE2eFile(st.run)).length === 0,
|
|
354
|
+
);
|
|
355
|
+
check(
|
|
356
|
+
"no gate names a file under test/e2e/",
|
|
357
|
+
GATES.flatMap((g) => commandOf(g).filter((t) => t.includes("test/e2e/")))
|
|
358
|
+
.length === 0,
|
|
359
|
+
);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// ── and the tail is not optional ───────────────────────────────────────────────────────────
|
|
363
|
+
it("and the tail is not optional", () => {
|
|
364
|
+
check(
|
|
365
|
+
"NOT_COVERED is non-empty — if it ever is, either CI shrank or someone silenced the tail",
|
|
366
|
+
Object.keys(NOT_COVERED).length > 0,
|
|
367
|
+
);
|
|
368
|
+
});
|
package/scripts/check.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* boundary reads as complete, which is the same class as a counter that counts what it ignores.
|
|
20
20
|
*
|
|
21
21
|
* ── WHAT KEEPS THE LIST FROM GOING STALE ───────────────────────────────────────────────────
|
|
22
|
-
* `check.
|
|
22
|
+
* `check-workflow.test.ts` sits beside it and pulls the job names OUT OF THE WORKFLOW ITSELF,
|
|
23
23
|
* requiring every one to be either covered here or named in `NOT_COVERED` with a reason. Add a
|
|
24
24
|
* job to CI and the harness goes red the same day — the list cannot quietly fall behind.
|
|
25
25
|
*
|
|
@@ -59,7 +59,7 @@ const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
|
59
59
|
*/
|
|
60
60
|
/**
|
|
61
61
|
* How CI runs a gate that has no step of its own: the step that runs it as a side effect, and the
|
|
62
|
-
* npm lifecycle script through which it does. `check.
|
|
62
|
+
* npm lifecycle script through which it does. `check-workflow.test.ts` requires that step in the job
|
|
63
63
|
* and that lifecycle script to be the gate's own command, so the two cannot drift apart.
|
|
64
64
|
*/
|
|
65
65
|
export interface RunInCi {
|
|
@@ -4,15 +4,15 @@ const fileLength = { max: 300, skipBlankLines: true, skipComments: true };
|
|
|
4
4
|
// Existing files keep a measured ceiling. Lower it when the file shrinks,
|
|
5
5
|
// and remove the entry when it fits the common limit.
|
|
6
6
|
const legacyCeilings = {
|
|
7
|
-
"eslint-rules/latex-language.
|
|
7
|
+
"eslint-rules/latex-language-rules.test.mjs": 428,
|
|
8
8
|
"eslint-rules/latex-language.ts": 610,
|
|
9
9
|
"eslint-rules/paper-stages.ts": 313,
|
|
10
10
|
"eslint-rules/paper-typography.test.mjs": 420,
|
|
11
11
|
"eslint-rules/paper-typography.ts": 397,
|
|
12
12
|
"eslint-rules/prereg-coverage.test.ts": 407,
|
|
13
13
|
"eslint-rules/prereg-coverage.ts": 320,
|
|
14
|
-
"eslint-rules/tex-build.
|
|
15
|
-
"eslint.config.mjs":
|
|
14
|
+
"eslint-rules/tex-build.test.mjs": 557,
|
|
15
|
+
"eslint.config.mjs": 635,
|
|
16
16
|
"scripts/coverage-config.test.ts": 376,
|
|
17
17
|
"scripts/pipeline.ts": 380,
|
|
18
18
|
"src/adapters/git/history.test.ts": 327,
|
|
@@ -27,11 +27,11 @@ const legacyCeilings = {
|
|
|
27
27
|
"src/artifact.test.ts": 451,
|
|
28
28
|
"src/artifact.ts": 332,
|
|
29
29
|
"src/bib-rules.test.ts": 324,
|
|
30
|
-
"src/build.
|
|
30
|
+
"src/build-fake-tex.test.mjs": 633,
|
|
31
31
|
"src/build.test.ts": 583,
|
|
32
32
|
"src/build.ts": 689,
|
|
33
33
|
"src/claim-provenance.test.ts": 342,
|
|
34
|
-
"src/cli.
|
|
34
|
+
"src/cli-e2e.test.mjs": 1582,
|
|
35
35
|
"src/cli.test.ts": 1420,
|
|
36
36
|
"src/cli.ts": 2321,
|
|
37
37
|
"src/domain/body-pages.test.ts": 418,
|
|
@@ -56,12 +56,12 @@ const legacyCeilings = {
|
|
|
56
56
|
"src/facts-file.ts": 337,
|
|
57
57
|
"src/heading-case.test.ts": 460,
|
|
58
58
|
"src/hooks-notice.test.ts": 578,
|
|
59
|
-
"src/hooks-settings.
|
|
59
|
+
"src/hooks-settings.test.ts": 341,
|
|
60
60
|
"src/hooks-settings.ts": 330,
|
|
61
61
|
"src/init.test.ts": 622,
|
|
62
62
|
"src/init.ts": 828,
|
|
63
|
-
"src/latex-log.
|
|
64
|
-
"src/latex-loop.
|
|
63
|
+
"src/latex-log.test.ts": 341,
|
|
64
|
+
"src/latex-loop.test.ts": 499,
|
|
65
65
|
"src/lint-edited-hook.test.ts": 542,
|
|
66
66
|
"src/new-paper.test.ts": 783,
|
|
67
67
|
"src/outputs-before-decision-rule.test.ts": 406,
|
|
@@ -92,7 +92,7 @@ const legacyCeilings = {
|
|
|
92
92
|
"src/tex-requirements.ts": 482,
|
|
93
93
|
"src/tex-venue-rules.test.ts": 2152,
|
|
94
94
|
"src/tex-venue-rules.ts": 695,
|
|
95
|
-
"src/toolchain.
|
|
95
|
+
"src/toolchain-mirror.test.mjs": 631,
|
|
96
96
|
"src/toolchain.ts": 605,
|
|
97
97
|
"src/venue-rules.test.ts": 1684,
|
|
98
98
|
"src/venue-rules.ts": 807,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* 🔴 IT LIVES IN A FILE, NOT INSIDE `action.yml`. An inline `node -e` blob in a composite step is
|
|
15
15
|
* unreachable from a test: the only way to exercise it is to run the whole action on a runner. This
|
|
16
|
-
* file is called by the action and by `action.
|
|
16
|
+
* file is called by the action and by `action.test.mjs` with the same arguments, so the harness
|
|
17
17
|
* proves the BEHAVIOUR rather than the presence of a string in YAML.
|
|
18
18
|
*
|
|
19
19
|
* Usage: node scripts/eslint-report-guard.mjs <report.json> <eslint-rc> [paths] [config]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The report guard's listing: a file entry without `messages`, a warning, and a message with no
|
|
3
3
|
* rule (ESLint's own parse errors carry `ruleId: null`). The zero-file refusal and the pass-through
|
|
4
|
-
* are driven end to end by `action.
|
|
4
|
+
* are driven end to end by `action.test.mjs`.
|
|
5
5
|
*/
|
|
6
6
|
import assert from "node:assert/strict";
|
|
7
7
|
import { writeFileSync } from "node:fs";
|
|
@@ -5,11 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* The rule is read from the file's IMPORTS, parsed with the TypeScript compiler — not from its
|
|
7
7
|
* folder and not from a text search: a comment or a string that mentions `runHook` is not an import,
|
|
8
|
-
* and `
|
|
9
|
-
*
|
|
10
|
-
* Harnesses that predate the rule and import none of the three are frozen in
|
|
11
|
-
* `harness-api.frozen.json` (issue #77). That list only shrinks: an entry that now imports the API,
|
|
12
|
-
* or that no longer exists, has to leave it.
|
|
8
|
+
* and the CLI's end-to-end test (once `cli.harness.mjs`) calls a function of paperlint's own that happens to be called `runHook`.
|
|
13
9
|
*/
|
|
14
10
|
import assert from "node:assert/strict";
|
|
15
11
|
import { execFileSync } from "node:child_process";
|
|
@@ -18,16 +14,8 @@ import { basename, dirname, join } from "node:path";
|
|
|
18
14
|
import { test } from "vitest";
|
|
19
15
|
import { fileURLToPath } from "node:url";
|
|
20
16
|
import ts from "typescript";
|
|
21
|
-
import { z } from "zod";
|
|
22
17
|
|
|
23
18
|
const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
24
|
-
const FROZEN: readonly string[] = z
|
|
25
|
-
.object({ harnesses: z.array(z.string()) })
|
|
26
|
-
.parse(
|
|
27
|
-
JSON.parse(
|
|
28
|
-
readFileSync(join(ROOT, "scripts", "harness-api.frozen.json"), "utf8"),
|
|
29
|
-
),
|
|
30
|
-
).harnesses;
|
|
31
19
|
|
|
32
20
|
/** vigiles' agent-testing API — what a harness exists to call. */
|
|
33
21
|
export const AGENT_API = new Set(["runHook", "runHarnessTest", "runEval"]);
|
|
@@ -84,28 +72,14 @@ export function importsAgentApi(fileName: string, source: string): boolean {
|
|
|
84
72
|
return found;
|
|
85
73
|
}
|
|
86
74
|
|
|
87
|
-
/** Harness-named files, among `paths`, that import none of the API
|
|
88
|
-
export function misnamed(
|
|
89
|
-
files: ReadonlyMap<string, string>,
|
|
90
|
-
frozen: readonly string[],
|
|
91
|
-
): string[] {
|
|
75
|
+
/** Harness-named files, among `paths`, that import none of the API. */
|
|
76
|
+
export function misnamed(files: ReadonlyMap<string, string>): string[] {
|
|
92
77
|
return [...files]
|
|
93
|
-
.filter(([p]) => isHarnessName(p)
|
|
78
|
+
.filter(([p]) => isHarnessName(p))
|
|
94
79
|
.filter(([p, src]) => !importsAgentApi(p, src))
|
|
95
80
|
.map(([p]) => p);
|
|
96
81
|
}
|
|
97
82
|
|
|
98
|
-
/** Frozen entries that must leave: gone from the tree, or now importing the API. */
|
|
99
|
-
export function mustLeave(
|
|
100
|
-
files: ReadonlyMap<string, string>,
|
|
101
|
-
frozen: readonly string[],
|
|
102
|
-
): string[] {
|
|
103
|
-
return frozen.filter((f) => {
|
|
104
|
-
const src = files.get(f);
|
|
105
|
-
return src === undefined || importsAgentApi(f, src);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
83
|
/** Every harness-named file git knows about (tracked, or new and not ignored), with its source. */
|
|
110
84
|
function harnessesOnDisk(): Map<string, string> {
|
|
111
85
|
const listed = execFileSync(
|
|
@@ -120,14 +94,9 @@ function harnessesOnDisk(): Map<string, string> {
|
|
|
120
94
|
);
|
|
121
95
|
}
|
|
122
96
|
|
|
123
|
-
test("every harness imports vigiles' agent-testing API
|
|
97
|
+
test("every harness imports vigiles' agent-testing API", () => {
|
|
124
98
|
// Guards: the rule on the real tree — a new plain test named `*.harness.*` turns this red.
|
|
125
|
-
assert.deepEqual(misnamed(harnessesOnDisk()
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test("the frozen list only shrinks", () => {
|
|
129
|
-
// Guards: a renamed, deleted or converted harness must leave the list, or it stops meaning anything.
|
|
130
|
-
assert.deepEqual(mustLeave(harnessesOnDisk(), FROZEN), []);
|
|
99
|
+
assert.deepEqual(misnamed(harnessesOnDisk()), []);
|
|
131
100
|
});
|
|
132
101
|
|
|
133
102
|
test("both halves, on planted files", () => {
|
|
@@ -143,15 +112,7 @@ test("both halves, on planted files", () => {
|
|
|
143
112
|
["src/z.test.ts", plain],
|
|
144
113
|
]);
|
|
145
114
|
// Guards: the fire half — a plain test named as a harness fails EVEN inside skills/.
|
|
146
|
-
assert.deepEqual(misnamed(files
|
|
147
|
-
// Guards: a file that is on the list but now imports the API has to leave it.
|
|
148
|
-
assert.deepEqual(mustLeave(files, ["src/y.harness.mjs"]), [
|
|
149
|
-
"src/y.harness.mjs",
|
|
150
|
-
]);
|
|
151
|
-
// Guards: an entry whose file is gone has to leave it.
|
|
152
|
-
assert.deepEqual(mustLeave(files, ["gone.harness.mjs"]), [
|
|
153
|
-
"gone.harness.mjs",
|
|
154
|
-
]);
|
|
115
|
+
assert.deepEqual(misnamed(files), ["skills/x/x.harness.ts"]);
|
|
155
116
|
});
|
|
156
117
|
|
|
157
118
|
test("an import is what counts — not a mention, not a same-named local function", () => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Colocated test for `scripts/rules-see-files.mjs` — the guard against a green zero.
|
|
3
|
-
* Run: `npx vigiles test scripts/rules-see-files.harness.mjs`
|
|
4
3
|
*
|
|
5
4
|
* 🔴 BOTH HALVES, and for this guard the order matters more than usual. Its success state is
|
|
6
5
|
* silence, and silence is exactly the state it was built to distrust: a guard that has only
|
|
@@ -14,6 +13,7 @@
|
|
|
14
13
|
* blind one", not "complained about everything".
|
|
15
14
|
*/
|
|
16
15
|
import assert from "node:assert/strict";
|
|
16
|
+
import { afterAll, it, vi } from "vitest";
|
|
17
17
|
import { ESLint } from "eslint";
|
|
18
18
|
import {
|
|
19
19
|
mkdirSync,
|
|
@@ -26,17 +26,21 @@ import { tmpdir } from "node:os";
|
|
|
26
26
|
import { dirname, join } from "node:path";
|
|
27
27
|
import { fileURLToPath } from "node:url";
|
|
28
28
|
|
|
29
|
+
// A test here lints the whole repository: ~72 s alone, up to 224 s beside the rest of the suite
|
|
30
|
+
// under coverage on 4 cores (measured 2026-11-24), so the limit only catches a hang.
|
|
31
|
+
vi.setConfig({ testTimeout: 600_000 });
|
|
32
|
+
|
|
29
33
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
30
34
|
const ROOT = join(HERE, "..");
|
|
31
35
|
const { rulesSeeFiles } = await import(join(HERE, "rules-see-files.mjs"));
|
|
32
36
|
|
|
33
37
|
const TMP = realpathSync(mkdtempSync(join(tmpdir(), "rules-see-files-")));
|
|
34
|
-
|
|
38
|
+
afterAll(() => rmSync(TMP, { recursive: true, force: true }));
|
|
35
39
|
|
|
36
40
|
// ═════════════════════════════════════════════════════════════════════════════
|
|
37
41
|
// I. QUIET ON THIS REPOSITORY
|
|
38
42
|
// ═════════════════════════════════════════════════════════════════════════════
|
|
39
|
-
{
|
|
43
|
+
it("I. QUIET ON THIS REPOSITORY", async () => {
|
|
40
44
|
const { rules, blind, linted } = await rulesSeeFiles({ cwd: ROOT });
|
|
41
45
|
assert.deepEqual(
|
|
42
46
|
blind,
|
|
@@ -61,12 +65,12 @@ process.on("exit", () => rmSync(TMP, { recursive: true, force: true }));
|
|
|
61
65
|
`\`tex/future-promise\` was enabled for ${tex.files} file(s); the four fixtures alone should ` +
|
|
62
66
|
"exceed that, so its glob is narrower than the test data it is supposed to cover",
|
|
63
67
|
);
|
|
64
|
-
}
|
|
68
|
+
});
|
|
65
69
|
|
|
66
70
|
// ═════════════════════════════════════════════════════════════════════════════
|
|
67
71
|
// II + III. FIRES ON A PLANTED EMPTY GLOB, AND NAMES THE RIGHT RULE
|
|
68
72
|
// ═════════════════════════════════════════════════════════════════════════════
|
|
69
|
-
{
|
|
73
|
+
it("II + III. FIRES ON A PLANTED EMPTY GLOB, AND NAMES THE RIGHT RULE", async () => {
|
|
70
74
|
const project = join(TMP, "planted");
|
|
71
75
|
mkdirSync(project, { recursive: true });
|
|
72
76
|
writeFileSync(join(project, "probe.js"), "export const x = 1;\n");
|
|
@@ -112,4 +116,4 @@ process.on("exit", () => rmSync(TMP, { recursive: true, force: true }));
|
|
|
112
116
|
"the control rule was not credited with the file it does see — the guard reports blindness " +
|
|
113
117
|
"for everything rather than for the blind one",
|
|
114
118
|
);
|
|
115
|
-
}
|
|
119
|
+
});
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* ESLint what the effective config is. A rule enabled for zero linted files is BLIND.
|
|
22
22
|
*
|
|
23
23
|
* Run: `node scripts/rules-see-files.mjs` (exit 1 and a named rule when something is blind)
|
|
24
|
-
* Tested by: `scripts/rules-see-files.
|
|
24
|
+
* Tested by: `scripts/rules-see-files-rule.test.mjs` — both halves, quiet here and firing on a
|
|
25
25
|
* planted empty glob.
|
|
26
26
|
*/
|
|
27
27
|
import { ESLint } from "eslint";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `npm run schema:venue-corpus`: the script writes the schema the parser generates, where it is told.
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { describe, expect, it } from "vitest";
|
|
8
|
+
import { venueCorpusSchemaText } from "../src/adapters/venue-corpus/index.ts";
|
|
9
|
+
import { runNode, useTempDir } from "../test/support.ts";
|
|
10
|
+
|
|
11
|
+
const SCRIPT = join(
|
|
12
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
13
|
+
"venue-corpus-schema.ts",
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
describe("venue-corpus-schema.ts", () => {
|
|
17
|
+
const dir = useTempDir();
|
|
18
|
+
|
|
19
|
+
it("🔴 writes the generated schema to the file it is given", () => {
|
|
20
|
+
const out = join(dir, "papers.schema.json");
|
|
21
|
+
expect(
|
|
22
|
+
runNode(SCRIPT, [out], { nodeArgs: ["--conditions=paperlint-source"] }),
|
|
23
|
+
).toEqual({ status: 0, stdout: "", stderr: "" });
|
|
24
|
+
expect(readFileSync(out, "utf8")).toBe(venueCorpusSchemaText());
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("no output file, or more than one: the usage, exit 2, nothing written", () => {
|
|
28
|
+
const usage = {
|
|
29
|
+
status: 2,
|
|
30
|
+
stdout: "",
|
|
31
|
+
stderr: "usage: node venue-corpus-schema.ts <output-file>\n",
|
|
32
|
+
};
|
|
33
|
+
const opts = { nodeArgs: ["--conditions=paperlint-source"] };
|
|
34
|
+
expect(runNode(SCRIPT, [], opts)).toEqual(usage);
|
|
35
|
+
expect(runNode(SCRIPT, [join(dir, "a"), join(dir, "b")], opts)).toEqual(
|
|
36
|
+
usage,
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
});
|