paperlint 18.9.1 → 19.0.1
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/CLAUDE.md +2 -2
- package/dist/adapters/eslint/index.d.ts +13 -0
- package/dist/adapters/eslint/index.d.ts.map +1 -0
- package/dist/adapters/eslint/index.js +44 -0
- package/dist/adapters/eslint/index.js.map +1 -0
- package/dist/adapters/eslint/report.io.d.ts +15 -0
- package/dist/adapters/eslint/report.io.d.ts.map +1 -0
- package/dist/adapters/eslint/report.io.js +48 -0
- package/dist/adapters/eslint/report.io.js.map +1 -0
- package/dist/cli.d.ts +7 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +73 -110
- package/dist/cli.js.map +1 -1
- package/dist/domain/submission-lint.d.ts +29 -0
- package/dist/domain/submission-lint.d.ts.map +1 -0
- package/dist/domain/submission-lint.js +84 -0
- package/dist/domain/submission-lint.js.map +1 -0
- package/dist/ports/submission-lint.d.ts +6 -0
- package/dist/ports/submission-lint.d.ts.map +1 -0
- package/dist/ports/submission-lint.js +2 -0
- package/dist/ports/submission-lint.js.map +1 -0
- package/dist/structure.d.ts +17 -1
- package/dist/structure.d.ts.map +1 -1
- package/dist/structure.js.map +1 -1
- package/dist/submission-confirm-hook.d.ts +8 -1
- package/dist/submission-confirm-hook.d.ts.map +1 -1
- package/dist/submission-confirm-hook.js +75 -20
- package/dist/submission-confirm-hook.js.map +1 -1
- package/dist/submission.d.ts +5 -0
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +46 -7
- package/dist/submission.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/submission.md +19 -8
- package/eslint.config.mjs +2 -0
- package/lib/skill-corpus.mjs +2 -113
- package/lib/skill-corpus.test.mjs +10 -11
- package/package.json +1 -2
- package/scripts/eslint-file-length.mjs +117 -0
- package/scripts/harness-api.frozen.json +0 -18
- package/skills/build-label-page/build-label-page.test.ts +2 -7
- package/skills/harden-paper/check-numbers.test.ts +104 -0
- package/skills/harden-paper/check-release-claims.test.ts +126 -0
- package/skills/label-agent-runs/label-agent-runs.harness.ts +2 -6
- package/skills/render-paper/render-paper.harness.mjs +153 -0
- package/skills/rewrite-unclear/rewrite-unclear.harness.ts +0 -5
- package/skills/run-agent-grid/run-agent-grid.harness.ts +2 -6
- package/skills/submit-paper/check-deanon.test.ts +165 -0
- package/src/adapters/eslint/index.test.ts +152 -0
- package/src/adapters/eslint/index.ts +89 -0
- package/src/adapters/eslint/report.io.ts +82 -0
- package/src/cli.ts +103 -134
- package/src/domain/submission-lint.test.ts +211 -0
- package/src/domain/submission-lint.ts +166 -0
- package/src/ports/submission-lint.ts +10 -0
- package/src/structure.ts +2 -4
- package/src/submission-confirm-hook-lint.test.ts +47 -0
- package/src/submission-confirm-hook.test.ts +73 -6
- package/src/submission-confirm-hook.ts +133 -28
- package/src/submission-fields-run.test.ts +1 -1
- package/src/submission-new.test.ts +4 -2
- package/src/submission-update.test.ts +16 -11
- package/src/submission.ts +62 -8
- package/src/types.ts +2 -0
- package/lib/skill-checks.d.mts +0 -10
- package/lib/skill-checks.mjs +0 -403
- package/lib/skill-checks.test.mjs +0 -288
- package/skills/analyze-sibling-paper/analyze-sibling-paper.harness.mjs +0 -23
- package/skills/argument-arc/argument-arc.harness.mjs +0 -23
- package/skills/build-benchmark/build-benchmark.harness.mjs +0 -23
- package/skills/camera-ready/camera-ready.harness.mjs +0 -23
- package/skills/cold-read-diff/cold-read-diff.harness.mjs +0 -21
- package/skills/draft-paper/draft-paper.harness.mjs +0 -23
- package/skills/extend-paper/extend-paper.harness.mjs +0 -23
- package/skills/find-venue/find-venue.harness.mjs +0 -23
- package/skills/harden-paper/harden-paper.harness.mjs +0 -23
- package/skills/map-prior-work/map-prior-work.harness.mjs +0 -23
- package/skills/paper-status/paper-status.harness.mjs +0 -25
- package/skills/pc-panel-review/pc-panel-review.harness.mjs +0 -24
- package/skills/plan-paper-timeline/plan-paper-timeline.harness.mjs +0 -23
- package/skills/research-ideate/research-ideate.harness.mjs +0 -23
- package/skills/study-accepted-papers/study-accepted-papers.harness.mjs +0 -23
- package/skills/submit-paper/submit-paper.harness.mjs +0 -23
- package/skills/tighten-paper/tighten-paper.harness.mjs +0 -23
- package/skills/verify-citations/verify-citations.harness.mjs +0 -23
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { ESLint, Linter } from "eslint";
|
|
2
|
+
import { expect, test } from "vitest";
|
|
3
|
+
import { err, ok } from "../../domain/result.ts";
|
|
4
|
+
import {
|
|
5
|
+
isEmptyLintSet,
|
|
6
|
+
lintFindings,
|
|
7
|
+
submissionLinter,
|
|
8
|
+
type OnLintResults,
|
|
9
|
+
} from "./index.ts";
|
|
10
|
+
|
|
11
|
+
const paperDir = "/work/paper";
|
|
12
|
+
const result = (
|
|
13
|
+
filePath: string,
|
|
14
|
+
messages: readonly Linter.LintMessage[],
|
|
15
|
+
): ESLint.LintResult => ({
|
|
16
|
+
filePath,
|
|
17
|
+
messages: [...messages],
|
|
18
|
+
suppressedMessages: [],
|
|
19
|
+
errorCount: 0,
|
|
20
|
+
fatalErrorCount: 0,
|
|
21
|
+
warningCount: 0,
|
|
22
|
+
fixableErrorCount: 0,
|
|
23
|
+
fixableWarningCount: 0,
|
|
24
|
+
usedDeprecatedRules: [],
|
|
25
|
+
});
|
|
26
|
+
const warning: Linter.LintMessage = {
|
|
27
|
+
ruleId: "tex/example",
|
|
28
|
+
severity: 1,
|
|
29
|
+
message: "a warning",
|
|
30
|
+
line: 3,
|
|
31
|
+
column: 2,
|
|
32
|
+
};
|
|
33
|
+
const fatal: Linter.LintMessage = {
|
|
34
|
+
ruleId: null,
|
|
35
|
+
severity: 2,
|
|
36
|
+
fatal: true,
|
|
37
|
+
message: "Parsing error",
|
|
38
|
+
line: 5,
|
|
39
|
+
column: 1,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
test("a finding's file is relative to the paper directory, with forward slashes, or a dot for the directory itself", () => {
|
|
43
|
+
const found = lintFindings(
|
|
44
|
+
[
|
|
45
|
+
result(`${paperDir}/sections/intro.tex`, [warning]),
|
|
46
|
+
result("/work/paper/sections\\win.tex", [warning]),
|
|
47
|
+
result(paperDir, [warning]),
|
|
48
|
+
],
|
|
49
|
+
paperDir,
|
|
50
|
+
);
|
|
51
|
+
expect(found).toStrictEqual(
|
|
52
|
+
ok([
|
|
53
|
+
{ ...warning, file: "sections/intro.tex" },
|
|
54
|
+
{ ...warning, file: "sections/win.tex" },
|
|
55
|
+
{ ...warning, file: "." },
|
|
56
|
+
]),
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("a fatal message makes the whole lint fail, one line per fatal message", () => {
|
|
61
|
+
const found = lintFindings(
|
|
62
|
+
[
|
|
63
|
+
result(`${paperDir}/a.tex`, [warning, fatal]),
|
|
64
|
+
result(`${paperDir}/b.tex`, [{ ...fatal, line: 9, message: "Broken" }]),
|
|
65
|
+
],
|
|
66
|
+
paperDir,
|
|
67
|
+
);
|
|
68
|
+
expect(found).toStrictEqual(
|
|
69
|
+
err("a.tex:5:1 — Parsing error\nb.tex:9:1 — Broken"),
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("the linter reports the lint of what the run produced", async () => {
|
|
74
|
+
const lint = submissionLinter(
|
|
75
|
+
(_dir, _cwd, onResults: OnLintResults) => {
|
|
76
|
+
onResults([result(`${paperDir}/a.tex`, [warning])]);
|
|
77
|
+
return Promise.resolve("");
|
|
78
|
+
},
|
|
79
|
+
() => null,
|
|
80
|
+
);
|
|
81
|
+
expect(await lint(paperDir, "/work")).toStrictEqual(
|
|
82
|
+
ok({
|
|
83
|
+
errors: [],
|
|
84
|
+
warnings: [{ ...warning, file: "a.tex" }],
|
|
85
|
+
abstractWarnings: [],
|
|
86
|
+
introductionWarnings: [],
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("the linter passes the paper and the working directory to the run", async () => {
|
|
92
|
+
const seen: (readonly [string, string])[] = [];
|
|
93
|
+
const lint = submissionLinter(
|
|
94
|
+
(dir, cwd, onResults) => {
|
|
95
|
+
seen.push([dir, cwd]);
|
|
96
|
+
onResults([]);
|
|
97
|
+
return Promise.resolve("");
|
|
98
|
+
},
|
|
99
|
+
() => null,
|
|
100
|
+
);
|
|
101
|
+
await lint(paperDir, "/elsewhere");
|
|
102
|
+
expect(seen).toStrictEqual([[paperDir, "/elsewhere"]]);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("a fatal message in the run's results is the linter's failure", async () => {
|
|
106
|
+
const lint = submissionLinter(
|
|
107
|
+
(_dir, _cwd, onResults) => {
|
|
108
|
+
onResults([result(`${paperDir}/a.tex`, [fatal])]);
|
|
109
|
+
return Promise.resolve("");
|
|
110
|
+
},
|
|
111
|
+
() => null,
|
|
112
|
+
);
|
|
113
|
+
expect(await lint(paperDir, "/work")).toStrictEqual(
|
|
114
|
+
err("a.tex:5:1 — Parsing error"),
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("a run that ends with a problem and no report is the linter's failure with that problem", async () => {
|
|
119
|
+
const lint = submissionLinter(
|
|
120
|
+
() => Promise.resolve("no config found"),
|
|
121
|
+
() => null,
|
|
122
|
+
);
|
|
123
|
+
expect(await lint(paperDir, "/work")).toStrictEqual(err("no config found"));
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("a run that ends silently without a report fails, and says so", async () => {
|
|
127
|
+
const lint = submissionLinter(
|
|
128
|
+
() => Promise.resolve(""),
|
|
129
|
+
() => null,
|
|
130
|
+
);
|
|
131
|
+
expect(await lint(paperDir, "/work")).toStrictEqual(
|
|
132
|
+
err("paperlint lint did not produce a report"),
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test("a run that throws is the linter's failure with the error's message", async () => {
|
|
137
|
+
const lint = submissionLinter(
|
|
138
|
+
() => Promise.reject(new Error("boom")),
|
|
139
|
+
() => null,
|
|
140
|
+
);
|
|
141
|
+
expect(await lint(paperDir, "/work")).toStrictEqual(err("boom"));
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("an empty lint set is recognised by ESLint's message template or its wording, and nothing else is", () => {
|
|
145
|
+
expect([
|
|
146
|
+
isEmptyLintSet({ messageTemplate: "file-not-found" }),
|
|
147
|
+
isEmptyLintSet({ messageTemplate: "all-matched-files-ignored" }),
|
|
148
|
+
isEmptyLintSet(new Error("No files matching 'x' were found.")),
|
|
149
|
+
isEmptyLintSet(new Error("disk on fire")),
|
|
150
|
+
isEmptyLintSet("not an error object"),
|
|
151
|
+
]).toStrictEqual([true, true, true, false, false]);
|
|
152
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ESLint } from "eslint";
|
|
2
|
+
import { relative } from "node:path";
|
|
3
|
+
import { flatMap, map, partition } from "remeda";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { err, ok, type Result } from "../../domain/result.ts";
|
|
6
|
+
import {
|
|
7
|
+
lintFindingLine,
|
|
8
|
+
submissionLint,
|
|
9
|
+
type LintFinding,
|
|
10
|
+
type PaperSections,
|
|
11
|
+
} from "../../domain/submission-lint.ts";
|
|
12
|
+
import { messageOf } from "../../domain/text.ts";
|
|
13
|
+
import type { SubmissionLinter } from "../../ports/submission-lint.ts";
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
LINT_FORMAT,
|
|
17
|
+
lintExitCode,
|
|
18
|
+
lintResultFor,
|
|
19
|
+
lintText,
|
|
20
|
+
printLintResults,
|
|
21
|
+
} from "./report.io.ts";
|
|
22
|
+
|
|
23
|
+
const lintFailure = z
|
|
24
|
+
.object({
|
|
25
|
+
messageTemplate: z.string().optional(),
|
|
26
|
+
message: z.string().optional(),
|
|
27
|
+
})
|
|
28
|
+
.catch({});
|
|
29
|
+
|
|
30
|
+
/** ESLint throws when the paths match no files or only ignored files. */
|
|
31
|
+
export function isEmptyLintSet(e: unknown): boolean {
|
|
32
|
+
const { messageTemplate, message } = lintFailure.parse(e);
|
|
33
|
+
return (
|
|
34
|
+
messageTemplate === "file-not-found" ||
|
|
35
|
+
messageTemplate === "all-matched-files-ignored" ||
|
|
36
|
+
message?.toLowerCase().includes("no files matching") === true
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Translate ESLint's structured diagnostics at the adapter boundary. */
|
|
41
|
+
export function lintFindings(
|
|
42
|
+
results: readonly ESLint.LintResult[],
|
|
43
|
+
paperDir: string,
|
|
44
|
+
): Result<readonly LintFinding[], string> {
|
|
45
|
+
const [fatal, findings] = partition(
|
|
46
|
+
flatMap(results, ({ filePath, messages }) =>
|
|
47
|
+
map(messages, (m) => ({
|
|
48
|
+
...m,
|
|
49
|
+
file: relative(paperDir, filePath).replaceAll("\\", "/") || ".",
|
|
50
|
+
})),
|
|
51
|
+
),
|
|
52
|
+
(m) => m.fatal === true,
|
|
53
|
+
);
|
|
54
|
+
return fatal.length === 0
|
|
55
|
+
? ok(findings)
|
|
56
|
+
: err(map(fatal, lintFindingLine).join("\n"));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type OnLintResults = (results: readonly ESLint.LintResult[]) => void;
|
|
60
|
+
type RunPaperLint = (
|
|
61
|
+
paperDir: string,
|
|
62
|
+
cwd: string,
|
|
63
|
+
onResults: OnLintResults,
|
|
64
|
+
) => Promise<string>;
|
|
65
|
+
|
|
66
|
+
export const submissionLinter =
|
|
67
|
+
(
|
|
68
|
+
runLint: RunPaperLint,
|
|
69
|
+
sectionsOf: (paperDir: string) => PaperSections | null,
|
|
70
|
+
): SubmissionLinter =>
|
|
71
|
+
(paperDir, cwd) =>
|
|
72
|
+
new Promise((settle) => {
|
|
73
|
+
const accept: OnLintResults = (results) => {
|
|
74
|
+
const findings = lintFindings(results, paperDir);
|
|
75
|
+
settle(
|
|
76
|
+
findings.ok
|
|
77
|
+
? ok(submissionLint(findings.value, sectionsOf(paperDir)))
|
|
78
|
+
: findings,
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
void runLint(paperDir, cwd, accept).then(
|
|
82
|
+
(problem) => {
|
|
83
|
+
settle(err(problem || "paperlint lint did not produce a report"));
|
|
84
|
+
},
|
|
85
|
+
(e: unknown) => {
|
|
86
|
+
settle(err(messageOf(e)));
|
|
87
|
+
},
|
|
88
|
+
);
|
|
89
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ESLint } from "eslint";
|
|
2
|
+
import { map, omit, sumBy } from "remeda";
|
|
3
|
+
|
|
4
|
+
export const LINT_FORMAT = "stylish";
|
|
5
|
+
|
|
6
|
+
export function lintResultFor(
|
|
7
|
+
file: string,
|
|
8
|
+
messages: readonly ESLint.LintResult["messages"][number][],
|
|
9
|
+
): Readonly<ESLint.LintResult> {
|
|
10
|
+
const errorCount = messages.filter((m) => m.severity === 2).length;
|
|
11
|
+
return {
|
|
12
|
+
filePath: file,
|
|
13
|
+
messages: [...messages],
|
|
14
|
+
suppressedMessages: [],
|
|
15
|
+
errorCount,
|
|
16
|
+
fatalErrorCount: 0,
|
|
17
|
+
warningCount: messages.length - errorCount,
|
|
18
|
+
fixableErrorCount: 0,
|
|
19
|
+
fixableWarningCount: 0,
|
|
20
|
+
usedDeprecatedRules: [],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Print the venue findings in the same format as the standalone lint command. */
|
|
25
|
+
export async function lintText(
|
|
26
|
+
file: string,
|
|
27
|
+
messages: readonly ESLint.LintResult["messages"][number][],
|
|
28
|
+
): Promise<string> {
|
|
29
|
+
return (await new ESLint().loadFormatter(LINT_FORMAT)).format([
|
|
30
|
+
lintResultFor(file, messages),
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface ReportFormat {
|
|
35
|
+
readonly json: boolean;
|
|
36
|
+
readonly structure: readonly ESLint.LintResult[];
|
|
37
|
+
readonly structureText: string;
|
|
38
|
+
readonly log: (line: string) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function printLintResults(
|
|
42
|
+
eslint: ESLint,
|
|
43
|
+
results: readonly ESLint.LintResult[],
|
|
44
|
+
{ json, structure, structureText, log }: ReportFormat,
|
|
45
|
+
): Promise<boolean> {
|
|
46
|
+
if (json) {
|
|
47
|
+
log(
|
|
48
|
+
JSON.stringify(
|
|
49
|
+
[...structure, ...map(results, (r) => omit(r, ["stats"]))],
|
|
50
|
+
null,
|
|
51
|
+
1,
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (structure.length > 0) log(structureText);
|
|
57
|
+
const out = await (
|
|
58
|
+
await eslint.loadFormatter(LINT_FORMAT)
|
|
59
|
+
).format([...results]);
|
|
60
|
+
const clean = out.trim() === "" && structure.length === 0;
|
|
61
|
+
log(
|
|
62
|
+
out.trim() ||
|
|
63
|
+
(clean ? `✓ ${String(results.length)} file(s) checked, no findings` : ""),
|
|
64
|
+
);
|
|
65
|
+
return clean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function lintExitCode(
|
|
69
|
+
results: readonly ESLint.LintResult[],
|
|
70
|
+
hasStructureErrors: boolean,
|
|
71
|
+
maxWarnings: number,
|
|
72
|
+
err: (line: string) => void,
|
|
73
|
+
): number {
|
|
74
|
+
if (hasStructureErrors || results.some((r) => r.errorCount > 0)) return 1;
|
|
75
|
+
if (maxWarnings < 0) return 0;
|
|
76
|
+
const warnings = sumBy(results, (r) => r.warningCount);
|
|
77
|
+
if (!(warnings > maxWarnings)) return 0;
|
|
78
|
+
err(
|
|
79
|
+
`${String(warnings)} warning(s) exceed the --max-warnings limit of ${String(maxWarnings)}`,
|
|
80
|
+
);
|
|
81
|
+
return 1;
|
|
82
|
+
}
|