paperlint 18.3.1 → 18.4.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/dist/adapters/memory/index.d.ts +6 -0
- package/dist/adapters/memory/index.d.ts.map +1 -1
- package/dist/adapters/memory/index.js +11 -0
- package/dist/adapters/memory/index.js.map +1 -1
- package/dist/adapters/node/index.d.ts +1 -0
- package/dist/adapters/node/index.d.ts.map +1 -1
- package/dist/adapters/node/index.js +1 -0
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/adapters/node/list-tree.io.d.ts +3 -0
- package/dist/adapters/node/list-tree.io.d.ts.map +1 -0
- package/dist/adapters/node/list-tree.io.js +23 -0
- package/dist/adapters/node/list-tree.io.js.map +1 -0
- package/dist/adapters/study-registry/index.d.ts +2 -2
- package/dist/artifact-rules.d.ts +26 -0
- package/dist/artifact-rules.d.ts.map +1 -0
- package/dist/artifact-rules.js +117 -0
- package/dist/artifact-rules.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -1
- package/dist/cli.js.map +1 -1
- package/dist/domain/artifact.d.ts +36 -0
- package/dist/domain/artifact.d.ts.map +1 -0
- package/dist/domain/artifact.js +116 -0
- package/dist/domain/artifact.js.map +1 -0
- package/dist/lib/paper-config.d.ts.map +1 -1
- package/dist/lib/paper-config.js +2 -0
- package/dist/lib/paper-config.js.map +1 -1
- package/dist/paper-settings.d.ts +3 -0
- package/dist/paper-settings.d.ts.map +1 -1
- package/dist/paper-settings.js +19 -16
- package/dist/paper-settings.js.map +1 -1
- package/dist/ports/list-tree.d.ts +11 -0
- package/dist/ports/list-tree.d.ts.map +1 -0
- package/dist/ports/list-tree.js +2 -0
- package/dist/ports/list-tree.js.map +1 -0
- package/docs/configuration.md +2 -1
- package/docs/rules/artifact/promised.md +64 -0
- package/docs/rules/artifact/required-files.md +65 -0
- package/docs/rules.md +2 -0
- package/lib/paper-config.ts +3 -0
- package/package.json +1 -1
- package/presets/agent-2027.jsonc +33 -0
- package/src/adapters/memory/index.test.ts +9 -0
- package/src/adapters/memory/index.ts +15 -0
- package/src/adapters/node/index.ts +1 -0
- package/src/adapters/node/list-tree.io.ts +27 -0
- package/src/adapters/node/list-tree.test.ts +38 -0
- package/src/artifact-rules.test.ts +50 -0
- package/src/artifact-rules.ts +188 -0
- package/src/cli.ts +7 -0
- package/src/domain/artifact.test.ts +154 -0
- package/src/domain/artifact.ts +171 -0
- package/src/new-paper.test.ts +1 -1
- package/src/paper-settings.test.ts +19 -0
- package/src/paper-settings.ts +21 -16
- package/src/ports/list-tree.ts +11 -0
- package/src/presets.test.ts +23 -0
- package/src/rule-cases.test.ts +134 -1
package/src/paper-settings.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* One file name at two levels, one schema (lib/paper-config.mjs → SETTINGS_KEYS):
|
|
5
5
|
*
|
|
6
6
|
* paperlint.json the project (optional): papersDir, rules, defaults
|
|
7
|
-
* <paper>/paperlint.json this paper: { extends, kind, pdf, rules, identity, talk, submission, authors, fields } —
|
|
7
|
+
* <paper>/paperlint.json this paper: { extends, kind, pdf, rules, identity, talk, submission, authors, fields, artifact } —
|
|
8
8
|
* or `cycles`, from whose current attempt extends, kind and submission
|
|
9
9
|
* are DERIVED (src/domain/cycle.ts); the two forms do not mix
|
|
10
10
|
* a venue preset `paperlint:<name>` (shipped) or `./x.jsonc` (src/presets.ts)
|
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
venueCycleOf,
|
|
48
48
|
type Cycles,
|
|
49
49
|
} from "./domain/cycle.ts";
|
|
50
|
+
import { parsePaperArtifact, type PaperArtifact } from "./domain/artifact.ts";
|
|
50
51
|
|
|
51
52
|
/** What one paper declares. Every absent field is null. */
|
|
52
53
|
export interface PaperSettings {
|
|
@@ -84,6 +85,8 @@ export interface PaperSettings {
|
|
|
84
85
|
* attempt's — derived, never written beside it. Never the root's.
|
|
85
86
|
*/
|
|
86
87
|
readonly cycles: Cycles | null;
|
|
88
|
+
/** Where the paper's reproduction artifact is and what the paper promises it holds (`artifact/contents`); null when absent. Never the root's. */
|
|
89
|
+
readonly artifact: PaperArtifact | null;
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
/** Why a paper's settings cannot be read. */
|
|
@@ -240,11 +243,14 @@ export function parsePaperSettings(
|
|
|
240
243
|
if (!rest.ok) return rest;
|
|
241
244
|
const cycles = cyclesField(json);
|
|
242
245
|
if (!cycles.ok) return cycles;
|
|
246
|
+
const artifact = parsePaperArtifact(json["artifact"]);
|
|
247
|
+
if (!artifact.ok) return artifact;
|
|
243
248
|
const flat = {
|
|
244
249
|
...fields.value,
|
|
245
250
|
...rest.value,
|
|
246
251
|
identity: identity.value,
|
|
247
252
|
cycles: cycles.value,
|
|
253
|
+
artifact: artifact.value,
|
|
248
254
|
};
|
|
249
255
|
return ok(
|
|
250
256
|
cycles.value === null ? flat : { ...flat, ...derived(cycles.value) },
|
|
@@ -321,6 +327,18 @@ const NO_DEFAULTS: Defaults = {
|
|
|
321
327
|
identity: null,
|
|
322
328
|
};
|
|
323
329
|
|
|
330
|
+
/** A paper that declares nothing. */
|
|
331
|
+
const NO_SETTINGS: PaperSettings = {
|
|
332
|
+
...NO_DEFAULTS,
|
|
333
|
+
rules: null,
|
|
334
|
+
talk: null,
|
|
335
|
+
submission: null,
|
|
336
|
+
authors: null,
|
|
337
|
+
fields: null,
|
|
338
|
+
cycles: null,
|
|
339
|
+
artifact: null,
|
|
340
|
+
};
|
|
341
|
+
|
|
324
342
|
/** Both lists, joined without repeats; null when neither side has one. */
|
|
325
343
|
const joined = (
|
|
326
344
|
a: readonly string[] | null,
|
|
@@ -334,26 +352,13 @@ function merge(
|
|
|
334
352
|
paper: PaperSettings | null,
|
|
335
353
|
): PaperSettings | null {
|
|
336
354
|
const r = root ?? NO_DEFAULTS;
|
|
337
|
-
const p = paper ??
|
|
338
|
-
...NO_DEFAULTS,
|
|
339
|
-
rules: null,
|
|
340
|
-
talk: null,
|
|
341
|
-
submission: null,
|
|
342
|
-
authors: null,
|
|
343
|
-
fields: null,
|
|
344
|
-
cycles: null,
|
|
345
|
-
};
|
|
355
|
+
const p = paper ?? NO_SETTINGS;
|
|
346
356
|
const merged: PaperSettings = {
|
|
357
|
+
...p,
|
|
347
358
|
extends: p.extends ?? r.extends,
|
|
348
359
|
kind: p.kind ?? r.kind,
|
|
349
360
|
pdf: p.pdf ?? r.pdf,
|
|
350
|
-
rules: p.rules,
|
|
351
361
|
identity: joined(r.identity, p.identity),
|
|
352
|
-
talk: p.talk,
|
|
353
|
-
submission: p.submission,
|
|
354
|
-
authors: p.authors,
|
|
355
|
-
fields: p.fields,
|
|
356
|
-
cycles: p.cycles,
|
|
357
362
|
};
|
|
358
363
|
return paper === null && Object.values(merged).every((v) => v === null)
|
|
359
364
|
? null
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every file under a folder — what the artifact rules ask of a paper's artifact folder, to judge its
|
|
3
|
+
* top level and its promises' globs over the same list a committed `files` list gives.
|
|
4
|
+
*/
|
|
5
|
+
import type { AbsolutePath } from "../domain/paths.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The regular files under `dir`, at any depth, as paths relative to it (`/`-separated), sorted;
|
|
9
|
+
* null when `dir` is not a directory.
|
|
10
|
+
*/
|
|
11
|
+
export type ListTree = (dir: AbsolutePath) => readonly string[] | null;
|
package/src/presets.test.ts
CHANGED
|
@@ -92,6 +92,29 @@ describe("shipped presets", () => {
|
|
|
92
92
|
url: "https://conf.researchr.org/home/ase-2026/agenticdev-2026",
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
|
+
|
|
96
|
+
it("paperlint:agent-2027 records its HotCRP form: a required Submission Type and the attachments field", () => {
|
|
97
|
+
const r = resolve("paperlint:agent-2027");
|
|
98
|
+
expect(r.ok).toBe(true);
|
|
99
|
+
if (!r.ok) return;
|
|
100
|
+
expect(r.value.submissionFields).toEqual({
|
|
101
|
+
source: "portal",
|
|
102
|
+
url: "https://icse2027-agent.hotcrp.com/api/searchcompletion",
|
|
103
|
+
read: "2026-11-20",
|
|
104
|
+
fields: {
|
|
105
|
+
SubTyp: {
|
|
106
|
+
kind: "choice",
|
|
107
|
+
required: true,
|
|
108
|
+
label: "Submission Type",
|
|
109
|
+
options: [
|
|
110
|
+
"Full paper (up to 8 pages, including references)",
|
|
111
|
+
"Short paper (up to 5 pages, including references)",
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
Att: { kind: "attachments", required: false, label: null },
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
});
|
|
95
118
|
});
|
|
96
119
|
|
|
97
120
|
describe("shipped presets: paperlint:msr-2027", () => {
|
package/src/rule-cases.test.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
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 { readFileSync } from "node:fs";
|
|
13
|
+
import { mkdirSync, readFileSync } from "node:fs";
|
|
14
14
|
import { dirname, join } from "node:path";
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
import { describe, expect, it } from "vitest";
|
|
@@ -813,7 +813,61 @@ const CHANGES_AT = `${P}/versions/beta-2027/changes.yaml`;
|
|
|
813
813
|
const DECLARED_CUT =
|
|
814
814
|
'- type: cut\n before: "We measured 63 repositories."\n why: too long\n reader_loses: the sample size\n drops: ["63"]\n';
|
|
815
815
|
|
|
816
|
+
/** A paper whose paperlint.json declares `artifact`, with the artifact's own files. */
|
|
817
|
+
const withArtifact = (
|
|
818
|
+
artifact: Readonly<Record<string, unknown>>,
|
|
819
|
+
files: Readonly<Record<string, string>> = {},
|
|
820
|
+
): Record<string, string> =>
|
|
821
|
+
paper(tex("x"), {
|
|
822
|
+
[`${P}/paperlint.json`]: JSON.stringify({ extends: null, artifact }),
|
|
823
|
+
...files,
|
|
824
|
+
});
|
|
825
|
+
/** The artifact in `extra/`, a folder the layout never judges. */
|
|
826
|
+
const ARTIFACT_DIR = "extra/artifact";
|
|
827
|
+
const LIST = "submission/artifact-files.txt";
|
|
828
|
+
const ARTIFACT_FILES: Readonly<Record<string, string>> = {
|
|
829
|
+
[`${P}/${ARTIFACT_DIR}/README.md`]: "# artifact\n",
|
|
830
|
+
[`${P}/${ARTIFACT_DIR}/LICENSE`]: "MIT\n",
|
|
831
|
+
[`${P}/${ARTIFACT_DIR}/data/prompts/a.md`]: "a\n",
|
|
832
|
+
};
|
|
833
|
+
const REQUIRED = ["README", "LICENSE"];
|
|
834
|
+
const PROMISES = { prompts: "**/prompts/*.md" };
|
|
835
|
+
|
|
816
836
|
const CASES: Readonly<Record<string, RuleCases>> = {
|
|
837
|
+
// A paper that requires README and LICENSE of an artifact holding only a README.
|
|
838
|
+
"artifact/required-files": {
|
|
839
|
+
reports: {
|
|
840
|
+
tree: withArtifact(
|
|
841
|
+
{ dir: ARTIFACT_DIR, required: REQUIRED },
|
|
842
|
+
{ [`${P}/${ARTIFACT_DIR}/README.md`]: "# artifact\n" },
|
|
843
|
+
),
|
|
844
|
+
file: `${P}/PIPELINE-STATUS.md`,
|
|
845
|
+
severity: 2,
|
|
846
|
+
line: 1,
|
|
847
|
+
},
|
|
848
|
+
// The same artifact with its LICENSE.
|
|
849
|
+
silent: withArtifact(
|
|
850
|
+
{ dir: ARTIFACT_DIR, required: REQUIRED },
|
|
851
|
+
ARTIFACT_FILES,
|
|
852
|
+
),
|
|
853
|
+
},
|
|
854
|
+
// A promise of prompts the artifact does not hold.
|
|
855
|
+
"artifact/promised": {
|
|
856
|
+
reports: {
|
|
857
|
+
tree: withArtifact(
|
|
858
|
+
{ dir: ARTIFACT_DIR, promises: PROMISES },
|
|
859
|
+
{ [`${P}/${ARTIFACT_DIR}/README.md`]: "# artifact\n" },
|
|
860
|
+
),
|
|
861
|
+
file: `${P}/PIPELINE-STATUS.md`,
|
|
862
|
+
severity: 2,
|
|
863
|
+
line: 1,
|
|
864
|
+
},
|
|
865
|
+
// The same promise in a committed list of a zip wrapped in one folder, the prompts there.
|
|
866
|
+
silent: withArtifact(
|
|
867
|
+
{ files: LIST, promises: PROMISES },
|
|
868
|
+
{ [`${P}/${LIST}`]: "artifact/\nartifact/data/prompts/a.md\n" },
|
|
869
|
+
),
|
|
870
|
+
},
|
|
817
871
|
"cycle/changes-since-approved": {
|
|
818
872
|
reports: {
|
|
819
873
|
tree: paper(tex("The rest is as before."), {
|
|
@@ -1629,11 +1683,13 @@ type Message = z.infer<typeof LintResults>[number]["messages"][number] & {
|
|
|
1629
1683
|
/** `paperlint lint --json` over the tree, in-process through the CLI: every message, by file. */
|
|
1630
1684
|
async function lintTree(
|
|
1631
1685
|
tree: Record<string, string | Uint8Array>,
|
|
1686
|
+
emptyDirs: readonly string[] = [],
|
|
1632
1687
|
): Promise<Message[]> {
|
|
1633
1688
|
const dir = writeTree(useTempDir("paperlint-rule-cases-"), {
|
|
1634
1689
|
"package.json": '{"name":"consumer","private":true}',
|
|
1635
1690
|
...tree,
|
|
1636
1691
|
});
|
|
1692
|
+
emptyDirs.forEach((d) => mkdirSync(join(dir, d), { recursive: true }));
|
|
1637
1693
|
const out: string[] = [];
|
|
1638
1694
|
await run(["lint", "--json"], {
|
|
1639
1695
|
cwd: dir,
|
|
@@ -1934,6 +1990,83 @@ describe("cycle/camera-ready-source, before the camera-ready is frozen", () => {
|
|
|
1934
1990
|
);
|
|
1935
1991
|
});
|
|
1936
1992
|
|
|
1993
|
+
const STATUS_AT = `${P}/PIPELINE-STATUS.md`;
|
|
1994
|
+
/** What the artifact rules say about `tree` (`emptyDirs` made too), as `file:line rule message`. */
|
|
1995
|
+
const said = async (
|
|
1996
|
+
tree: Record<string, string>,
|
|
1997
|
+
emptyDirs: readonly string[] = [],
|
|
1998
|
+
) =>
|
|
1999
|
+
(await lintTree(tree, emptyDirs))
|
|
2000
|
+
.filter((m) => (m.ruleId ?? "").startsWith("artifact/"))
|
|
2001
|
+
.map((m) => `${m.file}:${String(m.line)} ${m.ruleId ?? ""} ${m.message}`);
|
|
2002
|
+
|
|
2003
|
+
describe("the artifact rules through real ESLint: each message, both halves", () => {
|
|
2004
|
+
it(
|
|
2005
|
+
"🔴 a folder that does not exist: each rule says what it cannot check",
|
|
2006
|
+
{ timeout: CASE_TIMEOUT_MS },
|
|
2007
|
+
async () => {
|
|
2008
|
+
expect(
|
|
2009
|
+
await said(
|
|
2010
|
+
withArtifact({
|
|
2011
|
+
dir: ARTIFACT_DIR,
|
|
2012
|
+
required: ["README"],
|
|
2013
|
+
promises: PROMISES,
|
|
2014
|
+
}),
|
|
2015
|
+
),
|
|
2016
|
+
).toEqual([
|
|
2017
|
+
`${STATUS_AT}:1 artifact/required-files the artifact folder ${ARTIFACT_DIR} ("artifact.dir" in paperlint.json, relative to the paper) does not exist or is not a folder, so its required names cannot be checked`,
|
|
2018
|
+
`${STATUS_AT}:1 artifact/promised the artifact folder ${ARTIFACT_DIR} ("artifact.dir" in paperlint.json, relative to the paper) does not exist or is not a folder, so its promises cannot be checked`,
|
|
2019
|
+
]);
|
|
2020
|
+
},
|
|
2021
|
+
);
|
|
2022
|
+
|
|
2023
|
+
it(
|
|
2024
|
+
"🔴 a folder that exists and is empty: the name missing and the promise matching nothing, not the folder",
|
|
2025
|
+
{ timeout: CASE_TIMEOUT_MS },
|
|
2026
|
+
async () => {
|
|
2027
|
+
expect(
|
|
2028
|
+
await said(
|
|
2029
|
+
withArtifact({
|
|
2030
|
+
dir: ARTIFACT_DIR,
|
|
2031
|
+
required: ["README"],
|
|
2032
|
+
promises: PROMISES,
|
|
2033
|
+
}),
|
|
2034
|
+
[`${P}/${ARTIFACT_DIR}`],
|
|
2035
|
+
),
|
|
2036
|
+
).toEqual([
|
|
2037
|
+
`${STATUS_AT}:1 artifact/required-files the artifact (${ARTIFACT_DIR}) has no top-level README — any extension counts (README.md, README.txt, README); "artifact.required" in paperlint.json asks for one`,
|
|
2038
|
+
`${STATUS_AT}:1 artifact/promised the artifact promise "prompts" (**/prompts/*.md) matches no path of the artifact (${ARTIFACT_DIR}): the paper says the artifact holds it — add the files, or correct the glob in "artifact.promises"`,
|
|
2039
|
+
]);
|
|
2040
|
+
},
|
|
2041
|
+
);
|
|
2042
|
+
});
|
|
2043
|
+
|
|
2044
|
+
describe("the artifact rules through real ESLint: a committed list of paths", () => {
|
|
2045
|
+
it(
|
|
2046
|
+
"🔴 a list that does not exist, and one that names no file",
|
|
2047
|
+
{ timeout: CASE_TIMEOUT_MS },
|
|
2048
|
+
async () => {
|
|
2049
|
+
const declared = { files: LIST, required: ["README"] };
|
|
2050
|
+
expect(await said(withArtifact(declared))).toEqual([
|
|
2051
|
+
`${STATUS_AT}:1 artifact/required-files the artifact's list of paths ${LIST} ("artifact.files" in paperlint.json, relative to the paper) does not exist, so its required names cannot be checked`,
|
|
2052
|
+
]);
|
|
2053
|
+
expect(
|
|
2054
|
+
await said(withArtifact(declared, { [`${P}/${LIST}`]: "artifact/\n" })),
|
|
2055
|
+
).toEqual([
|
|
2056
|
+
`${STATUS_AT}:1 artifact/required-files the artifact's list of paths ${LIST} names no file, so its required names cannot be checked — write one path per line, relative to the artifact's root, as \`zipinfo -1\` or \`find . -type f\` print them`,
|
|
2057
|
+
]);
|
|
2058
|
+
},
|
|
2059
|
+
);
|
|
2060
|
+
|
|
2061
|
+
it(
|
|
2062
|
+
"a paper that declares no artifact: silent, the rules on by default all the same",
|
|
2063
|
+
{ timeout: CASE_TIMEOUT_MS },
|
|
2064
|
+
async () => {
|
|
2065
|
+
expect(await said(paper(tex("x")))).toEqual([]);
|
|
2066
|
+
},
|
|
2067
|
+
);
|
|
2068
|
+
});
|
|
2069
|
+
|
|
1937
2070
|
describe.each(Object.entries(CASES))("%s, through real ESLint", (id, c) => {
|
|
1938
2071
|
it(
|
|
1939
2072
|
`reports on ${c.reports.file}:${String(c.reports.line)} at severity ${String(c.reports.severity)}`,
|