paperlint 20.1.1 → 20.1.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/.github/workflows/ci.yml +7 -0
- package/CLAUDE.md +2 -2
- package/CONTRIBUTING.md +2 -2
- package/{action.harness.mjs → action.test.mjs} +147 -138
- 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/docs/e2e.md +9 -9
- package/docs/testing.md +3 -4
- 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 +3 -3
- package/presets/acm-acmsmall.jsonc +1 -1
- 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/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/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/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/src/adapters/pdfjs/fill.test.ts +1 -1
- 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/{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/{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
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* Both halves for the `paperlint lint` utility, and separately — failures, each
|
|
3
3
|
* of which must be EXPLAINABLE, not just nonzero.
|
|
4
4
|
*
|
|
5
|
+
* An end-to-end test of paperlint's own CLI (it was `cli.harness.mjs`, named so only because
|
|
6
|
+
* `npm test` once ran `vigiles test` alone; it imports nothing from vigiles). It stays `.mjs`, in
|
|
7
|
+
* its original order, so the move from the harness is reviewable with whitespace hidden; typing it
|
|
8
|
+
* is follow-up work under #77.
|
|
9
|
+
*
|
|
5
10
|
* 🔴 Two of the defects checked here the utility already had, and both were found by the
|
|
6
11
|
* FIRST run, not by reading:
|
|
7
12
|
* 1. `paperlint --help` used to answer "unknown command `--help`" — argv[0] unconditionally became
|
|
@@ -12,6 +17,7 @@
|
|
|
12
17
|
* Both are pinned down by the assertions below so there is no going back.
|
|
13
18
|
*/
|
|
14
19
|
import { load as yamlLoad } from "js-yaml";
|
|
20
|
+
import { expect, it } from "vitest";
|
|
15
21
|
import {
|
|
16
22
|
mkdtempSync,
|
|
17
23
|
mkdirSync,
|
|
@@ -29,19 +35,28 @@ import { tmpdir } from "node:os";
|
|
|
29
35
|
import { join, dirname } from "node:path";
|
|
30
36
|
import { fileURLToPath } from "node:url";
|
|
31
37
|
import { PAPERS_DIR_FIELD, findProjectRoot } from "../lib/paper-config.ts";
|
|
32
|
-
import { createChecker } from "../lib/check.ts";
|
|
33
38
|
|
|
34
39
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
35
40
|
const { run, parseArgs, buildConfig, nextSteps, runHook } = await import(
|
|
36
41
|
join(HERE, "cli.ts")
|
|
37
42
|
);
|
|
38
|
-
const {
|
|
39
|
-
|
|
43
|
+
const {
|
|
44
|
+
init,
|
|
45
|
+
choosePapers,
|
|
46
|
+
offerWorkflow,
|
|
47
|
+
missingPrograms,
|
|
48
|
+
interactivity,
|
|
49
|
+
WORKFLOW_PATH,
|
|
50
|
+
} = await import(join(HERE, "init.ts"));
|
|
40
51
|
const { PROGRAMS } = await import(join(HERE, "doctor.ts"));
|
|
41
52
|
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
const check =
|
|
53
|
+
// A failed check stops its test with the label (and the detail) as the message, as the harness's
|
|
54
|
+
// own checker threw: a later check in a block never runs on a state an earlier one found wrong.
|
|
55
|
+
const check = (label, cond, detail) =>
|
|
56
|
+
expect(
|
|
57
|
+
Boolean(cond),
|
|
58
|
+
detail === undefined ? label : `${label}\n${String(detail)}`,
|
|
59
|
+
).toBe(true);
|
|
45
60
|
|
|
46
61
|
/**
|
|
47
62
|
* init's `Prompts` port answered by `reply(message, options)`: a value, `undefined` (Enter: the
|
|
@@ -84,10 +99,10 @@ async function cli(args, cwd) {
|
|
|
84
99
|
// `out` stays a merged string for text assertions; `stdout` is what actually goes down a pipe.
|
|
85
100
|
const stdout = [];
|
|
86
101
|
const stderr = [];
|
|
87
|
-
const prev = process.cwd();
|
|
88
|
-
if (cwd) process.chdir(cwd);
|
|
89
102
|
try {
|
|
90
103
|
const code = await run(args, {
|
|
104
|
+
// Worker threads cannot `process.chdir`: the directory is handed to `run`.
|
|
105
|
+
...(cwd ? { cwd } : {}),
|
|
91
106
|
log: (...a) => stdout.push(a.join(" ")),
|
|
92
107
|
err: (...a) => stderr.push(a.join(" ")),
|
|
93
108
|
// `init` never spawns a package manager here.
|
|
@@ -119,47 +134,47 @@ async function cli(args, cwd) {
|
|
|
119
134
|
stdout: "",
|
|
120
135
|
stderr: `THREW: ${e?.message ?? e}`,
|
|
121
136
|
};
|
|
122
|
-
} finally {
|
|
123
|
-
process.chdir(prev);
|
|
124
137
|
}
|
|
125
138
|
}
|
|
126
139
|
|
|
127
140
|
// ── argument parsing ───────────────────────────────────────────────────────────────────
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
)
|
|
141
|
+
it("argument parsing", () => {
|
|
142
|
+
check(
|
|
143
|
+
"`--help` as the first argument — is a FLAG, not a command",
|
|
144
|
+
parseArgs(["--help"]).help === true,
|
|
145
|
+
);
|
|
146
|
+
check(
|
|
147
|
+
"and a command is not invented in the process",
|
|
148
|
+
parseArgs(["--help"]).cmd === null,
|
|
149
|
+
);
|
|
150
|
+
check(
|
|
151
|
+
"the path and config are parsed",
|
|
152
|
+
(() => {
|
|
153
|
+
const a = parseArgs(["lint", "papers", "--config", "o.json", "--json"]);
|
|
154
|
+
return (
|
|
155
|
+
a.cmd === "lint" &&
|
|
156
|
+
a.paths[0] === "papers" &&
|
|
157
|
+
a.config === "o.json" &&
|
|
158
|
+
a.json === true
|
|
159
|
+
);
|
|
160
|
+
})(),
|
|
161
|
+
);
|
|
162
|
+
check(
|
|
163
|
+
"the default warning threshold is NEGATIVE — advice does not fail the run",
|
|
164
|
+
parseArgs(["lint"]).maxWarnings === -1,
|
|
165
|
+
);
|
|
166
|
+
check(
|
|
167
|
+
"and it is parsed when named explicitly",
|
|
168
|
+
parseArgs(["lint", "--max-warnings", "0"]).maxWarnings === 0,
|
|
169
|
+
);
|
|
170
|
+
check(
|
|
171
|
+
"the old `--options` spelling keeps working — a flag in someone else's CI is not ours to break",
|
|
172
|
+
parseArgs(["lint", "--options", "o.json"]).config === "o.json",
|
|
173
|
+
);
|
|
174
|
+
});
|
|
160
175
|
|
|
161
176
|
// ── config is assembled, and consumer data gets through ────────────────────────────────────
|
|
162
|
-
{
|
|
177
|
+
it("config is assembled, and consumer data gets through", async () => {
|
|
163
178
|
const cfg = buildConfig({}, null);
|
|
164
179
|
// Blocks with `files` — the global `ignores` block below is not a rule block.
|
|
165
180
|
const ruleBlocks = (c) => c.filter((b) => Array.isArray(b.files));
|
|
@@ -188,23 +203,23 @@ check(
|
|
|
188
203
|
siblings.rules["sibling/frontmatter"] === "warn" &&
|
|
189
204
|
siblings.ignores.some((g) => g.endsWith("siblings/README.md")),
|
|
190
205
|
);
|
|
191
|
-
}
|
|
206
|
+
});
|
|
192
207
|
|
|
193
208
|
// ── failures must be EXPLAINABLE ─────────────────────────────────────────────────────────
|
|
194
|
-
{
|
|
209
|
+
it("`--help` prints usage and exits zero", async () => {
|
|
195
210
|
const r = await cli(["--help"]);
|
|
196
211
|
check(
|
|
197
212
|
"`--help` prints usage and exits zero",
|
|
198
213
|
r.code === 0 && /npx paperlint lint/.test(r.out),
|
|
199
214
|
);
|
|
200
|
-
}
|
|
215
|
+
});
|
|
201
216
|
// ── ONE DECLARATION, READ BY THE SAME THING THAT WRITES IT ─────────────────────────────
|
|
202
217
|
//
|
|
203
218
|
// 🔴 WITHOUT THIS BLOCK `init` COULD PRODUCE A BROKEN INSTALL. It writes one declaration, into
|
|
204
219
|
// the root `paperlint.json` — the file the hooks read at `$CLAUDE_PROJECT_DIR`. If the utility
|
|
205
220
|
// read another file, the install command and the check command would be looking at different
|
|
206
221
|
// files — exactly the defect it exists to close, just from the other side.
|
|
207
|
-
{
|
|
222
|
+
it("one declaration, read by the same thing that writes it", async () => {
|
|
208
223
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-carrier-")));
|
|
209
224
|
try {
|
|
210
225
|
const paper = join(root, "papers", "p1");
|
|
@@ -280,7 +295,7 @@ check(
|
|
|
280
295
|
} finally {
|
|
281
296
|
rmSync(root, { recursive: true, force: true });
|
|
282
297
|
}
|
|
283
|
-
}
|
|
298
|
+
});
|
|
284
299
|
|
|
285
300
|
// ── `init` — THREE ACTIONS INSTEAD OF NINE ────────────────────────────────────────────────
|
|
286
301
|
//
|
|
@@ -293,7 +308,7 @@ check(
|
|
|
293
308
|
// ⚠️ Questions here are NOT ASKED blind: `interactive` is passed explicitly, never read from
|
|
294
309
|
// stdin. A harness stuck at an input prompt is not a red test, it is the absence of any answer
|
|
295
310
|
// at all.
|
|
296
|
-
{
|
|
311
|
+
it("`init` \u2014 three actions instead of nine", async () => {
|
|
297
312
|
const workRoot = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-init-")));
|
|
298
313
|
const project = (
|
|
299
314
|
name,
|
|
@@ -632,7 +647,7 @@ check(
|
|
|
632
647
|
|
|
633
648
|
// ── 7-bis. THE SKILLS: WHAT WAS LINKED, AND WHAT WAS LEFT ALONE, BY NAME ────────────
|
|
634
649
|
//
|
|
635
|
-
// The links themselves are `link-skills.
|
|
650
|
+
// The links themselves are `link-skills-fs.test.ts`'s subject. Here: init REPORTS them, and
|
|
636
651
|
// a name it refused to take does not turn a working install red. The state is handed in so
|
|
637
652
|
// this block does not depend on a package being installed next to the temp project.
|
|
638
653
|
{
|
|
@@ -683,15 +698,15 @@ check(
|
|
|
683
698
|
} finally {
|
|
684
699
|
rmSync(workRoot, { recursive: true, force: true });
|
|
685
700
|
}
|
|
686
|
-
}
|
|
687
|
-
{
|
|
701
|
+
});
|
|
702
|
+
it("an unknown command is named", async () => {
|
|
688
703
|
const r = await cli(["frobnicate"]);
|
|
689
704
|
check(
|
|
690
705
|
"an unknown command is NAMED",
|
|
691
706
|
r.code === 2 && /unknown command `frobnicate`/.test(r.out),
|
|
692
707
|
);
|
|
693
|
-
}
|
|
694
|
-
{
|
|
708
|
+
});
|
|
709
|
+
it("a flag with no value is a failure, not a silent default", async () => {
|
|
695
710
|
// A flag with no value. The defect was found by the compiler while porting to TypeScript:
|
|
696
711
|
// `rest[++i]` past the last argument gives undefined, and `--config` with no value silently
|
|
697
712
|
// meant "no config was set" — i.e. an autodiscovered file instead of the named one.
|
|
@@ -700,8 +715,8 @@ check(
|
|
|
700
715
|
"a flag with no value — a FAILURE, not a silent default",
|
|
701
716
|
r.code === 2 && /--config needs a value/.test(r.out),
|
|
702
717
|
);
|
|
703
|
-
}
|
|
704
|
-
{
|
|
718
|
+
});
|
|
719
|
+
it("`lint` with no path, no config and no papers/ refuses and names both ways out", async () => {
|
|
705
720
|
// A "." default would give a green run over whatever happens to be lying around. The default
|
|
706
721
|
// is `papers/`, and an empty directory with no config has none: a refusal naming BOTH ways out.
|
|
707
722
|
const bare = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-bare-")));
|
|
@@ -717,10 +732,10 @@ check(
|
|
|
717
732
|
} finally {
|
|
718
733
|
rmSync(bare, { recursive: true, force: true });
|
|
719
734
|
}
|
|
720
|
-
}
|
|
735
|
+
});
|
|
721
736
|
|
|
722
737
|
// ── on live files: both halves ───────────────────────────────────────────────────────
|
|
723
|
-
{
|
|
738
|
+
it("on live files: both halves", async () => {
|
|
724
739
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-cli-")));
|
|
725
740
|
try {
|
|
726
741
|
const paper = join(root, "papers", "p1");
|
|
@@ -799,7 +814,7 @@ check(
|
|
|
799
814
|
} finally {
|
|
800
815
|
rmSync(root, { recursive: true, force: true });
|
|
801
816
|
}
|
|
802
|
-
}
|
|
817
|
+
});
|
|
803
818
|
|
|
804
819
|
// ── THE CONFIG FINDS ITSELF, AND THE PAPERS DIRECTORY IS DECLARED IN IT ──────────────────
|
|
805
820
|
//
|
|
@@ -807,7 +822,7 @@ check(
|
|
|
807
822
|
// it via an explicit `--options`. I.e. the file the utility itself created had no effect on the
|
|
808
823
|
// run — and there was no way to find that out: zero typography debt looks exactly like a
|
|
809
824
|
// config that was never found.
|
|
810
|
-
{
|
|
825
|
+
it("the config finds itself, and the papers directory is declared in it", async () => {
|
|
811
826
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-cfg-")));
|
|
812
827
|
try {
|
|
813
828
|
const paper = join(root, "papers", "p1");
|
|
@@ -907,14 +922,14 @@ check(
|
|
|
907
922
|
} finally {
|
|
908
923
|
rmSync(root, { recursive: true, force: true });
|
|
909
924
|
}
|
|
910
|
-
}
|
|
925
|
+
});
|
|
911
926
|
|
|
912
927
|
// ── THE WARNING THRESHOLD ───────────────────────────────────────────────────────────────
|
|
913
928
|
//
|
|
914
929
|
// The action has a `max-warnings` input, and once the action stopped calling eslint directly,
|
|
915
930
|
// the threshold had to show up here too — otherwise it would have been lost SILENTLY: the run
|
|
916
931
|
// would stay green, and the consumer's setting would stop meaning anything.
|
|
917
|
-
{
|
|
932
|
+
it("the warning threshold", async () => {
|
|
918
933
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-warn-")));
|
|
919
934
|
try {
|
|
920
935
|
const paper = join(root, "papers", "p1");
|
|
@@ -964,14 +979,14 @@ check(
|
|
|
964
979
|
} finally {
|
|
965
980
|
rmSync(root, { recursive: true, force: true });
|
|
966
981
|
}
|
|
967
|
-
}
|
|
982
|
+
});
|
|
968
983
|
|
|
969
984
|
// ── STRUCTURE GETS THROUGH TO THE COMMAND ──────────────────────────────────────────────
|
|
970
985
|
//
|
|
971
|
-
// `structure.mjs` is checked separately and in full (`structure.
|
|
986
|
+
// `structure.mjs` is checked separately and in full (`structure.test.ts`). Here — exactly
|
|
972
987
|
// one fact that harness cannot know: that the module is WIRED IN. A correct module forgotten in
|
|
973
988
|
// `run()` gives zero findings and looks like a clean corpus.
|
|
974
|
-
{
|
|
989
|
+
it("structure gets through to the command", async () => {
|
|
975
990
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-wired-")));
|
|
976
991
|
try {
|
|
977
992
|
const paper = join(root, "papers", "orphan");
|
|
@@ -1042,7 +1057,7 @@ check(
|
|
|
1042
1057
|
} finally {
|
|
1043
1058
|
rmSync(root, { recursive: true, force: true });
|
|
1044
1059
|
}
|
|
1045
|
-
}
|
|
1060
|
+
});
|
|
1046
1061
|
|
|
1047
1062
|
// ── THE PAPERS DO NOT HAVE TO LIVE UNDER THE CURRENT DIRECTORY (#48) ─────────────────────
|
|
1048
1063
|
//
|
|
@@ -1055,7 +1070,7 @@ check(
|
|
|
1055
1070
|
// Second half: the typography debt is keyed by the paper's path FROM THE CONFIG'S DIRECTORY
|
|
1056
1071
|
// (`"papers/p"`). Keys are computed against ESLint's `cwd`, so a run started from a
|
|
1057
1072
|
// subdirectory, or with `--config` from elsewhere, silently stopped honouring the debt.
|
|
1058
|
-
{
|
|
1073
|
+
it("the papers do not have to live under the current directory (#48)", async () => {
|
|
1059
1074
|
// A message that names the paper's own `paperlint.json` names it as the reader typed it, so
|
|
1060
1075
|
// relative to where the run started: that path is the run's, like the file paths, and is masked.
|
|
1061
1076
|
const findings = (r) => {
|
|
@@ -1156,10 +1171,10 @@ check(
|
|
|
1156
1171
|
rmSync(tree, { recursive: true, force: true });
|
|
1157
1172
|
rmSync(elsewhere, { recursive: true, force: true });
|
|
1158
1173
|
}
|
|
1159
|
-
}
|
|
1174
|
+
});
|
|
1160
1175
|
|
|
1161
1176
|
// ── `paperlint hook` with no name or an unknown one — said, and never a denial (#324) ─────────
|
|
1162
|
-
{
|
|
1177
|
+
it("`paperlint hook` with no name or an unknown one is said, and never a denial (#324)", async () => {
|
|
1163
1178
|
let said = "";
|
|
1164
1179
|
const err = (...a) => {
|
|
1165
1180
|
said += a.join(" ") + "\n";
|
|
@@ -1177,7 +1192,7 @@ check(
|
|
|
1177
1192
|
said,
|
|
1178
1193
|
),
|
|
1179
1194
|
);
|
|
1180
|
-
}
|
|
1195
|
+
});
|
|
1181
1196
|
|
|
1182
1197
|
// ── RUNNING THROUGH A SYMLINK — the only way a consumer ever calls the utility ───────
|
|
1183
1198
|
//
|
|
@@ -1185,7 +1200,7 @@ check(
|
|
|
1185
1200
|
// against `file://${process.argv[1]}`: for a symlink those two paths are DIFFERENT, the
|
|
1186
1201
|
// condition is false, and the utility silently exited zero. A direct `node bin/paperlint.mjs` worked
|
|
1187
1202
|
// fine, meanwhile — i.e. the defect was invisible in exactly the way it is normally checked.
|
|
1188
|
-
{
|
|
1203
|
+
it("running through a symlink, the only way a consumer calls the utility", async () => {
|
|
1189
1204
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-link-")));
|
|
1190
1205
|
try {
|
|
1191
1206
|
const link = join(root, "paperlint-shim");
|
|
@@ -1209,13 +1224,13 @@ check(
|
|
|
1209
1224
|
} finally {
|
|
1210
1225
|
rmSync(root, { recursive: true, force: true });
|
|
1211
1226
|
}
|
|
1212
|
-
}
|
|
1227
|
+
});
|
|
1213
1228
|
|
|
1214
1229
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
1215
1230
|
// `paperlint hook paper-folder-layout` the way Claude Code runs it: the payload on stdin, the answer
|
|
1216
1231
|
// on stdout, through the real bin. The in-process tests inject both streams; this is the one place
|
|
1217
1232
|
// the defaults are read and written for real.
|
|
1218
|
-
{
|
|
1233
|
+
it("`paperlint hook paper-folder-layout` through the real bin", async () => {
|
|
1219
1234
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-hook-")));
|
|
1220
1235
|
try {
|
|
1221
1236
|
const paper = join(root, "papers", "p");
|
|
@@ -1251,14 +1266,14 @@ check(
|
|
|
1251
1266
|
} finally {
|
|
1252
1267
|
rmSync(root, { recursive: true, force: true });
|
|
1253
1268
|
}
|
|
1254
|
-
}
|
|
1269
|
+
});
|
|
1255
1270
|
|
|
1256
1271
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
1257
1272
|
// `paperlint hook lint-edited` the way Claude Code runs it, through the real bin — and the bin's
|
|
1258
1273
|
// fast path: an edit outside every paper is answered before the CLI (and ESLint) is ever loaded. A
|
|
1259
1274
|
// preload records every module resolved to the CLI or into ESLint, so "never loaded" is observed,
|
|
1260
1275
|
// and the edit inside a paper is the control that the probe sees a load when there is one.
|
|
1261
|
-
{
|
|
1276
|
+
it("`paperlint hook lint-edited` through the real bin, and its fast path", async () => {
|
|
1262
1277
|
const root = realpathSync(
|
|
1263
1278
|
mkdtempSync(join(tmpdir(), "paperlint-lint-edited-")),
|
|
1264
1279
|
);
|
|
@@ -1332,17 +1347,13 @@ check(
|
|
|
1332
1347
|
} finally {
|
|
1333
1348
|
rmSync(root, { recursive: true, force: true });
|
|
1334
1349
|
}
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
console.log(
|
|
1338
|
-
`✓ ${String(check.count)} assertions passed — paperlint lint, one command instead of hand-rolled config`,
|
|
1339
|
-
);
|
|
1350
|
+
});
|
|
1340
1351
|
|
|
1341
1352
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
1342
1353
|
// What is left after init is typed in THE SAME TERMINAL. The two `/plugin` lines are gone: the
|
|
1343
|
-
// hooks are written into `.claude/settings.json` by init itself (hooks-settings.
|
|
1354
|
+
// hooks are written into `.claude/settings.json` by init itself (hooks-settings.test.ts).
|
|
1344
1355
|
|
|
1345
|
-
{
|
|
1356
|
+
it("what is left after init is typed in the same terminal", async () => {
|
|
1346
1357
|
const steps = nextSteps("papers");
|
|
1347
1358
|
check(
|
|
1348
1359
|
"🔴 no /plugin line is left — nothing is typed into another program any more",
|
|
@@ -1353,11 +1364,10 @@ console.log(
|
|
|
1353
1364
|
"it names the two commands that ARE left: new and lint",
|
|
1354
1365
|
/npx paperlint new <name>/.test(steps) && /npx paperlint lint/.test(steps),
|
|
1355
1366
|
);
|
|
1356
|
-
}
|
|
1367
|
+
});
|
|
1357
1368
|
|
|
1358
1369
|
// ── the mode decision: a human is at the other end only when EVERY signal says so ──────────
|
|
1359
|
-
{
|
|
1360
|
-
const { interactivity } = await import(join(HERE, "init.ts"));
|
|
1370
|
+
it("the mode decision: a human is at the other end only when every signal says so", async () => {
|
|
1361
1371
|
const tty = { stdinTTY: true, stdoutTTY: true, env: {}, yes: false };
|
|
1362
1372
|
check(
|
|
1363
1373
|
"a terminal on stdin AND stdout, no CI, no --yes → interactive",
|
|
@@ -1383,10 +1393,10 @@ console.log(
|
|
|
1383
1393
|
"an empty CI variable is not CI",
|
|
1384
1394
|
interactivity({ ...tty, env: { CI: "" } }).interactive === true,
|
|
1385
1395
|
);
|
|
1386
|
-
}
|
|
1396
|
+
});
|
|
1387
1397
|
|
|
1388
1398
|
// ── the new flags parse, and none of them becomes the directory argument ─────────────────
|
|
1389
|
-
{
|
|
1399
|
+
it("the new flags parse, and none of them becomes the directory argument", async () => {
|
|
1390
1400
|
const a = parseArgs(["init", "--yes", "--no-hooks", "--paper", "demo"]);
|
|
1391
1401
|
check(
|
|
1392
1402
|
"init flags parse into fields, not into paths",
|
|
@@ -1402,10 +1412,10 @@ console.log(
|
|
|
1402
1412
|
"🔴 --hooks=local is NOT implemented, and it is refused by name rather than read as a path",
|
|
1403
1413
|
r.code === 2 && /--hooks=local is not implemented/.test(r.out),
|
|
1404
1414
|
);
|
|
1405
|
-
}
|
|
1415
|
+
});
|
|
1406
1416
|
|
|
1407
1417
|
// ── init wires the hooks, and a human can say no ─────────────────────────────────────────
|
|
1408
|
-
{
|
|
1418
|
+
it("init wires the hooks, and a human can say no", async () => {
|
|
1409
1419
|
const root = realpathSync(
|
|
1410
1420
|
mkdtempSync(join(tmpdir(), "paperlint-init-hooks-")),
|
|
1411
1421
|
);
|
|
@@ -1494,10 +1504,10 @@ console.log(
|
|
|
1494
1504
|
} finally {
|
|
1495
1505
|
rmSync(root, { recursive: true, force: true });
|
|
1496
1506
|
}
|
|
1497
|
-
}
|
|
1507
|
+
});
|
|
1498
1508
|
|
|
1499
1509
|
// ── init offers a first paper only where there is none, and only to a human ─────────────
|
|
1500
|
-
{
|
|
1510
|
+
it("init offers a first paper only where there is none, and only to a human", async () => {
|
|
1501
1511
|
const root = realpathSync(
|
|
1502
1512
|
mkdtempSync(join(tmpdir(), "paperlint-init-paper-")),
|
|
1503
1513
|
);
|
|
@@ -1647,10 +1657,10 @@ console.log(
|
|
|
1647
1657
|
} finally {
|
|
1648
1658
|
rmSync(root, { recursive: true, force: true });
|
|
1649
1659
|
}
|
|
1650
|
-
}
|
|
1660
|
+
});
|
|
1651
1661
|
|
|
1652
1662
|
// ── `paperlint lint` does not sweep the project's paper TEMPLATE as a paper ────────────────────
|
|
1653
|
-
{
|
|
1663
|
+
it("`paperlint lint` does not sweep the project's paper template as a paper", async () => {
|
|
1654
1664
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-template-")));
|
|
1655
1665
|
try {
|
|
1656
1666
|
writeFileSync(
|
|
@@ -1689,10 +1699,10 @@ console.log(
|
|
|
1689
1699
|
} finally {
|
|
1690
1700
|
rmSync(root, { recursive: true, force: true });
|
|
1691
1701
|
}
|
|
1692
|
-
}
|
|
1702
|
+
});
|
|
1693
1703
|
|
|
1694
1704
|
// ── `paperlint new` through the CLI: the papers directory comes from the one declaration ────────
|
|
1695
|
-
{
|
|
1705
|
+
it("`paperlint new` through the CLI: the papers directory comes from the one declaration", async () => {
|
|
1696
1706
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-new-cli-")));
|
|
1697
1707
|
try {
|
|
1698
1708
|
const none = await cli(["new", "first"], root);
|
|
@@ -1736,10 +1746,10 @@ console.log(
|
|
|
1736
1746
|
} finally {
|
|
1737
1747
|
rmSync(root, { recursive: true, force: true });
|
|
1738
1748
|
}
|
|
1739
|
-
}
|
|
1749
|
+
});
|
|
1740
1750
|
|
|
1741
1751
|
// ── the settings are parsed at the boundary: unknown keys, `rules` blocks ─────────────────
|
|
1742
|
-
{
|
|
1752
|
+
it("the settings are parsed at the boundary: unknown keys, `rules` blocks", async () => {
|
|
1743
1753
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-settings-")));
|
|
1744
1754
|
try {
|
|
1745
1755
|
const dir = join(root, "papers", "p");
|
|
@@ -1845,8 +1855,4 @@ console.log(
|
|
|
1845
1855
|
} finally {
|
|
1846
1856
|
rmSync(root, { recursive: true, force: true });
|
|
1847
1857
|
}
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
console.log(
|
|
1851
|
-
`✓ ${String(check.count)} assertions in total, including init's hooks and paperlint new`,
|
|
1852
|
-
);
|
|
1858
|
+
});
|
package/src/cli.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* cli.ts paths the
|
|
2
|
+
* cli.ts paths the end-to-end test (src/cli-e2e.test.mjs) does not reach: argument parsing of the flags
|
|
3
3
|
* `build`/`toolchain` take, the root settings' refusals, `build` and `new` refusing before any
|
|
4
4
|
* work, the hook runner when its runtime is broken, and venue choice by path and by prefix. Each
|
|
5
5
|
* case runs `run()` in-process with its own `cwd` and compares the whole code and output.
|