paperlint 20.5.0 → 20.6.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/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 +11 -8
- 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 +6 -2
- package/dist/corpus-layout-rule.d.ts.map +1 -1
- package/dist/corpus-layout-rule.js +6 -2
- package/dist/corpus-layout-rule.js.map +1 -1
- 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 +4 -2
- package/dist/corpus-record-rule.js.map +1 -1
- 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/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/optional-rules.md +11 -10
- package/docs/rules/corpus/allowed-files-only.md +9 -8
- package/docs/rules/corpus/licence.md +125 -0
- package/docs/rules/corpus/record.md +6 -3
- package/docs/rules.md +3 -2
- package/docs/venues.md +8 -8
- 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.ts +13 -11
- package/src/corpus-json-rules.ts +22 -0
- package/src/corpus-layout-rule.test.ts +3 -1
- package/src/corpus-layout-rule.ts +7 -3
- package/src/corpus-licence-rule.test.ts +217 -0
- package/src/corpus-licence-rule.ts +94 -0
- package/src/corpus-record-rule.test.ts +12 -0
- package/src/corpus-record-rule.ts +6 -2
- 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/rule-cases.test.ts +2 -44
- package/src/rule-id-shape.test.ts +42 -0
- package/dist/skill-chunks/{chunk-CXAGKT44.js → chunk-EDHTB7KT.js} +4 -4
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `corpus/licence`'s judgement of one venue corpus (docs/design/venue-corpus.md, decisions 3 and 4;
|
|
3
|
+
* docs/rules/corpus/licence.md): whether the licence of each copy permits keeping each kind it
|
|
4
|
+
* stores. Pure: the record, already parsed by the codec, and the one setting in; the findings out.
|
|
5
|
+
* What a licence permits is the table in `licence.ts`, asked here and never copied.
|
|
6
|
+
*/
|
|
7
|
+
import { groupBy } from "remeda";
|
|
8
|
+
import { storedAt } from "./corpus-record.ts";
|
|
9
|
+
import {
|
|
10
|
+
permits,
|
|
11
|
+
type LicenceSettings,
|
|
12
|
+
type Permission,
|
|
13
|
+
type StoredKind,
|
|
14
|
+
} from "./licence.ts";
|
|
15
|
+
import type { Copy, RecordPath, VenueCorpus } from "./venue-corpus.ts";
|
|
16
|
+
|
|
17
|
+
/** What stands against storing one kind of one copy: any permission but the one that allows it. */
|
|
18
|
+
export type Refusal = Exclude<Permission, { readonly kind: "permitted" }>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The kinds of one copy that one refusal stands against, with `at`, the copy's `stored` in `papers.json`.
|
|
22
|
+
* A copy whose kinds are refused for the same reason is one finding naming them all; ND, which
|
|
23
|
+
* refuses one kind and not the other, gives one finding for that kind.
|
|
24
|
+
*/
|
|
25
|
+
export interface LicenceFinding {
|
|
26
|
+
readonly at: RecordPath;
|
|
27
|
+
readonly key: string;
|
|
28
|
+
readonly licence: string;
|
|
29
|
+
readonly stored: readonly [StoredKind, ...StoredKind[]];
|
|
30
|
+
readonly refusal: Refusal;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** One stored kind of a copy and what refuses it. */
|
|
34
|
+
interface Refused {
|
|
35
|
+
readonly stored: StoredKind;
|
|
36
|
+
readonly refusal: Refusal;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The stored kinds of `copy` its licence refuses, in its `stored` order. */
|
|
40
|
+
const refusedKinds = (
|
|
41
|
+
copy: Readonly<Copy>,
|
|
42
|
+
settings: Readonly<LicenceSettings>,
|
|
43
|
+
): readonly Refused[] =>
|
|
44
|
+
copy.stored.flatMap((stored) => {
|
|
45
|
+
const refusal = permits(copy.licence.id, stored, settings);
|
|
46
|
+
return refusal.kind === "permitted" ? [] : [{ stored, refusal }];
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/** The refusals of one copy, one per reason (two refusals that print the same message are one), each with its kinds. */
|
|
50
|
+
const byReason = (
|
|
51
|
+
refused: readonly Refused[],
|
|
52
|
+
): readonly Pick<LicenceFinding, "stored" | "refusal">[] =>
|
|
53
|
+
Object.values(groupBy(refused, (r) => JSON.stringify(r.refusal))).map(
|
|
54
|
+
([first, ...rest]) => ({
|
|
55
|
+
stored: [first.stored, ...rest.map((r) => r.stored)],
|
|
56
|
+
refusal: first.refusal,
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
/** Every refusal of every copy, with the stored kinds it stands against, in the record's order. */
|
|
61
|
+
export const judgeLicences = (
|
|
62
|
+
corpus: VenueCorpus,
|
|
63
|
+
settings: Readonly<LicenceSettings>,
|
|
64
|
+
): readonly LicenceFinding[] =>
|
|
65
|
+
corpus.papers.flatMap((p, paper) =>
|
|
66
|
+
p.copies.flatMap((c, copy) =>
|
|
67
|
+
byReason(refusedKinds(c, settings)).map((r) => ({
|
|
68
|
+
at: storedAt(paper, [copy]),
|
|
69
|
+
key: p.key,
|
|
70
|
+
licence: c.licence.id,
|
|
71
|
+
...r,
|
|
72
|
+
})),
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const FILE: Readonly<Record<StoredKind, string>> = {
|
|
77
|
+
pdf: "pdf/<key>.pdf",
|
|
78
|
+
text: "text/<key>.txt",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/** The text of a finding: what is wrong, then what to do. */
|
|
82
|
+
export function licenceMessage(f: LicenceFinding): string {
|
|
83
|
+
const kinds = f.stored.map((k) => `\`${k}\``).join(" and ");
|
|
84
|
+
const files = f.stored.map((k) => `\`${FILE[k]}\``).join(", ");
|
|
85
|
+
const quoted = f.stored.map((k) => `\`"${k}"\``).join(" and ");
|
|
86
|
+
const it = f.stored.length === 1 ? "it" : "them";
|
|
87
|
+
const what = `a copy of \`${f.key}\` stores ${kinds} (${files})`;
|
|
88
|
+
const remove = `remove ${f.stored.length === 1 ? "the file" : "the files"} and ${quoted} from that copy's \`stored\`, and keep the paper's ids`;
|
|
89
|
+
switch (f.refusal.kind) {
|
|
90
|
+
case "not-read":
|
|
91
|
+
return `${what}, and no licence was read for that copy (\`NOASSERTION\`). What to do: record the licence and where it was read (\`licence.id\`, \`read_from\`, \`read_on\`), or ${remove}`;
|
|
92
|
+
case "unlisted":
|
|
93
|
+
return `${what} under \`${f.refusal.id}\`, and the licence table does not list that id, so it permits nothing. What to do: correct the id if it is misspelt; otherwise ${remove}`;
|
|
94
|
+
case "forbidden":
|
|
95
|
+
return `${what} under \`${f.licence}\`, which does not permit ${it}: ${f.refusal.why}. What to do: ${remove}`;
|
|
96
|
+
case "non-commercial-only":
|
|
97
|
+
return `${what} under \`${f.licence}\`, which permits ${it} only in a non-commercial project, and this one has not declared itself one. What to do: if it is one, set \`"corpus/licence": ["warn", { "nonCommercial": true }]\` in the root \`paperlint.json\`; otherwise ${remove}`;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -37,7 +37,7 @@ const folder = (
|
|
|
37
37
|
record: CorpusFolder["record"],
|
|
38
38
|
pdf: readonly string[] = [],
|
|
39
39
|
text: readonly string[] = [],
|
|
40
|
-
): CorpusFolder => ({ record, stored: { pdf, text } });
|
|
40
|
+
): CorpusFolder => ({ folder: "agent", record, stored: { pdf, text } });
|
|
41
41
|
|
|
42
42
|
const read = (papers: readonly Paper[]): CorpusFolder["record"] => ({
|
|
43
43
|
ok: true,
|
|
@@ -61,6 +61,12 @@ describe("storedKey: the paper a stored file's name belongs to", () => {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
describe("judgeCorpus", () => {
|
|
64
|
+
it("names a record whose venue is not its folder's name, at the venue field", () => {
|
|
65
|
+
expect(judgeCorpus({ ...folder(read([])), folder: "other" })).toEqual([
|
|
66
|
+
{ kind: "venue", at: ["venue"], venue: "agent", folder: "other" },
|
|
67
|
+
]);
|
|
68
|
+
});
|
|
69
|
+
|
|
64
70
|
it("is silent when every stored file is claimed by exactly one copy and exists", () => {
|
|
65
71
|
expect(
|
|
66
72
|
judgeCorpus(
|
|
@@ -23,6 +23,8 @@ export const CORPORA_DIR = "venues";
|
|
|
23
23
|
|
|
24
24
|
/** What the rule reads of one corpus folder. */
|
|
25
25
|
export interface CorpusFolder {
|
|
26
|
+
/** The corpus folder's name: the venue preset's series, which the record's `venue` must repeat. */
|
|
27
|
+
readonly folder: string;
|
|
26
28
|
/** `papers.json`, as the codec parsed it. */
|
|
27
29
|
readonly record: ParsedCorpus;
|
|
28
30
|
/** The names in `pdf/` and in `text/`, hidden ones left out; none when the folder is absent. */
|
|
@@ -35,6 +37,11 @@ export interface CorpusFolder {
|
|
|
35
37
|
*/
|
|
36
38
|
export type CorpusFinding = { readonly at: RecordPath } & (
|
|
37
39
|
| { readonly kind: "unparsed"; readonly message: string }
|
|
40
|
+
| {
|
|
41
|
+
readonly kind: "venue";
|
|
42
|
+
readonly venue: string;
|
|
43
|
+
readonly folder: string;
|
|
44
|
+
}
|
|
38
45
|
| {
|
|
39
46
|
readonly kind: "unclaimed";
|
|
40
47
|
readonly file: string;
|
|
@@ -95,13 +102,10 @@ interface Claim {
|
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
/** The `stored` of a paper's copy (`copy` holds its index), as a path. */
|
|
98
|
-
const storedAt = (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
...copy,
|
|
103
|
-
"stored",
|
|
104
|
-
];
|
|
105
|
+
export const storedAt = (
|
|
106
|
+
paper: number,
|
|
107
|
+
copy: readonly number[],
|
|
108
|
+
): RecordPath => ["papers", paper, "copies", ...copy, "stored"];
|
|
105
109
|
|
|
106
110
|
/** A paper's kind stored by more than one of its copies, reported at the second one. */
|
|
107
111
|
const twice = (claims: readonly Claim[]): readonly CorpusFinding[] =>
|
|
@@ -162,11 +166,21 @@ const missing = (
|
|
|
162
166
|
file: expectedFile(c.kind, c.key),
|
|
163
167
|
}));
|
|
164
168
|
|
|
169
|
+
/** The record's `venue`, when it is not the name of the folder it stands in. */
|
|
170
|
+
const venueName = (
|
|
171
|
+
corpus: VenueCorpus,
|
|
172
|
+
folder: string,
|
|
173
|
+
): readonly CorpusFinding[] =>
|
|
174
|
+
corpus.venue === folder
|
|
175
|
+
? []
|
|
176
|
+
: [{ kind: "venue", at: ["venue"], venue: corpus.venue, folder }];
|
|
177
|
+
|
|
165
178
|
/** What a read record says about the folder. */
|
|
166
179
|
function judgeRecord(
|
|
167
180
|
corpus: VenueCorpus,
|
|
168
|
-
|
|
181
|
+
folder: CorpusFolder,
|
|
169
182
|
): readonly CorpusFinding[] {
|
|
183
|
+
const { stored } = folder;
|
|
170
184
|
const claims = STORED_KINDS.flatMap((kind) =>
|
|
171
185
|
corpus.papers.map((p, paper) => ({
|
|
172
186
|
kind,
|
|
@@ -176,6 +190,7 @@ function judgeRecord(
|
|
|
176
190
|
})),
|
|
177
191
|
);
|
|
178
192
|
return [
|
|
193
|
+
...venueName(corpus, folder.folder),
|
|
179
194
|
...twice(claims),
|
|
180
195
|
...unclaimed(claims, stored),
|
|
181
196
|
...missing(claims, stored),
|
|
@@ -185,7 +200,7 @@ function judgeRecord(
|
|
|
185
200
|
/** Every finding about one corpus folder; none for a corpus whose record accounts for each copy. */
|
|
186
201
|
export const judgeCorpus = (folder: CorpusFolder): readonly CorpusFinding[] =>
|
|
187
202
|
folder.record.ok
|
|
188
|
-
? judgeRecord(folder.record.corpus, folder
|
|
203
|
+
? judgeRecord(folder.record.corpus, folder)
|
|
189
204
|
: folder.record.problems.map((p) => ({
|
|
190
205
|
kind: "unparsed",
|
|
191
206
|
at: p.path,
|
|
@@ -200,6 +215,8 @@ export function corpusMessage(f: CorpusFinding): string {
|
|
|
200
215
|
switch (f.kind) {
|
|
201
216
|
case "unparsed":
|
|
202
217
|
return `\`${pathText(f.at)}\`: ${f.message}. What to do: correct the field; the fields are in the JSON Schema \`papers.schema.json\` that \`study-accepted-papers\` ships`;
|
|
218
|
+
case "venue":
|
|
219
|
+
return `the record says \`"venue": "${f.venue}"\`, and its folder is \`${f.folder}\`. What to do: rename the folder to \`${f.venue}\`, or correct the field to \`${f.folder}\``;
|
|
203
220
|
case "unclaimed":
|
|
204
221
|
return `\`${f.file}\` is stored, and no copy in \`${CORPUS_RECORD}\` claims it${f.key === null ? `: its name is not \`pdf/<key>.pdf\`, \`text/<key>.txt\` or \`text/<key>.<variant>.txt\`` : ` (no copy of the paper \`${f.key}\` lists it in \`stored\`)`}. What to do: record it under the copy it was fetched from, with \`fetched_from\`, its licence and where the licence was read; ${KEEP_IDS}`;
|
|
205
222
|
case "missing":
|
package/src/domain/edition.ts
CHANGED
|
@@ -13,8 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { sortBy } from "remeda";
|
|
15
15
|
|
|
16
|
-
/** A
|
|
17
|
-
|
|
16
|
+
/** A series: lowercase words and digits joined by hyphens (`icse`, `usenix-sec`). */
|
|
17
|
+
const SERIES = "[a-z0-9]+(?:-[a-z0-9]+)*";
|
|
18
|
+
|
|
19
|
+
/** A venue preset's id: a series, then `-<year>`. */
|
|
20
|
+
export const EDITION_ID = new RegExp(`^(${SERIES})-(\\d{4})$`, "u");
|
|
21
|
+
|
|
22
|
+
/** A series id's shape, the part of an edition's id before its year; whether it ends in a year is `endsInYear`. */
|
|
23
|
+
export const SERIES_ID = new RegExp(`^${SERIES}$`, "u");
|
|
18
24
|
|
|
19
25
|
/** An edition: its series and its year. */
|
|
20
26
|
export interface Edition {
|
|
@@ -25,7 +25,7 @@ const both = (id: string, settings = COMMERCIAL) =>
|
|
|
25
25
|
const PERMITTED = { kind: "permitted" } as const;
|
|
26
26
|
const NC_ONLY = { kind: "non-commercial-only" } as const;
|
|
27
27
|
const ARXIV_WHY =
|
|
28
|
-
'
|
|
28
|
+
'its only grant is to arXiv: "I grant arXiv.org a perpetual, non-exclusive license to distribute this article" (arxiv.org/licenses/nonexclusive-distrib/1.0/license.html), and nothing to anyone else';
|
|
29
29
|
const ND_WHY =
|
|
30
30
|
"ND permits reproduction in unmodified form; whether an extracted text is an adaptation is unsettled";
|
|
31
31
|
|
package/src/domain/licence.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
export const STORED_KINDS = ["text", "pdf"] as const;
|
|
17
17
|
export type StoredKind = (typeof STORED_KINDS)[number];
|
|
18
18
|
|
|
19
|
-
/** SPDX's
|
|
19
|
+
/** SPDX's keyword (not a list id) for "no licence information was given": here, the licence was not read. */
|
|
20
20
|
export const NOASSERTION = "NOASSERTION";
|
|
21
21
|
|
|
22
22
|
/** The project's one setting the table reads: it declares itself non-commercial. */
|
|
@@ -48,7 +48,7 @@ const ND = {
|
|
|
48
48
|
} as const;
|
|
49
49
|
|
|
50
50
|
const ARXIV = {
|
|
51
|
-
no: '
|
|
51
|
+
no: 'its only grant is to arXiv: "I grant arXiv.org a perpetual, non-exclusive license to distribute this article" (arxiv.org/licenses/nonexclusive-distrib/1.0/license.html), and nothing to anyone else',
|
|
52
52
|
} as const;
|
|
53
53
|
|
|
54
54
|
const PUBLISHER = {
|
package/src/rule-cases.test.ts
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
import { recordText } from "../test/recorded-fixture.ts";
|
|
34
34
|
import { lintTree } from "../test/lint-report.ts";
|
|
35
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,35 +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
|
-
},
|
|
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
|
-
},
|
|
1271
|
+
...CORPUS_CASES,
|
|
1314
1272
|
// A loose script at the top of repro/: it belongs in repro/tools/.
|
|
1315
1273
|
"repro/allowed-files-only": {
|
|
1316
1274
|
reports: {
|
|
@@ -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
|
+
});
|
|
@@ -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";
|