paperlint 20.3.0 → 20.5.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 +2 -2
- package/dist/adapters/venue-corpus/index.d.ts.map +1 -1
- package/dist/adapters/venue-corpus/index.js +15 -3
- package/dist/adapters/venue-corpus/index.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +51 -19
- package/dist/cli.js.map +1 -1
- 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-record-rule.d.ts.map +1 -1
- package/dist/corpus-record-rule.js +2 -1
- 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/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/domain/venue-corpus.d.ts +11 -2
- package/dist/domain/venue-corpus.d.ts.map +1 -1
- package/dist/domain/venue-corpus.js +16 -0
- package/dist/domain/venue-corpus.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/docs/design/venue-corpus.md +17 -16
- package/docs/layout.md +2 -2
- package/docs/rules/corpus/allowed-files-only.md +99 -0
- package/docs/rules/corpus/record.md +7 -3
- package/docs/rules.md +1 -0
- package/docs/venues.md +14 -7
- package/package.json +1 -1
- package/skills/study-accepted-papers/SKILL.md +2 -2
- package/skills/study-accepted-papers/SKILL.md.spec.ts +1 -1
- package/skills/study-accepted-papers/papers.schema.json +1 -0
- package/skills/study-accepted-papers/scripts/corpus-licences.js +21 -2
- package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +1 -0
- package/src/adapters/venue-corpus/index.test.ts +22 -54
- package/src/adapters/venue-corpus/index.ts +15 -2
- package/src/adapters/venue-corpus/schema.test.ts +47 -0
- package/src/cli-e2e.test.mjs +2 -2
- package/src/cli.ts +64 -17
- package/src/corpus-layout-rule.test.ts +177 -0
- package/src/corpus-layout-rule.ts +145 -0
- package/src/corpus-record-rule.test.ts +16 -4
- package/src/corpus-record-rule.ts +2 -1
- package/src/domain/corpus-layout.test.ts +118 -0
- package/src/domain/corpus-layout.ts +159 -0
- package/src/domain/paper-layout.ts +3 -2
- package/src/domain/venue-corpus.test.ts +85 -0
- package/src/domain/venue-corpus.ts +27 -2
- package/src/layout-docs.test.ts +3 -1
- package/src/paper-files.ts +19 -3
- package/src/rule-cases.test.ts +20 -42
- package/src/unowned-file.test.ts +1 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE LAYOUT OF A VENUE CORPUS — what may stand at the top of `<papers-root>/venues/<venue>/`
|
|
3
|
+
* (docs/design/venue-corpus.md, decision 5; docs/rules/corpus/allowed-files-only.md): the record,
|
|
4
|
+
* its caveats, the codes, the stored copies, the deep reads and the pages as they were read. Every
|
|
5
|
+
* other name is reported with where it goes; what the operating system and interpreters leave (the
|
|
6
|
+
* lists `paper-layout.ts` and `repro-layout.ts` never report) is never reported. Only the top is
|
|
7
|
+
* judged: `pdf/` and `text/` are `corpus/record`'s. Pure: the caller lists the folder.
|
|
8
|
+
*/
|
|
9
|
+
import { extname } from "node:path";
|
|
10
|
+
import { leaf, renderTree } from "./layout-tree.ts";
|
|
11
|
+
import {
|
|
12
|
+
IMAGE_EXTENSIONS,
|
|
13
|
+
OS_FILES,
|
|
14
|
+
type LayoutEntry,
|
|
15
|
+
} from "./paper-layout.ts";
|
|
16
|
+
import {
|
|
17
|
+
DATA_EXTENSIONS,
|
|
18
|
+
NOTE_EXTENSIONS,
|
|
19
|
+
REPRO_BYPRODUCTS,
|
|
20
|
+
SCRIPT_EXTENSIONS,
|
|
21
|
+
TOOL_FILES,
|
|
22
|
+
} from "./repro-layout.ts";
|
|
23
|
+
import { CORPUS_RECORD } from "./venue-corpus.ts";
|
|
24
|
+
|
|
25
|
+
/** The names a corpus may hold at its top, files then folders, each with what it holds. */
|
|
26
|
+
const FILE_NOTES: readonly (readonly [string, string])[] = [
|
|
27
|
+
[CORPUS_RECORD, "the record: every paper, each copy of it and its licence"],
|
|
28
|
+
["MANIFEST.md", "optional: caveats only, the prose no field holds"],
|
|
29
|
+
["measurements.json", "the codes of L0 and L1, one row per paper, by key"],
|
|
30
|
+
[".gitignore", "optional: keeps the stored copies out of git"],
|
|
31
|
+
];
|
|
32
|
+
const DIR_NOTES: readonly (readonly [string, string])[] = [
|
|
33
|
+
["pdf", "pdf/<key>.pdf, when a copy's licence permits it"],
|
|
34
|
+
["text", "text/<key>.txt and text/<key>.<variant>.txt"],
|
|
35
|
+
["deep-reads", "deep-reads/<key>.md, one per paper read in full"],
|
|
36
|
+
["sources", "the listing and call pages as they were read"],
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
/** The drawing of a corpus's layout: the rule's message and its page. */
|
|
40
|
+
export const CORPUS_LAYOUT_TREE: string = renderTree(
|
|
41
|
+
"<papers-root>/venues/<venue>/",
|
|
42
|
+
[
|
|
43
|
+
...FILE_NOTES.map(([name, note]) => leaf(name, note)),
|
|
44
|
+
...DIR_NOTES.map(([name, note]) => leaf(`${name}/`, note)),
|
|
45
|
+
],
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
/** Where a folder goes, and a file of a kind no other cure names. */
|
|
49
|
+
export const DIR_CURE =
|
|
50
|
+
"copies of papers into pdf/ or text/, each claimed in papers.json; saved pages into sources/; notes on one paper into deep-reads/<key>.md";
|
|
51
|
+
export const FILE_CURE = `decide by what it is — ${DIR_CURE}; caveats into MANIFEST.md`;
|
|
52
|
+
|
|
53
|
+
/** For a stray file, the place its name or extension says, the first match winning. */
|
|
54
|
+
export const FILE_CURES: readonly {
|
|
55
|
+
readonly names: readonly string[];
|
|
56
|
+
readonly extensions: readonly string[];
|
|
57
|
+
readonly cure: string;
|
|
58
|
+
}[] = [
|
|
59
|
+
{
|
|
60
|
+
names: [],
|
|
61
|
+
extensions: [".pdf"],
|
|
62
|
+
cure: "pdf/<key>.pdf, claimed by its copy in papers.json",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
names: [],
|
|
66
|
+
extensions: [".txt"],
|
|
67
|
+
cure: "text/<key>.txt, claimed by its copy in papers.json",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
names: [],
|
|
71
|
+
extensions: NOTE_EXTENSIONS,
|
|
72
|
+
cure: "MANIFEST.md when it is a caveat about the whole corpus; deep-reads/<key>.md when it is about one paper",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
names: TOOL_FILES,
|
|
76
|
+
extensions: SCRIPT_EXTENSIONS,
|
|
77
|
+
cure: "out of the corpus: the paper's repro/tools/, and the command that runs it into papers.json's `rebuild`",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
names: [],
|
|
81
|
+
extensions: DATA_EXTENSIONS,
|
|
82
|
+
cure: "its rows into papers.json (the papers) or measurements.json (their codes); the list as it was downloaded into sources/",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
names: [],
|
|
86
|
+
extensions: [".html", ".htm", ".mhtml", ...IMAGE_EXTENSIONS],
|
|
87
|
+
cure: "sources/, beside the other pages as they were read",
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
/** An entry at the top of a corpus that is not one of its names (a folder's ends in a slash), with where it goes. */
|
|
92
|
+
export interface CorpusStray {
|
|
93
|
+
readonly name: string;
|
|
94
|
+
readonly cure: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const isAllowed = (e: LayoutEntry): boolean =>
|
|
98
|
+
OS_FILES.includes(e.name) ||
|
|
99
|
+
REPRO_BYPRODUCTS.includes(e.name) ||
|
|
100
|
+
(e.kind === "dir" ? DIR_NOTES : FILE_NOTES).some(([n]) => n === e.name);
|
|
101
|
+
|
|
102
|
+
const fileCure = (name: string): string =>
|
|
103
|
+
FILE_CURES.find(
|
|
104
|
+
(c) =>
|
|
105
|
+
c.names.includes(name) ||
|
|
106
|
+
c.extensions.includes(extname(name).toLowerCase()),
|
|
107
|
+
)?.cure ?? FILE_CURE;
|
|
108
|
+
|
|
109
|
+
/** The entries at the top of a corpus that are not part of its layout, in the order given. Pure. */
|
|
110
|
+
export const judgeCorpusLayout = (
|
|
111
|
+
entries: readonly LayoutEntry[],
|
|
112
|
+
): readonly CorpusStray[] =>
|
|
113
|
+
entries
|
|
114
|
+
.filter((e) => !isAllowed(e))
|
|
115
|
+
.map((e) =>
|
|
116
|
+
e.kind === "dir"
|
|
117
|
+
? { name: `${e.name}/`, cure: DIR_CURE }
|
|
118
|
+
: { name: e.name, cure: fileCure(e.name) },
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
/** Whether a corpus stores copies (`pdf/` or `text/`) and has no `papers.json` to record them. Pure. */
|
|
122
|
+
export const storesWithoutRecord = (entries: readonly LayoutEntry[]): boolean =>
|
|
123
|
+
entries.some((e) => e.kind === "dir" && ["pdf", "text"].includes(e.name)) &&
|
|
124
|
+
!entries.some((e) => e.kind === "file" && e.name === CORPUS_RECORD);
|
|
125
|
+
|
|
126
|
+
const RULE_LINE =
|
|
127
|
+
"Rule corpus/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/corpus/allowed-files-only.md";
|
|
128
|
+
|
|
129
|
+
/** The text a stray is reported with; `corpus` is the corpus folder as the reader sees it. */
|
|
130
|
+
export const corpusStrayMessage = (corpus: string, s: CorpusStray): string =>
|
|
131
|
+
[
|
|
132
|
+
`\`${corpus}/${s.name}\` is not one of the names a venue corpus holds. Where it goes: ${s.cure}.`,
|
|
133
|
+
"What a corpus holds (.DS_Store and what interpreters leave, like __pycache__/, are never reported):",
|
|
134
|
+
CORPUS_LAYOUT_TREE,
|
|
135
|
+
RULE_LINE,
|
|
136
|
+
].join("\n");
|
|
137
|
+
|
|
138
|
+
/** The text a corpus that stores copies without its record is reported with. */
|
|
139
|
+
export const unrecordedMessage = (corpus: string): string =>
|
|
140
|
+
`\`${corpus}/\` stores copies in pdf/ or text/ and has no ${CORPUS_RECORD}, so nothing records which paper each file is a copy of, or under which licence it is kept. What to do: write ${corpus}/${CORPUS_RECORD} (study-accepted-papers writes it; its fields are in papers.schema.json), or remove pdf/ and text/ and keep the papers' ids. ${RULE_LINE}`;
|
|
141
|
+
|
|
142
|
+
/** What `venues/` may hold besides its corpus folders: an index and the agent instruction files. */
|
|
143
|
+
const VENUES_FILES: readonly string[] = ["README.md", "CLAUDE.md", "AGENTS.md"];
|
|
144
|
+
|
|
145
|
+
/** The files loose at the top of `venues/`, in the order given; a folder there is a corpus. Pure. */
|
|
146
|
+
export const judgeVenues = (
|
|
147
|
+
entries: readonly LayoutEntry[],
|
|
148
|
+
): readonly string[] =>
|
|
149
|
+
entries
|
|
150
|
+
.filter(
|
|
151
|
+
(e) =>
|
|
152
|
+
e.kind === "file" &&
|
|
153
|
+
![...VENUES_FILES, ...OS_FILES, ...REPRO_BYPRODUCTS].includes(e.name),
|
|
154
|
+
)
|
|
155
|
+
.map((e) => e.name);
|
|
156
|
+
|
|
157
|
+
/** The text a file loose in `venues/` is reported with; `venues` is the folder as the reader sees it. */
|
|
158
|
+
export const looseMessage = (venues: string, name: string): string =>
|
|
159
|
+
`\`${venues}/${name}\` is a file loose in venues/, which holds one folder per venue corpus, and ${VENUES_FILES.slice(0, -1).join(", ")} or ${VENUES_FILES.slice(-1).join("")}. Where it goes: into the corpus it is about (caveats into its MANIFEST.md, saved pages into its sources/), or out of venues/ when it serves several (a script into a paper's repro/tools/, its command into each ${CORPUS_RECORD}'s \`rebuild\`). ${RULE_LINE}`;
|
|
@@ -319,8 +319,9 @@ export const VENUES_DIR = "venues";
|
|
|
319
319
|
|
|
320
320
|
/**
|
|
321
321
|
* The papers directory as the README and `docs/layout.md` draw it: the venues' corpora beside the
|
|
322
|
-
* paper folders, and each paper folder with its layout.
|
|
323
|
-
*
|
|
322
|
+
* paper folders, and each paper folder with its layout. The paper folder's part is enforced by the two
|
|
323
|
+
* layout rules; each corpus in `venues/` by `corpus/record` and `corpus/allowed-files-only`, whose
|
|
324
|
+
* layout is `corpus-layout.ts`.
|
|
324
325
|
*/
|
|
325
326
|
export const PAPERS_NODES: readonly TreeNode[] = [
|
|
326
327
|
{
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { editionCountIssue, type Edition, type Paper } from "./venue-corpus.ts";
|
|
3
|
+
|
|
4
|
+
const EDITION: Edition = {
|
|
5
|
+
edition: 2026,
|
|
6
|
+
listed_from: "https://example.org/accepted",
|
|
7
|
+
read_on: "2026-11-03",
|
|
8
|
+
accepted: 2,
|
|
9
|
+
capped: null,
|
|
10
|
+
proxy: null,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const row = (
|
|
14
|
+
key: string,
|
|
15
|
+
group: "accepted" | "award",
|
|
16
|
+
edition = 2026,
|
|
17
|
+
): Paper => ({
|
|
18
|
+
key,
|
|
19
|
+
edition,
|
|
20
|
+
group,
|
|
21
|
+
title: key,
|
|
22
|
+
ids: { doi: `10.1/${key}` },
|
|
23
|
+
copies: [],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const SISTER: Paper = {
|
|
27
|
+
key: "other",
|
|
28
|
+
group: "sister",
|
|
29
|
+
venue: "nlbse",
|
|
30
|
+
year: 2026,
|
|
31
|
+
listed_from: "https://example.org/nlbse",
|
|
32
|
+
title: "other",
|
|
33
|
+
ids: { doi: "10.1/other" },
|
|
34
|
+
copies: [],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe("an edition's papers against what it accepted", () => {
|
|
38
|
+
it("🔴 uncapped: the winners and the ordinary papers together are all it accepted", () => {
|
|
39
|
+
// Guards: an award row is one of the accepted papers; a sister or another edition's row is not.
|
|
40
|
+
expect(
|
|
41
|
+
editionCountIssue(EDITION, [
|
|
42
|
+
row("a", "accepted"),
|
|
43
|
+
row("b", "award"),
|
|
44
|
+
row("c", "accepted", 2025),
|
|
45
|
+
SISTER,
|
|
46
|
+
]),
|
|
47
|
+
).toBeNull();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("🔴 uncapped: fewer rows than it accepted is a list copied in part", () => {
|
|
51
|
+
expect(editionCountIssue(EDITION, [row("a", "accepted")])).toBe(
|
|
52
|
+
"1 papers of 2026 are listed and 2 were accepted: list them all, or say in capped what was left out",
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("🔴 uncapped: more rows than it accepted", () => {
|
|
57
|
+
expect(
|
|
58
|
+
editionCountIssue(EDITION, [
|
|
59
|
+
row("a", "accepted"),
|
|
60
|
+
row("b", "accepted"),
|
|
61
|
+
row("c", "award"),
|
|
62
|
+
]),
|
|
63
|
+
).toBe(
|
|
64
|
+
"3 papers of 2026 are listed and 2 were accepted: list them all, or say in capped what was left out",
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("🔴 capped: fewer rows than it accepted is what capped says", () => {
|
|
69
|
+
expect(
|
|
70
|
+
editionCountIssue({ ...EDITION, capped: "the research track only" }, [
|
|
71
|
+
row("a", "accepted"),
|
|
72
|
+
]),
|
|
73
|
+
).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("🔴 capped: still never more rows than it accepted", () => {
|
|
77
|
+
expect(
|
|
78
|
+
editionCountIssue({ ...EDITION, capped: "the research track only" }, [
|
|
79
|
+
row("a", "accepted"),
|
|
80
|
+
row("b", "accepted"),
|
|
81
|
+
row("c", "accepted"),
|
|
82
|
+
]),
|
|
83
|
+
).toBe("3 papers of 2026 are listed, more than the 2 it accepted");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -41,8 +41,11 @@ export interface Edition {
|
|
|
41
41
|
/** The page that lists what the edition accepted. */
|
|
42
42
|
readonly listed_from: string;
|
|
43
43
|
readonly read_on: string;
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* How many it accepted: the rows of the page that lists them. Without `capped` the corpus lists
|
|
46
|
+
* exactly this many of the edition's papers; with it, at most this many.
|
|
47
|
+
*/
|
|
48
|
+
readonly accepted: number;
|
|
46
49
|
/** What was left out of the edition and why; null when nothing was (never left out). */
|
|
47
50
|
readonly capped: string | null;
|
|
48
51
|
/** The stand-in for "strong accept" in this edition; null when it has none. */
|
|
@@ -157,3 +160,25 @@ export const pathText = (path: RecordPath): string =>
|
|
|
157
160
|
/** Every problem on one line, each with its path. */
|
|
158
161
|
export const problemsText = (problems: readonly CorpusProblem[]): string =>
|
|
159
162
|
`${CORPUS_RECORD}: ${problems.map((p) => `${pathText(p.path)}: ${p.message}`).join("; ")}`;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* What an edition lists against what it accepted, or null when they agree: without `capped` its
|
|
166
|
+
* papers (`accepted` and `award` rows; a `sister` is another venue's) number exactly `accepted`,
|
|
167
|
+
* with `capped` at most that many.
|
|
168
|
+
*/
|
|
169
|
+
export const editionCountIssue = (
|
|
170
|
+
edition: Readonly<Edition>,
|
|
171
|
+
papers: readonly Paper[],
|
|
172
|
+
): string | null => {
|
|
173
|
+
const listed = papers.filter(
|
|
174
|
+
(p) => p.group !== "sister" && p.edition === edition.edition,
|
|
175
|
+
).length;
|
|
176
|
+
const tally = `${String(listed)} papers of ${String(edition.edition)} are listed`;
|
|
177
|
+
if (edition.capped === null)
|
|
178
|
+
return listed === edition.accepted
|
|
179
|
+
? null
|
|
180
|
+
: `${tally} and ${String(edition.accepted)} were accepted: list them all, or say in capped what was left out`;
|
|
181
|
+
return listed > edition.accepted
|
|
182
|
+
? `${tally}, more than the ${String(edition.accepted)} it accepted`
|
|
183
|
+
: null;
|
|
184
|
+
};
|
package/src/layout-docs.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The pages draw the layout the code enforces. Each page embeds the drawing between
|
|
3
3
|
* `<!-- layout:begin … -->` and `<!-- layout:end -->`, and that block must equal the render of the
|
|
4
|
-
* constants that decide what is allowed (`PAPER_LAYOUT_TREE`, `REPRO_LAYOUT_TREE`, and
|
|
4
|
+
* constants that decide what is allowed (`PAPER_LAYOUT_TREE`, `REPRO_LAYOUT_TREE`, `CORPUS_LAYOUT_TREE`, and
|
|
5
5
|
* `PAPERS_LAYOUT_TREE`, which draws the paper folder beside the venues' corpora) — so a page cannot
|
|
6
6
|
* show an entry the rule reports, or miss one it allows. Both halves: the committed pages match, and
|
|
7
7
|
* a page with one entry changed or with no block at all does not.
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
PAPER_LAYOUT_TREE,
|
|
18
18
|
PAPERS_LAYOUT_TREE,
|
|
19
19
|
} from "./domain/paper-layout.ts";
|
|
20
|
+
import { CORPUS_LAYOUT_TREE } from "./domain/corpus-layout.ts";
|
|
20
21
|
import { REPRO_LAYOUT_TREE } from "./domain/repro-layout.ts";
|
|
21
22
|
|
|
22
23
|
const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
@@ -24,6 +25,7 @@ const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
|
24
25
|
const PAGES: readonly (readonly [string, string])[] = [
|
|
25
26
|
["docs/rules/paper/allowed-files-only.md", PAPER_LAYOUT_TREE],
|
|
26
27
|
["docs/rules/repro/allowed-files-only.md", REPRO_LAYOUT_TREE],
|
|
28
|
+
["docs/rules/corpus/allowed-files-only.md", CORPUS_LAYOUT_TREE],
|
|
27
29
|
["docs/layout.md", PAPERS_LAYOUT_TREE],
|
|
28
30
|
];
|
|
29
31
|
|
package/src/paper-files.ts
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
* - `files: [["a", "b"]]` matches a file only when BOTH patterns match.
|
|
42
42
|
*/
|
|
43
43
|
import { relative, sep } from "node:path";
|
|
44
|
+
import { CONFIG_FILE } from "#lib/paper-config";
|
|
44
45
|
import { CORPORA_DIR } from "./domain/corpus-record.ts";
|
|
45
46
|
import type {
|
|
46
47
|
ConfigBlock,
|
|
@@ -53,8 +54,9 @@ import type {
|
|
|
53
54
|
* Which papers' own files paperlint's blocks claim. `any` is the config's SHAPE, for the rule list and
|
|
54
55
|
* the docs: a file in any folder. `papers` is what `paperlint lint` runs on: the real papers, as glob
|
|
55
56
|
* prefixes relative to ESLint's `cwd` ("" for `cwd` itself), so a copy of a paper kept inside one (a
|
|
56
|
-
* review snapshot, a build copy) is claimed by no block (#582);
|
|
57
|
-
* whose `venues/` hold the venue corpora.
|
|
57
|
+
* review snapshot, a build copy) is claimed by no block (#582); the papers roots (absolute),
|
|
58
|
+
* whose `venues/` hold the venue corpora; and the project root (absolute) whose `paperlint.json`
|
|
59
|
+
* is linted, or null when it is not (no papers root holds `venues/`).
|
|
58
60
|
*/
|
|
59
61
|
export type PaperScope =
|
|
60
62
|
| { readonly kind: "any" }
|
|
@@ -63,6 +65,7 @@ export type PaperScope =
|
|
|
63
65
|
readonly cwd: string;
|
|
64
66
|
readonly prefixes: readonly string[];
|
|
65
67
|
readonly roots: readonly string[];
|
|
68
|
+
readonly home: string | null;
|
|
66
69
|
};
|
|
67
70
|
|
|
68
71
|
export const ANY_PAPER: PaperScope = { kind: "any" };
|
|
@@ -75,18 +78,31 @@ const literalGlob = (path: string): string =>
|
|
|
75
78
|
const posixRelative = (from: string, to: string): string =>
|
|
76
79
|
relative(from, to).split(sep).join("/");
|
|
77
80
|
|
|
78
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* The papers `dirs` and the papers `roots` under ESLint's `cwd`, and the project root `home` whose
|
|
83
|
+
* `paperlint.json` is linted (null: none is): the scope `paperlint lint` lints. Pure.
|
|
84
|
+
*/
|
|
79
85
|
export const papersScope = (
|
|
80
86
|
dirs: readonly string[],
|
|
81
87
|
cwd: string,
|
|
82
88
|
roots: readonly string[],
|
|
89
|
+
home: string | null = null,
|
|
83
90
|
): PaperScope => ({
|
|
84
91
|
kind: "papers",
|
|
85
92
|
cwd,
|
|
86
93
|
prefixes: dirs.map((d) => literalGlob(posixRelative(cwd, d))),
|
|
87
94
|
roots,
|
|
95
|
+
home,
|
|
88
96
|
});
|
|
89
97
|
|
|
98
|
+
/** The project's root settings file, as the glob that names it from ESLint's `cwd`; none without a `home`. Pure. */
|
|
99
|
+
export const rootSettingsFile = (scope: PaperScope): readonly string[] => {
|
|
100
|
+
if (scope.kind === "any") return [CONFIG_FILE];
|
|
101
|
+
if (scope.home === null) return [];
|
|
102
|
+
const dir = posixRelative(scope.cwd, scope.home);
|
|
103
|
+
return [dir === "" ? CONFIG_FILE : `${literalGlob(dir)}/${CONFIG_FILE}`];
|
|
104
|
+
};
|
|
105
|
+
|
|
90
106
|
/** A glob of a paper's own file (`paper.tex`, `reviews/*.md`) in each paper of `scope`. Pure. */
|
|
91
107
|
export const paperFiles = (
|
|
92
108
|
scope: PaperScope,
|
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,8 @@ 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
36
|
|
|
37
37
|
/** No plan and no history: the index with every mode column `—`. */
|
|
38
38
|
const NO_FACTS: IndexInput = { plans: new Map(), history: new Map() };
|
|
@@ -1295,6 +1295,22 @@ const CASES: Readonly<Record<string, RuleCases>> = {
|
|
|
1295
1295
|
},
|
|
1296
1296
|
silent: paper(tex("x"), { [CORPUS_RECORD]: EMPTY_RECORD }),
|
|
1297
1297
|
},
|
|
1298
|
+
// A note at the top of a venue corpus: its place is MANIFEST.md or deep-reads/<key>.md.
|
|
1299
|
+
"corpus/allowed-files-only": {
|
|
1300
|
+
reports: {
|
|
1301
|
+
tree: paper(tex("x"), {
|
|
1302
|
+
[CORPUS_RECORD]: EMPTY_RECORD,
|
|
1303
|
+
"papers/venues/agent/notes.md": "# notes\n",
|
|
1304
|
+
}),
|
|
1305
|
+
file: CORPUS_RECORD,
|
|
1306
|
+
severity: 2,
|
|
1307
|
+
line: 1,
|
|
1308
|
+
},
|
|
1309
|
+
silent: paper(tex("x"), {
|
|
1310
|
+
[CORPUS_RECORD]: EMPTY_RECORD,
|
|
1311
|
+
"papers/venues/agent/MANIFEST.md": "# caveats\n",
|
|
1312
|
+
}),
|
|
1313
|
+
},
|
|
1298
1314
|
// A loose script at the top of repro/: it belongs in repro/tools/.
|
|
1299
1315
|
"repro/allowed-files-only": {
|
|
1300
1316
|
reports: {
|
|
@@ -1710,44 +1726,6 @@ const EXEMPT: Readonly<Record<string, string>> = {};
|
|
|
1710
1726
|
|
|
1711
1727
|
// ── the run ─────────────────────────────────────────────────────────────────────────────────────
|
|
1712
1728
|
|
|
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
1729
|
/** Every rule id the registry holds. */
|
|
1752
1730
|
const registered = Object.entries(rulePlugins()).flatMap(([plugin, p]) =>
|
|
1753
1731
|
Object.keys(p.rules ?? {}).map((rule) => `${plugin}/${rule}`),
|
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
|
|