paperlint 20.2.0 → 20.3.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 +17 -1
- package/dist/adapters/venue-corpus/index.d.ts.map +1 -1
- package/dist/adapters/venue-corpus/index.js +23 -7
- package/dist/adapters/venue-corpus/index.js.map +1 -1
- package/dist/cli.d.ts +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +42 -13
- package/dist/cli.js.map +1 -1
- package/dist/corpus-record-rule.d.ts +65 -0
- package/dist/corpus-record-rule.d.ts.map +1 -0
- package/dist/corpus-record-rule.js +85 -0
- package/dist/corpus-record-rule.js.map +1 -0
- package/dist/domain/corpus-record.d.ts +51 -0
- package/dist/domain/corpus-record.d.ts.map +1 -0
- package/dist/domain/corpus-record.js +119 -0
- package/dist/domain/corpus-record.js.map +1 -0
- package/dist/domain/venue-corpus.d.ts +25 -3
- package/dist/domain/venue-corpus.d.ts.map +1 -1
- package/dist/domain/venue-corpus.js +4 -0
- package/dist/domain/venue-corpus.js.map +1 -1
- package/dist/paper-files.d.ts +10 -3
- package/dist/paper-files.d.ts.map +1 -1
- package/dist/paper-files.js +17 -2
- package/dist/paper-files.js.map +1 -1
- package/dist/papers-roots.d.ts +6 -0
- package/dist/papers-roots.d.ts.map +1 -1
- package/dist/papers-roots.js +14 -0
- package/dist/papers-roots.js.map +1 -1
- package/docs/design/venue-corpus.md +48 -27
- package/docs/layout.md +2 -2
- package/docs/rules/corpus/record.md +119 -0
- package/docs/rules.md +1 -0
- package/docs/venues.md +31 -20
- package/eslint.config.mjs +1 -0
- package/package.json +2 -1
- package/scripts/eslint-file-length.mjs +3 -3
- package/skills/study-accepted-papers/SKILL.md +14 -8
- package/skills/study-accepted-papers/SKILL.md.spec.ts +13 -7
- package/skills/study-accepted-papers/papers.schema.json +49 -2
- package/skills/study-accepted-papers/scripts/corpus-licences-core.js +2 -2
- package/skills/study-accepted-papers/scripts/corpus-licences-core.ts +2 -1
- package/skills/study-accepted-papers/scripts/corpus-licences.js +19 -9
- package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +4 -1
- package/src/adapters/venue-corpus/index.test.ts +68 -10
- package/src/adapters/venue-corpus/index.ts +28 -8
- package/src/cli-e2e.test.mjs +2 -2
- package/src/cli.test.ts +1 -1
- package/src/cli.ts +57 -13
- package/src/corpus-record-rule.test.ts +228 -0
- package/src/corpus-record-rule.ts +175 -0
- package/src/domain/corpus-record.test.ts +163 -0
- package/src/domain/corpus-record.ts +210 -0
- package/src/domain/venue-corpus.ts +32 -3
- package/src/paper-files.test.ts +13 -4
- package/src/paper-files.ts +23 -2
- package/src/paper-settings-commands.test.ts +2 -2
- package/src/papers-roots.test.ts +34 -1
- package/src/papers-roots.ts +15 -0
- package/src/rule-cases.test.ts +15 -0
- package/src/settled-paper.test.ts +1 -1
- package/src/unowned-file.test.ts +1 -1
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 { CORPORA_DIR } from "./domain/corpus-record.ts";
|
|
44
45
|
import type {
|
|
45
46
|
ConfigBlock,
|
|
46
47
|
RuleBlock,
|
|
@@ -52,7 +53,8 @@ import type {
|
|
|
52
53
|
* Which papers' own files paperlint's blocks claim. `any` is the config's SHAPE, for the rule list and
|
|
53
54
|
* the docs: a file in any folder. `papers` is what `paperlint lint` runs on: the real papers, as glob
|
|
54
55
|
* prefixes relative to ESLint's `cwd` ("" for `cwd` itself), so a copy of a paper kept inside one (a
|
|
55
|
-
* review snapshot, a build copy) is claimed by no block (#582)
|
|
56
|
+
* review snapshot, a build copy) is claimed by no block (#582); and the papers roots (absolute),
|
|
57
|
+
* whose `venues/` hold the venue corpora.
|
|
56
58
|
*/
|
|
57
59
|
export type PaperScope =
|
|
58
60
|
| { readonly kind: "any" }
|
|
@@ -60,6 +62,7 @@ export type PaperScope =
|
|
|
60
62
|
readonly kind: "papers";
|
|
61
63
|
readonly cwd: string;
|
|
62
64
|
readonly prefixes: readonly string[];
|
|
65
|
+
readonly roots: readonly string[];
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
export const ANY_PAPER: PaperScope = { kind: "any" };
|
|
@@ -72,14 +75,16 @@ const literalGlob = (path: string): string =>
|
|
|
72
75
|
const posixRelative = (from: string, to: string): string =>
|
|
73
76
|
relative(from, to).split(sep).join("/");
|
|
74
77
|
|
|
75
|
-
/** The papers `dirs` under ESLint's `cwd`: the scope `paperlint lint` lints. Pure. */
|
|
78
|
+
/** The papers `dirs` and the papers `roots` under ESLint's `cwd`: the scope `paperlint lint` lints. Pure. */
|
|
76
79
|
export const papersScope = (
|
|
77
80
|
dirs: readonly string[],
|
|
78
81
|
cwd: string,
|
|
82
|
+
roots: readonly string[],
|
|
79
83
|
): PaperScope => ({
|
|
80
84
|
kind: "papers",
|
|
81
85
|
cwd,
|
|
82
86
|
prefixes: dirs.map((d) => literalGlob(posixRelative(cwd, d))),
|
|
87
|
+
roots,
|
|
83
88
|
});
|
|
84
89
|
|
|
85
90
|
/** A glob of a paper's own file (`paper.tex`, `reviews/*.md`) in each paper of `scope`. Pure. */
|
|
@@ -91,6 +96,22 @@ export const paperFiles = (
|
|
|
91
96
|
? [`**/${glob}`]
|
|
92
97
|
: scope.prefixes.map((p) => (p === "" ? glob : `${p}/${glob}`));
|
|
93
98
|
|
|
99
|
+
/**
|
|
100
|
+
* A glob of a file in each venue corpus, `<papers-root>/venues/<venue>/<glob>`; none for a root
|
|
101
|
+
* outside ESLint's `cwd`, whose files ESLint never lints. Pure.
|
|
102
|
+
*/
|
|
103
|
+
export const corpusFiles = (
|
|
104
|
+
scope: PaperScope,
|
|
105
|
+
glob: string,
|
|
106
|
+
): readonly string[] => {
|
|
107
|
+
const inCorpus = `${CORPORA_DIR}/*/${glob}`;
|
|
108
|
+
if (scope.kind === "any") return [`**/${inCorpus}`];
|
|
109
|
+
return scope.roots
|
|
110
|
+
.map((r) => posixRelative(scope.cwd, r))
|
|
111
|
+
.filter((r) => r !== ".." && !r.startsWith("../"))
|
|
112
|
+
.map((r) => (r === "" ? inCorpus : `${literalGlob(r)}/${inCorpus}`));
|
|
113
|
+
};
|
|
114
|
+
|
|
94
115
|
/**
|
|
95
116
|
* A glob relative to `cwd`, as the block whose `basePath` is `base` must write it — ESLint reads a
|
|
96
117
|
* block's patterns from its `basePath`, and a paper's own settings carry the paper's folder. None
|
|
@@ -230,7 +230,7 @@ describe("paperlint lint — the venue preset's rules", () => {
|
|
|
230
230
|
}),
|
|
231
231
|
});
|
|
232
232
|
const cfgOf = await import("./cli.ts").then((m) =>
|
|
233
|
-
m.paperRuleBlocks([join(root, "papers")]),
|
|
233
|
+
m.paperRuleBlocks([join(root, "papers")], [join(root, "papers")]),
|
|
234
234
|
);
|
|
235
235
|
expect(cfgOf.ok && cfgOf.value.preset).toEqual([
|
|
236
236
|
{
|
|
@@ -276,7 +276,7 @@ describe("paperlint lint — the paper over its preset, and the project's own pr
|
|
|
276
276
|
}),
|
|
277
277
|
});
|
|
278
278
|
const blocks = await import("./cli.ts").then((m) =>
|
|
279
|
-
m.paperRuleBlocks([join(root, "papers")]),
|
|
279
|
+
m.paperRuleBlocks([join(root, "papers")], [join(root, "papers")]),
|
|
280
280
|
);
|
|
281
281
|
// The preset's block comes first and the paper's own after it: the later block wins.
|
|
282
282
|
expect(blocks.ok && blocks.value.preset[0]?.rules).toEqual({
|
package/src/papers-roots.test.ts
CHANGED
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import assert from "node:assert/strict";
|
|
6
6
|
import { test } from "vitest";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
inCorpus,
|
|
9
|
+
papersRoots,
|
|
10
|
+
segmentsUnder,
|
|
11
|
+
toPaths,
|
|
12
|
+
} from "./papers-roots.ts";
|
|
8
13
|
|
|
9
14
|
test("a papers directory given as a string or as a list normalises to a list; anything else to none", () => {
|
|
10
15
|
assert.deepEqual(
|
|
@@ -54,3 +59,31 @@ test("a path is placed under the first directory that holds it, by its segments"
|
|
|
54
59
|
[["x", "paper.tex"], ["y"], null, null, null, ["..draft", "paper.tex"]],
|
|
55
60
|
);
|
|
56
61
|
});
|
|
62
|
+
|
|
63
|
+
test("a folder is in a venue corpus when it is `<root>/venues/<venue>/` or below it", () => {
|
|
64
|
+
const roots = ["/p/papers"];
|
|
65
|
+
assert.deepEqual(
|
|
66
|
+
[
|
|
67
|
+
"/p/papers/venues/agent",
|
|
68
|
+
"/p/papers/venues/agent/sources/x",
|
|
69
|
+
"/p/papers/venues",
|
|
70
|
+
"/p/papers/agent",
|
|
71
|
+
"/p/elsewhere/venues/agent",
|
|
72
|
+
].map((d) => inCorpus(d, roots)),
|
|
73
|
+
[true, true, false, false, false],
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("🔴 a corpus under any of overlapping roots is a corpus, whichever root is listed first", () => {
|
|
78
|
+
// Guards: `papersDir: [".", "papers"]` — the corpus under the second root must still be excluded
|
|
79
|
+
// from the paper rules, not read through the first root as `papers/venues/agent`.
|
|
80
|
+
const dir = "/project/papers/venues/agent";
|
|
81
|
+
assert.deepEqual(
|
|
82
|
+
[
|
|
83
|
+
inCorpus(dir, ["/project", "/project/papers"]),
|
|
84
|
+
inCorpus(dir, ["/project/papers", "/project"]),
|
|
85
|
+
inCorpus("/project/papers/agent", ["/project", "/project/papers"]),
|
|
86
|
+
],
|
|
87
|
+
[true, true, false],
|
|
88
|
+
);
|
|
89
|
+
});
|
package/src/papers-roots.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
13
13
|
import { DEFAULT_PAPERS_ROOT } from "#lib/paper-config";
|
|
14
|
+
import { CORPORA_DIR } from "./domain/corpus-record.ts";
|
|
14
15
|
|
|
15
16
|
/** The papers directory field of the settings, read by its one declared name; the default when absent. */
|
|
16
17
|
export function papersDirOf(opts: { readonly papersDir?: unknown }): unknown {
|
|
@@ -54,3 +55,17 @@ export function segmentsUnder(
|
|
|
54
55
|
);
|
|
55
56
|
return below === undefined ? null : below.split(sep);
|
|
56
57
|
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether the absolute folder `dir` is a venue corpus of one of `roots`, or inside one:
|
|
61
|
+
* `<root>/venues/<venue>/` and below. A paper found there is an accepted paper's source kept in the
|
|
62
|
+
* corpus, not one of the project's papers (#215), so no paper rule judges it.
|
|
63
|
+
*/
|
|
64
|
+
export function inCorpus(dir: string, roots: readonly string[]): boolean {
|
|
65
|
+
// Each root on its own: roots may overlap (`.` and `papers`), and the first that holds `dir` need
|
|
66
|
+
// not be the one whose `venues/` it is in.
|
|
67
|
+
return roots.some((root) => {
|
|
68
|
+
const [first, venue] = segmentsUnder(dir, [root]) ?? [];
|
|
69
|
+
return first === CORPORA_DIR && venue !== undefined;
|
|
70
|
+
});
|
|
71
|
+
}
|
package/src/rule-cases.test.ts
CHANGED
|
@@ -42,6 +42,8 @@ const fixture = (p: string): string =>
|
|
|
42
42
|
readFileSync(join(ROOT, "fixtures", p), "utf8");
|
|
43
43
|
|
|
44
44
|
const P = "papers/p";
|
|
45
|
+
const CORPUS_RECORD = "papers/venues/agent/papers.json";
|
|
46
|
+
const EMPTY_RECORD = '{"venue":"agent","editions":[],"papers":[],"rebuild":[]}';
|
|
45
47
|
const STATUS = "---\nstages: []\n---\n# PIPELINE-STATUS\n";
|
|
46
48
|
const tex = (body: string, cls = "\\documentclass{article}"): string =>
|
|
47
49
|
`${cls}\n\\begin{document}\n${body}\n\\end{document}\n`;
|
|
@@ -1280,6 +1282,19 @@ const CASES: Readonly<Record<string, RuleCases>> = {
|
|
|
1280
1282
|
[`${P}/extra/PLAN.md`]: "# plan\n",
|
|
1281
1283
|
}),
|
|
1282
1284
|
},
|
|
1285
|
+
// A venue corpus storing a PDF its papers.json lists no paper for; silent while it stores nothing.
|
|
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
|
+
},
|
|
1283
1298
|
// A loose script at the top of repro/: it belongs in repro/tools/.
|
|
1284
1299
|
"repro/allowed-files-only": {
|
|
1285
1300
|
reports: {
|
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, **/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, **/reviews/*.md, **/paper.tex, **/siblings/*.md, and the .tex files a built paper.tex includes",
|
|
92
92
|
);
|
|
93
93
|
});
|
|
94
94
|
|