paperlint 20.4.0 → 20.6.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/dist/adapters/venue-corpus/index.d.ts.map +1 -1
- package/dist/adapters/venue-corpus/index.js +9 -2
- package/dist/adapters/venue-corpus/index.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +61 -26
- package/dist/cli.js.map +1 -1
- package/dist/corpus-json-rules.d.ts +6 -0
- package/dist/corpus-json-rules.d.ts.map +1 -0
- package/dist/corpus-json-rules.js +15 -0
- package/dist/corpus-json-rules.js.map +1 -0
- package/dist/corpus-layout-rule.d.ts +11 -0
- package/dist/corpus-layout-rule.d.ts.map +1 -0
- package/dist/corpus-layout-rule.js +92 -0
- package/dist/corpus-layout-rule.js.map +1 -0
- package/dist/corpus-licence-rule.d.ts +27 -0
- package/dist/corpus-licence-rule.d.ts.map +1 -0
- package/dist/corpus-licence-rule.js +78 -0
- package/dist/corpus-licence-rule.js.map +1 -0
- package/dist/corpus-record-rule.d.ts +2 -0
- package/dist/corpus-record-rule.d.ts.map +1 -1
- package/dist/corpus-record-rule.js +6 -3
- package/dist/corpus-record-rule.js.map +1 -1
- package/dist/domain/corpus-layout.d.ts +30 -0
- package/dist/domain/corpus-layout.d.ts.map +1 -0
- package/dist/domain/corpus-layout.js +101 -0
- package/dist/domain/corpus-layout.js.map +1 -0
- package/dist/domain/corpus-licence.d.ts +23 -0
- package/dist/domain/corpus-licence.d.ts.map +1 -0
- package/dist/domain/corpus-licence.js +50 -0
- package/dist/domain/corpus-licence.js.map +1 -0
- package/dist/domain/corpus-record.d.ts +8 -0
- package/dist/domain/corpus-record.d.ts.map +1 -1
- package/dist/domain/corpus-record.js +11 -9
- package/dist/domain/corpus-record.js.map +1 -1
- package/dist/domain/edition.d.ts +3 -1
- package/dist/domain/edition.d.ts.map +1 -1
- package/dist/domain/edition.js +6 -2
- package/dist/domain/edition.js.map +1 -1
- package/dist/domain/licence.d.ts +1 -1
- package/dist/domain/licence.d.ts.map +1 -1
- package/dist/domain/licence.js +2 -2
- package/dist/domain/licence.js.map +1 -1
- package/dist/domain/paper-layout.d.ts +3 -2
- package/dist/domain/paper-layout.d.ts.map +1 -1
- package/dist/domain/paper-layout.js +3 -2
- package/dist/domain/paper-layout.js.map +1 -1
- package/dist/paper-files.d.ts +11 -4
- package/dist/paper-files.d.ts.map +1 -1
- package/dist/paper-files.js +16 -2
- package/dist/paper-files.js.map +1 -1
- package/dist/skill-chunks/chunk-QPWFSYJG.js +17 -0
- package/dist/skill-chunks/{chunk-6YEM4VDI.js → chunk-WYQTXKNM.js} +1 -1
- package/docs/design/venue-corpus.md +16 -16
- package/docs/layout.md +2 -2
- package/docs/optional-rules.md +11 -10
- package/docs/rules/corpus/allowed-files-only.md +99 -0
- package/docs/rules/corpus/licence.md +125 -0
- package/docs/rules/corpus/record.md +10 -6
- package/docs/rules.md +3 -1
- package/docs/venues.md +14 -11
- package/package.json +1 -1
- package/skills/argument-arc/scripts/headings.js +2 -2
- package/skills/cold-read-diff/scripts/cold-read.js +5 -5
- package/skills/paper-pipeline/scripts/extract-ref-facts.js +3 -3
- package/skills/pc-panel-review/scripts/prior-reviews.js +2 -1
- package/skills/study-accepted-papers/SKILL.md +4 -3
- package/skills/study-accepted-papers/SKILL.md.spec.ts +3 -2
- package/skills/study-accepted-papers/papers.schema.json +2 -2
- package/skills/study-accepted-papers/scripts/corpus-licences.js +15 -3
- package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +1 -1
- package/skills/verify-citations/scripts/bib-authors.js +3 -3
- package/skills/verify-citations/scripts/verify-cites.js +3 -3
- package/src/adapters/venue-corpus/index.test.ts +25 -0
- package/src/adapters/venue-corpus/index.ts +16 -2
- package/src/cli-e2e.test.mjs +2 -2
- package/src/cli.ts +75 -26
- package/src/corpus-json-rules.ts +22 -0
- package/src/corpus-layout-rule.test.ts +177 -0
- package/src/corpus-layout-rule.ts +145 -0
- package/src/corpus-licence-rule.test.ts +217 -0
- package/src/corpus-licence-rule.ts +94 -0
- package/src/corpus-record-rule.test.ts +27 -4
- package/src/corpus-record-rule.ts +8 -3
- package/src/domain/corpus-layout.test.ts +118 -0
- package/src/domain/corpus-layout.ts +159 -0
- package/src/domain/corpus-licence.test.ts +128 -0
- package/src/domain/corpus-licence.ts +99 -0
- package/src/domain/corpus-record.test.ts +7 -1
- package/src/domain/corpus-record.ts +26 -9
- package/src/domain/edition.ts +8 -2
- package/src/domain/licence.test.ts +1 -1
- package/src/domain/licence.ts +2 -2
- package/src/domain/paper-layout.ts +3 -2
- package/src/layout-docs.test.ts +3 -1
- package/src/paper-files.ts +19 -3
- package/src/rule-cases.test.ts +6 -70
- package/src/rule-id-shape.test.ts +42 -0
- package/src/unowned-file.test.ts +1 -1
- package/dist/skill-chunks/{chunk-CXAGKT44.js → chunk-EDHTB7KT.js} +4 -4
package/src/rule-cases.test.ts
CHANGED
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
* `EXEMPT` with the reason; a case for a rule that is not registered fails too. A `_build/` file a
|
|
11
11
|
* rule reads is planted as the build would write it — no pdflatex, no network.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
14
|
import { dirname, join } from "node:path";
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
import { omit } from "remeda";
|
|
17
17
|
import { describe, expect, it } from "vitest";
|
|
18
|
-
import {
|
|
19
|
-
import { run, rulePlugins } from "./cli.ts";
|
|
18
|
+
import { rulePlugins } from "./cli.ts";
|
|
20
19
|
import { uploadRecordText } from "./domain/artifact-upload.ts";
|
|
21
20
|
import { sha256Hex } from "./domain/sha256.ts";
|
|
22
21
|
import { lockText, type LockEntry } from "./domain/versions.ts";
|
|
@@ -32,7 +31,9 @@ import {
|
|
|
32
31
|
type IndexInput,
|
|
33
32
|
} from "./domain/study-registry.ts";
|
|
34
33
|
import { recordText } from "../test/recorded-fixture.ts";
|
|
35
|
-
import {
|
|
34
|
+
import { lintTree } from "../test/lint-report.ts";
|
|
35
|
+
import { venuePreset } from "../test/support.ts";
|
|
36
|
+
import { CORPUS_CASES, type RuleCases } from "../test/rule-cases-corpus.ts";
|
|
36
37
|
|
|
37
38
|
/** No plan and no history: the index with every mode column `—`. */
|
|
38
39
|
const NO_FACTS: IndexInput = { plans: new Map(), history: new Map() };
|
|
@@ -42,8 +43,6 @@ const fixture = (p: string): string =>
|
|
|
42
43
|
readFileSync(join(ROOT, "fixtures", p), "utf8");
|
|
43
44
|
|
|
44
45
|
const P = "papers/p";
|
|
45
|
-
const CORPUS_RECORD = "papers/venues/agent/papers.json";
|
|
46
|
-
const EMPTY_RECORD = '{"venue":"agent","editions":[],"papers":[],"rebuild":[]}';
|
|
47
46
|
const STATUS = "---\nstages: []\n---\n# PIPELINE-STATUS\n";
|
|
48
47
|
const tex = (body: string, cls = "\\documentclass{article}"): string =>
|
|
49
48
|
`${cls}\n\\begin{document}\n${body}\n\\end{document}\n`;
|
|
@@ -574,19 +573,6 @@ const onTalk = (
|
|
|
574
573
|
|
|
575
574
|
// ── the case table ─────────────────────────────────────────────────────────────────────────────
|
|
576
575
|
|
|
577
|
-
interface Reports {
|
|
578
|
-
readonly tree: Record<string, string | Uint8Array>;
|
|
579
|
-
/** The file the finding is on, relative to the project. */
|
|
580
|
-
readonly file: string;
|
|
581
|
-
readonly severity: 1 | 2;
|
|
582
|
-
readonly line: number;
|
|
583
|
-
}
|
|
584
|
-
interface RuleCases {
|
|
585
|
-
readonly reports: Reports;
|
|
586
|
-
/** A tree on which the rule says nothing, on any file. */
|
|
587
|
-
readonly silent: Record<string, string | Uint8Array>;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
576
|
const TEX_FILE = `${P}/paper.tex`;
|
|
591
577
|
|
|
592
578
|
/** A body of 200 sentences of 14 words: enough words for `tex/register` to judge a rate. */
|
|
@@ -1282,19 +1268,7 @@ const CASES: Readonly<Record<string, RuleCases>> = {
|
|
|
1282
1268
|
[`${P}/extra/PLAN.md`]: "# plan\n",
|
|
1283
1269
|
}),
|
|
1284
1270
|
},
|
|
1285
|
-
|
|
1286
|
-
"corpus/record": {
|
|
1287
|
-
reports: {
|
|
1288
|
-
tree: paper(tex("x"), {
|
|
1289
|
-
[CORPUS_RECORD]: EMPTY_RECORD,
|
|
1290
|
-
"papers/venues/agent/pdf/a.pdf": "",
|
|
1291
|
-
}),
|
|
1292
|
-
file: CORPUS_RECORD,
|
|
1293
|
-
severity: 2,
|
|
1294
|
-
line: 1,
|
|
1295
|
-
},
|
|
1296
|
-
silent: paper(tex("x"), { [CORPUS_RECORD]: EMPTY_RECORD }),
|
|
1297
|
-
},
|
|
1271
|
+
...CORPUS_CASES,
|
|
1298
1272
|
// A loose script at the top of repro/: it belongs in repro/tools/.
|
|
1299
1273
|
"repro/allowed-files-only": {
|
|
1300
1274
|
reports: {
|
|
@@ -1710,44 +1684,6 @@ const EXEMPT: Readonly<Record<string, string>> = {};
|
|
|
1710
1684
|
|
|
1711
1685
|
// ── the run ─────────────────────────────────────────────────────────────────────────────────────
|
|
1712
1686
|
|
|
1713
|
-
const LintResults = z.array(
|
|
1714
|
-
z.looseObject({
|
|
1715
|
-
filePath: z.string(),
|
|
1716
|
-
messages: z.array(
|
|
1717
|
-
z.looseObject({
|
|
1718
|
-
ruleId: z.string().nullable(),
|
|
1719
|
-
severity: z.number(),
|
|
1720
|
-
line: z.number().optional(),
|
|
1721
|
-
message: z.string(),
|
|
1722
|
-
}),
|
|
1723
|
-
),
|
|
1724
|
-
}),
|
|
1725
|
-
);
|
|
1726
|
-
type Message = z.infer<typeof LintResults>[number]["messages"][number] & {
|
|
1727
|
-
readonly file: string;
|
|
1728
|
-
};
|
|
1729
|
-
|
|
1730
|
-
/** `paperlint lint --json` over the tree, in-process through the CLI: every message, by file. */
|
|
1731
|
-
async function lintTree(
|
|
1732
|
-
tree: Record<string, string | Uint8Array>,
|
|
1733
|
-
emptyDirs: readonly string[] = [],
|
|
1734
|
-
): Promise<Message[]> {
|
|
1735
|
-
const dir = writeTree(useTempDir("paperlint-rule-cases-"), {
|
|
1736
|
-
"package.json": '{"name":"consumer","private":true}',
|
|
1737
|
-
...tree,
|
|
1738
|
-
});
|
|
1739
|
-
emptyDirs.forEach((d) => mkdirSync(join(dir, d), { recursive: true }));
|
|
1740
|
-
const out: string[] = [];
|
|
1741
|
-
await run(["lint", "--json"], {
|
|
1742
|
-
cwd: dir,
|
|
1743
|
-
log: (...a: unknown[]) => out.push(a.join(" ")),
|
|
1744
|
-
err: () => undefined,
|
|
1745
|
-
});
|
|
1746
|
-
return LintResults.parse(JSON.parse(out.join("\n"))).flatMap((r) =>
|
|
1747
|
-
r.messages.map((m) => ({ ...m, file: r.filePath.slice(dir.length + 1) })),
|
|
1748
|
-
);
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
1687
|
/** Every rule id the registry holds. */
|
|
1752
1688
|
const registered = Object.entries(rulePlugins()).flatMap(([plugin, p]) =>
|
|
1753
1689
|
Object.keys(p.rules ?? {}).map((rule) => `${plugin}/${rule}`),
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "A Rule Id Names Its Subject" (eslint-rules/CLAUDE.md): every rule id paperlint registers is
|
|
3
|
+
* `<family>/<rule>`, one slash, kebab-case. The ids are read off the registry `paperlint lint`
|
|
4
|
+
* builds (`rulePlugins`), every family, so a rule registered tomorrow is judged the day it exists.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { rulePlugins } from "./cli.ts";
|
|
8
|
+
|
|
9
|
+
/** One slash, a kebab-case family and a kebab-case rule. */
|
|
10
|
+
const SHAPE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;
|
|
11
|
+
|
|
12
|
+
/** Every id the registry holds, `<plugin>/<rule>`. */
|
|
13
|
+
const registered = Object.entries(rulePlugins()).flatMap(([plugin, p]) =>
|
|
14
|
+
Object.keys(p.rules ?? {}).map((rule) => `${plugin}/${rule}`),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
describe("every registered rule id has the one-slash kebab-case shape", () => {
|
|
18
|
+
it("the registry is read in full: several families, many rules", () => {
|
|
19
|
+
// Guards: an empty registry would make the shape test below pass for nothing.
|
|
20
|
+
expect([...new Set(registered.map((id) => id.split("/")[0]))]).toEqual(
|
|
21
|
+
expect.arrayContaining(["paper", "tex", "corpus", "pdf", "cycle"]),
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("no id breaks the shape", () => {
|
|
26
|
+
expect(registered.filter((id) => !SHAPE.test(id))).toEqual([]);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it.each([
|
|
30
|
+
"tex",
|
|
31
|
+
"corpus/a/b",
|
|
32
|
+
"Corpus/record",
|
|
33
|
+
"corpus/Record",
|
|
34
|
+
"corpus/rec_ord",
|
|
35
|
+
"corpus/-record",
|
|
36
|
+
"corpus/record-",
|
|
37
|
+
"corpus/",
|
|
38
|
+
"/record",
|
|
39
|
+
])("the shape refuses %s", (id) => {
|
|
40
|
+
expect(SHAPE.test(id)).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
});
|
package/src/unowned-file.test.ts
CHANGED
|
@@ -88,7 +88,7 @@ describe("any other unowned file keeps the general refusal, without the glob it
|
|
|
88
88
|
const r = await lint(dir, "papers/a/repro/x.js");
|
|
89
89
|
expect(r.code).toBe(2);
|
|
90
90
|
expect(r.err).toBe(
|
|
91
|
-
"papers/a/repro/x.js is not a file paperlint lints — it lints **/PIPELINE-STATUS.md, **/venues/*/papers.json, **/reviews/*.md, **/paper.tex, **/siblings/*.md, and the .tex files a built paper.tex includes",
|
|
91
|
+
"papers/a/repro/x.js is not a file paperlint lints — it lints **/PIPELINE-STATUS.md, **/venues/*/papers.json, paperlint.json, **/reviews/*.md, **/paper.tex, **/siblings/*.md, and the .tex files a built paper.tex includes",
|
|
92
92
|
);
|
|
93
93
|
});
|
|
94
94
|
|
|
@@ -16,6 +16,10 @@ import {
|
|
|
16
16
|
readWhole,
|
|
17
17
|
venueClass
|
|
18
18
|
} from "./chunk-J5XYPERO.js";
|
|
19
|
+
import {
|
|
20
|
+
err,
|
|
21
|
+
ok
|
|
22
|
+
} from "./chunk-5KCU4WTN.js";
|
|
19
23
|
import {
|
|
20
24
|
countBy,
|
|
21
25
|
hasAtLeast,
|
|
@@ -26,10 +30,6 @@ import {
|
|
|
26
30
|
sortBy,
|
|
27
31
|
zip
|
|
28
32
|
} from "./chunk-C2G5EK7S.js";
|
|
29
|
-
import {
|
|
30
|
-
err,
|
|
31
|
-
ok
|
|
32
|
-
} from "./chunk-5KCU4WTN.js";
|
|
33
33
|
import {
|
|
34
34
|
external_exports
|
|
35
35
|
} from "./chunk-4MHEJ6FR.js";
|