paperlint 20.1.0 → 20.1.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/domain/paper-layout.d.ts +18 -6
- package/dist/domain/paper-layout.d.ts.map +1 -1
- package/dist/domain/paper-layout.js +44 -38
- package/dist/domain/paper-layout.js.map +1 -1
- package/dist/folder-layout-hook.js +1 -1
- package/docs/install.md +11 -11
- package/docs/rules/paper/allowed-files-only.md +31 -28
- package/package.json +1 -1
- package/src/cli.harness.mjs +1 -1
- package/src/cli.test.ts +1 -1
- package/src/domain/paper-layout.test.ts +89 -49
- package/src/domain/paper-layout.ts +61 -42
- package/src/folder-layout-hook.test.ts +1 -1
- package/src/folder-layout-hook.ts +1 -1
- package/src/folder-layout-rule.test.ts +1 -1
- package/src/layout-docs.test.ts +47 -0
|
@@ -14,7 +14,7 @@ export interface Stray {
|
|
|
14
14
|
/** The entry's name; a folder's ends in a slash. */
|
|
15
15
|
readonly name: string;
|
|
16
16
|
readonly kind: "file" | "dir";
|
|
17
|
-
/** Where it goes: one destination
|
|
17
|
+
/** Where it goes: one destination, by its name, else by its kind, else `extra/`. */
|
|
18
18
|
readonly cure: string;
|
|
19
19
|
}
|
|
20
20
|
/** The one folder whose content is not judged. */
|
|
@@ -54,13 +54,25 @@ export declare const KNOWN_CURES: readonly {
|
|
|
54
54
|
readonly kind: "file" | "dir";
|
|
55
55
|
readonly cure: string;
|
|
56
56
|
}[];
|
|
57
|
-
/**
|
|
58
|
-
export declare const
|
|
57
|
+
/** The extensions of the images a figure is drawn from. */
|
|
58
|
+
export declare const IMAGE_EXTENSIONS: readonly string[];
|
|
59
|
+
/**
|
|
60
|
+
* For a file nobody listed: the folder its kind names, by its exact name or its extension (matched
|
|
61
|
+
* ignoring case). The same kinds `repro/allowed-files-only` sorts by. No `.pdf`: a root PDF may be
|
|
62
|
+
* a figure, a draft or a review, and `versions/` holds only cycle folders (`versions/layout`).
|
|
63
|
+
*/
|
|
64
|
+
export declare const CURE_BY_FILE: readonly {
|
|
65
|
+
readonly names: readonly string[];
|
|
66
|
+
readonly extensions: readonly string[];
|
|
67
|
+
readonly cure: string;
|
|
68
|
+
}[];
|
|
69
|
+
/** For anything else: the folder that is never judged. */
|
|
70
|
+
export declare const CURE_BY_DEFAULT = "extra/";
|
|
59
71
|
/** The root entries that are not part of the layout, in the order given. Pure. */
|
|
60
72
|
export declare function judgeLayout(entries: readonly LayoutEntry[], declared: Declared): readonly Stray[];
|
|
61
73
|
/** The paper folder's layout, entry by entry, `repro/` drawn with its own layout inside. */
|
|
62
74
|
export declare const PAPER_NODES: readonly TreeNode[];
|
|
63
|
-
/** The drawing of the paper folder's layout
|
|
75
|
+
/** The drawing of the paper folder's layout, which the rule's page embeds. */
|
|
64
76
|
export declare const PAPER_LAYOUT_TREE: string;
|
|
65
77
|
/** The folder beside the paper folders that holds one corpus of accepted papers per venue. */
|
|
66
78
|
export declare const VENUES_DIR = "venues";
|
|
@@ -74,8 +86,8 @@ export declare const PAPERS_NODES: readonly TreeNode[];
|
|
|
74
86
|
export declare const PAPERS_LAYOUT_TREE: string;
|
|
75
87
|
/**
|
|
76
88
|
* The one text a stray entry is reported with, by the rule `paper/allowed-files-only` and by the hook that
|
|
77
|
-
* refuses to create such an entry
|
|
78
|
-
*
|
|
89
|
+
* refuses to create such an entry: one line, the entry and its one destination. The layout, and how
|
|
90
|
+
* each destination is picked, are on the rule's page, which the finding's rule id names.
|
|
79
91
|
*/
|
|
80
92
|
export declare function strayMessage(s: Stray): string;
|
|
81
93
|
//# sourceMappingURL=paper-layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paper-layout.d.ts","sourceRoot":"","sources":["../../src/domain/paper-layout.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"paper-layout.d.ts","source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
|
33
33
|
import { leaf, renderTree } from "./layout-tree.js";
|
|
34
|
-
import { REPRO_DIR, REPRO_NODES } from "./repro-layout.js";
|
|
34
|
+
import { DATA_EXTENSIONS, NOTE_EXTENSIONS, REPRO_DIR, REPRO_NODES, SCRIPT_EXTENSIONS, TOOL_FILES, } from "./repro-layout.js";
|
|
35
35
|
export const NOTHING_DECLARED = { roots: [] };
|
|
36
36
|
/** The one folder whose content is not judged. */
|
|
37
37
|
export const ESCAPE_HATCH = "extra";
|
|
@@ -146,9 +146,9 @@ export const BUILD_BYPRODUCTS = BYPRODUCT_EXTENSIONS.map((ext) => `paper.${ext}`
|
|
|
146
146
|
/** Files the operating system writes into any folder it shows. Never reported. */
|
|
147
147
|
export const OS_FILES = [".DS_Store", "Thumbs.db"];
|
|
148
148
|
/** The live state of a paper — its stages, its plan, its scorecard — is one file. */
|
|
149
|
-
const STATUS_SECTIONS =
|
|
150
|
-
/** The shared corpus of a venue's accepted papers. */
|
|
151
|
-
const VENUE_CORPUS = "<papers-root>/venues/<venue
|
|
149
|
+
const STATUS_SECTIONS = "a section of PIPELINE-STATUS.md";
|
|
150
|
+
/** The shared corpus of a venue's accepted papers, outside every paper folder. */
|
|
151
|
+
const VENUE_CORPUS = "<papers-root>/venues/<venue>/";
|
|
152
152
|
/**
|
|
153
153
|
* Names met in real paper folders, each with its one destination. Matched ignoring case, a file's
|
|
154
154
|
* name against files and a folder's against folders.
|
|
@@ -156,32 +156,36 @@ const VENUE_CORPUS = "<papers-root>/venues/<venue>/, outside the paper folder: o
|
|
|
156
156
|
export const KNOWN_CURES = [
|
|
157
157
|
{ name: "PLAN.md", kind: "file", cure: STATUS_SECTIONS },
|
|
158
158
|
{ name: "plans", kind: "dir", cure: STATUS_SECTIONS },
|
|
159
|
-
{ name: "DECISION-LOG.md", kind: "file", cure: "research/
|
|
160
|
-
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
name: "data",
|
|
167
|
-
kind: "dir",
|
|
168
|
-
cure: "repro/data/ (the data behind the numbers)",
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
name: "artifact",
|
|
172
|
-
kind: "dir",
|
|
173
|
-
cure: "repro/ — its scripts in repro/tools/, its data in repro/data/; the anonymized copy uploaded for review is about submitting and goes in submission/",
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
name: "archive",
|
|
177
|
-
kind: "dir",
|
|
178
|
-
cure: "versions/ for frozen PDFs, submission/ for an earlier attempt's forms, mails and checklists, extra/ for the rest",
|
|
179
|
-
},
|
|
159
|
+
{ name: "DECISION-LOG.md", kind: "file", cure: "research/" },
|
|
160
|
+
{ name: "EMAILS.md", kind: "file", cure: "submission/" },
|
|
161
|
+
{ name: "data", kind: "dir", cure: "repro/data/" },
|
|
162
|
+
{ name: "artifact", kind: "dir", cure: "repro/" },
|
|
163
|
+
{ name: "archive", kind: "dir", cure: `${ESCAPE_HATCH}/` },
|
|
180
164
|
{ name: "venue-corpus", kind: "dir", cure: VENUE_CORPUS },
|
|
181
165
|
{ name: "venues", kind: "dir", cure: VENUE_CORPUS },
|
|
182
166
|
];
|
|
183
|
-
/**
|
|
184
|
-
export const
|
|
167
|
+
/** The extensions of the images a figure is drawn from. */
|
|
168
|
+
export const IMAGE_EXTENSIONS = [
|
|
169
|
+
".png",
|
|
170
|
+
".jpg",
|
|
171
|
+
".jpeg",
|
|
172
|
+
".gif",
|
|
173
|
+
".svg",
|
|
174
|
+
".eps",
|
|
175
|
+
];
|
|
176
|
+
/**
|
|
177
|
+
* For a file nobody listed: the folder its kind names, by its exact name or its extension (matched
|
|
178
|
+
* ignoring case). The same kinds `repro/allowed-files-only` sorts by. No `.pdf`: a root PDF may be
|
|
179
|
+
* a figure, a draft or a review, and `versions/` holds only cycle folders (`versions/layout`).
|
|
180
|
+
*/
|
|
181
|
+
export const CURE_BY_FILE = [
|
|
182
|
+
{ names: TOOL_FILES, extensions: SCRIPT_EXTENSIONS, cure: "repro/tools/" },
|
|
183
|
+
{ names: [], extensions: DATA_EXTENSIONS, cure: "repro/data/" },
|
|
184
|
+
{ names: [], extensions: IMAGE_EXTENSIONS, cure: "figures/" },
|
|
185
|
+
{ names: [], extensions: NOTE_EXTENSIONS, cure: "research/" },
|
|
186
|
+
];
|
|
187
|
+
/** For anything else: the folder that is never judged. */
|
|
188
|
+
export const CURE_BY_DEFAULT = `${ESCAPE_HATCH}/`;
|
|
185
189
|
const isAllowedFile = (name, declared) => ROOT_FILES.includes(name) ||
|
|
186
190
|
TEX_INPUT_EXTENSIONS.includes(extname(name)) ||
|
|
187
191
|
BUILD_BYPRODUCTS.includes(name) ||
|
|
@@ -190,10 +194,16 @@ const isAllowedFile = (name, declared) => ROOT_FILES.includes(name) ||
|
|
|
190
194
|
const isAllowed = (e, declared) => e.kind === "dir"
|
|
191
195
|
? ROOT_DIRS.includes(e.name) || declared.roots.includes(e.name)
|
|
192
196
|
: isAllowedFile(e.name, declared);
|
|
193
|
-
/** Where
|
|
197
|
+
/** Where `e` belongs: its listed destination, else its kind's folder, else `extra/`. */
|
|
194
198
|
function cureFor(e) {
|
|
195
199
|
const known = KNOWN_CURES.find((c) => c.kind === e.kind && c.name.toLowerCase() === e.name.toLowerCase());
|
|
196
|
-
|
|
200
|
+
if (known !== undefined)
|
|
201
|
+
return known.cure;
|
|
202
|
+
const ext = extname(e.name).toLowerCase();
|
|
203
|
+
const byKind = e.kind === "file"
|
|
204
|
+
? CURE_BY_FILE.find((c) => c.names.includes(e.name) || c.extensions.includes(ext))
|
|
205
|
+
: undefined;
|
|
206
|
+
return byKind?.cure ?? CURE_BY_DEFAULT;
|
|
197
207
|
}
|
|
198
208
|
/** The root entries that are not part of the layout, in the order given. Pure. */
|
|
199
209
|
export function judgeLayout(entries, declared) {
|
|
@@ -221,7 +231,7 @@ export const PAPER_NODES = [
|
|
|
221
231
|
children: d.name === REPRO_DIR ? REPRO_NODES : [],
|
|
222
232
|
})),
|
|
223
233
|
];
|
|
224
|
-
/** The drawing of the paper folder's layout
|
|
234
|
+
/** The drawing of the paper folder's layout, which the rule's page embeds. */
|
|
225
235
|
export const PAPER_LAYOUT_TREE = renderTree("<paper>/", PAPER_NODES);
|
|
226
236
|
/** The folder beside the paper folders that holds one corpus of accepted papers per venue. */
|
|
227
237
|
export const VENUES_DIR = "venues";
|
|
@@ -248,15 +258,11 @@ export const PAPERS_NODES = [
|
|
|
248
258
|
export const PAPERS_LAYOUT_TREE = renderTree("<papers-root>/", PAPERS_NODES);
|
|
249
259
|
/**
|
|
250
260
|
* The one text a stray entry is reported with, by the rule `paper/allowed-files-only` and by the hook that
|
|
251
|
-
* refuses to create such an entry
|
|
252
|
-
*
|
|
261
|
+
* refuses to create such an entry: one line, the entry and its one destination. The layout, and how
|
|
262
|
+
* each destination is picked, are on the rule's page, which the finding's rule id names.
|
|
253
263
|
*/
|
|
254
264
|
export function strayMessage(s) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
`The layout (${ESCAPE_HATCH}/ takes anything and is never judged; the build's paper.* byproducts are never reported):`,
|
|
258
|
-
PAPER_LAYOUT_TREE,
|
|
259
|
-
`Rule paper/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/paper/allowed-files-only.md`,
|
|
260
|
-
].join("\n");
|
|
265
|
+
const fallback = s.cure === CURE_BY_DEFAULT ? "the folder for its kind" : CURE_BY_DEFAULT;
|
|
266
|
+
return `\`${s.name}\` does not belong at a paper folder's root: move it to ${s.cure}, or ${fallback}.`;
|
|
261
267
|
}
|
|
262
268
|
//# sourceMappingURL=paper-layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paper-layout.js","sourceRoot":"","sources":["../../src/domain/paper-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,IAAI,EA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,QAAQ,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE;KAClD,CAAC,CAAC;CACJ,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,iBAAiB,GAAW,UAAU,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAE7E,8FAA8F;AAC9F,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAwB;IAC/C;QACE,IAAI,EAAE,GAAG,UAAU,GAAG;QACtB,IAAI,EAAE,kDAAkD;QACxD,QAAQ,EAAE;YACR,IAAI,CACF,UAAU,EACV,iEAAiE,CAClE;SACF;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,+EAA+E;QACrF,QAAQ,EAAE,WAAW;KACtB;CACF,CAAC;AAEF,yGAAyG;AACzG,MAAM,CAAC,MAAM,kBAAkB,GAAW,UAAU,CAClD,gBAAgB,EAChB,YAAY,CACb,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAQ;IACnC,MAAM,QAAQ,GACZ,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,eAAe,CAAC;IAC3E,OAAO,KAAK,CAAC,CAAC,IAAI,2DAA2D,CAAC,CAAC,IAAI,QAAQ,QAAQ,GAAG,CAAC;AACzG,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* created, not at the next lint. PreToolUse on `Edit|Write|MultiEdit` (`plugin/hooks/hooks.json`):
|
|
4
4
|
* when the file about to be written does not exist yet and would add an entry the layout does not
|
|
5
5
|
* allow — at a paper folder's root, or at the top of its `repro/` — the call is denied, and the
|
|
6
|
-
* reason is the rule's own message: where the entry goes
|
|
6
|
+
* reason is the rule's own message: where the entry goes (for `repro/`, also its layout drawn). The agent writes it
|
|
7
7
|
* where it belongs instead, in the same turn.
|
|
8
8
|
*
|
|
9
9
|
* ── WHAT IT NEVER BLOCKS ─────────────────────────────────────────────────────────
|
package/docs/install.md
CHANGED
|
@@ -232,14 +232,14 @@ Neither `paperlint lint` nor any of the five hooks loads `@ast-grep` or `typescr
|
|
|
232
232
|
|
|
233
233
|
## Troubleshooting
|
|
234
234
|
|
|
235
|
-
| symptom
|
|
236
|
-
|
|
|
237
|
-
| `init`: skills "nothing linked", or hooks that fail to start
|
|
238
|
-
| `paperlint lint`: `no papers in papers/`
|
|
239
|
-
| hooks fail with `Cannot find module` in a fresh clone
|
|
240
|
-
| `paperlint: not built`
|
|
241
|
-
| a skill does not show up in Claude Code
|
|
242
|
-
| a Write of a new file is denied: "…
|
|
243
|
-
| after an edit, Claude Code shows "paperlint lint-edited: the edit was kept; the errors above are the ones it introduced."
|
|
244
|
-
| `paperlint: the lint-edited hook did not run: …` on stderr
|
|
245
|
-
| anything else
|
|
235
|
+
| symptom | cause and fix |
|
|
236
|
+
| ------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
237
|
+
| `init`: skills "nothing linked", or hooks that fail to start | the package is not installed in this project (`npx` ran a temporary copy). Run `npm i -D paperlint`, then `npx paperlint init` again |
|
|
238
|
+
| `paperlint lint`: `no papers in papers/` | there is no paper where `papersDir` points. Create one with `npx paperlint new <name>`, or set `"papersDir"` in `paperlint.json` |
|
|
239
|
+
| hooks fail with `Cannot find module` in a fresh clone | the hook commands run files in `node_modules`: run `npm install` |
|
|
240
|
+
| `paperlint: not built` | installed from git with `--ignore-scripts`, or a clone before building: run `npm run build` in the package |
|
|
241
|
+
| a skill does not show up in Claude Code | its name was already taken in `.claude/skills/`. `init` names it and leaves it alone; rename or remove yours and run `npx paperlint init` again |
|
|
242
|
+
| a Write of a new file is denied: "… does not belong at a paper folder's root" or "… is loose at the top of the paper's repro/ folder" | `paper-folder-layout` refuses to create an entry the paper layout does not allow; the reason says where it goes. Write it there. Existing files are never refused, and the hook does not see shell moves |
|
|
243
|
+
| after an edit, Claude Code shows "paperlint lint-edited: the edit was kept; the errors above are the ones it introduced." | `lint-edited` linted the file the edit wrote and `paper.tex`, and found an error the edit introduced ([layout.md](layout.md#the-lint-edited-hook)). The edit stands; fix the error it names |
|
|
244
|
+
| `paperlint: the lint-edited hook did not run: …` on stderr | the hook could not lint (the reason follows); the edit stands. `npx paperlint lint` on the paper shows the same failure |
|
|
245
|
+
| anything else | `npx paperlint doctor` — it checks the setup and exits non-zero on anything miswired |
|
|
@@ -91,38 +91,41 @@ itself.
|
|
|
91
91
|
|
|
92
92
|
## Examples
|
|
93
93
|
|
|
94
|
-
Failing: a
|
|
94
|
+
Failing: a results table beside the paper.
|
|
95
95
|
|
|
96
96
|
```text
|
|
97
97
|
papers/agent-rule-drift/PIPELINE-STATUS.md
|
|
98
|
-
1:1 error `
|
|
99
|
-
and that root holds only paperlint's layout. Where it goes: a section of
|
|
100
|
-
PIPELINE-STATUS.md — the paper's one live-state file holds its stages, its plan
|
|
101
|
-
("Plan / now") and its scorecard; move what is still live there and delete the file.
|
|
102
|
-
The layout (extra/ takes anything and is never judged; the build's paper.* byproducts are never reported):
|
|
103
|
-
<paper>/
|
|
104
|
-
├── PIPELINE-STATUS.md ← the paper's one live-state file: stages, plan, scorecard
|
|
105
|
-
…
|
|
106
|
-
└── extra/ ← anything; never judged
|
|
107
|
-
Rule paper/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/paper/allowed-files-only.md paper/allowed-files-only
|
|
98
|
+
1:1 error `results-final-v2.csv` does not belong at a paper folder's root: move it to repro/data/, or extra/. paper/allowed-files-only
|
|
108
99
|
```
|
|
109
100
|
|
|
110
|
-
Each
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
101
|
+
Each finding is one line naming one destination. A name met in real paper folders has its own:
|
|
102
|
+
|
|
103
|
+
| entry | where it goes |
|
|
104
|
+
| -------------------------- | ------------------------------- |
|
|
105
|
+
| `PLAN.md`, `plans/` | a section of PIPELINE-STATUS.md |
|
|
106
|
+
| `DECISION-LOG.md` | `research/` |
|
|
107
|
+
| `EMAILS.md` | `submission/` |
|
|
108
|
+
| `data/` | `repro/data/` |
|
|
109
|
+
| `artifact/` | `repro/` |
|
|
110
|
+
| `archive/` | `extra/` |
|
|
111
|
+
| `venue-corpus/`, `venues/` | `<papers-root>/venues/<venue>/` |
|
|
112
|
+
|
|
113
|
+
Any other file goes where its kind says, by its name or its extension (matched ignoring case):
|
|
114
|
+
|
|
115
|
+
| extension | where it goes |
|
|
116
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
|
|
117
|
+
| data: `.tsv` `.csv` `.json` `.jsonl` `.ndjson` `.yaml` `.yml` `.xml` `.txt` `.log` `.parquet` `.sqlite` `.db` `.xlsx` `.npy` `.npz` `.pkl` `.gz` `.zip` `.tar` | `repro/data/` |
|
|
118
|
+
| scripts and the files that run them: `Makefile` `Dockerfile` `requirements.txt` `pyproject.toml` `uv.lock` `package.json` `package-lock.json` `.py` `.ipynb` `.sh` `.bash` `.zsh` `.js` `.mjs` `.cjs` `.ts` `.mts` `.cts` `.r` `.jl` `.rb` `.pl` `.awk` `.sql` | `repro/tools/` |
|
|
119
|
+
| images: `.png` `.jpg` `.jpeg` `.gif` `.svg` `.eps` | `figures/` |
|
|
120
|
+
| notes: `.md` `.markdown` | `research/` |
|
|
121
|
+
|
|
122
|
+
Anything else, and any folder not listed, goes to `extra/`; so does a PDF, which may be a figure (`figures/`), a draft or a review. The finding names one folder; pick
|
|
123
|
+
another when you know better: a record or research → `research/`; about submitting (forms, mails,
|
|
124
|
+
checklists, portal records) → `submission/`; the paper's live state → a section of
|
|
125
|
+
`PIPELINE-STATUS.md`; reproduction → `repro/`; a frozen PDF of a stage → `versions/`; unclear →
|
|
126
|
+
`extra/`. An `archive/` usually splits: its frozen PDFs into `versions/`, an earlier attempt's forms
|
|
127
|
+
and mails into `submission/`, the rest into `extra/`. The anonymized copy of an `artifact/` uploaded
|
|
128
|
+
for review goes in `submission/`.
|
|
126
129
|
|
|
127
130
|
Passing: the folder `paperlint new` writes (`PIPELINE-STATUS.md`, `paper.tex`, `paperlint.json`),
|
|
128
131
|
and any folder holding only the entries above.
|
|
@@ -145,7 +148,7 @@ No rule options. The paper's `pdf`, `talk.dir` and own preset files add what the
|
|
|
145
148
|
`plugin/hooks/hooks.json`). When an agent is about to create a file that would add an entry the
|
|
146
149
|
layout does not allow — at a paper folder's root, or at the top of its `repro/`
|
|
147
150
|
([`repro/allowed-files-only`](../repro/allowed-files-only.md)) — the hook denies the call, and the reason it gives is the
|
|
148
|
-
rule's own message: where the entry goes
|
|
151
|
+
rule's own message: where the entry goes. The agent writes the file where it
|
|
149
152
|
belongs instead, in the same turn. The text comes from the functions the rules report with
|
|
150
153
|
(`strayTexts`, `reproTexts`); there is no second list.
|
|
151
154
|
|
package/package.json
CHANGED
package/src/cli.harness.mjs
CHANGED
|
@@ -1239,7 +1239,7 @@ check(
|
|
|
1239
1239
|
check(
|
|
1240
1240
|
"the layout hook refuses a new stray PLAN.md on stdout as a PreToolUse deny, exit 0",
|
|
1241
1241
|
stray.status === 0 &&
|
|
1242
|
-
/^\{"hookSpecificOutput":\{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"`PLAN\.md`
|
|
1242
|
+
/^\{"hookSpecificOutput":\{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"`PLAN\.md` does not belong at a paper folder's root/.test(
|
|
1243
1243
|
stray.stdout,
|
|
1244
1244
|
),
|
|
1245
1245
|
);
|
package/src/cli.test.ts
CHANGED
|
@@ -234,7 +234,7 @@ test("runHook paper-folder-layout: in-process, on the real disk — a refusal on
|
|
|
234
234
|
assert.equal(stray.code, 0);
|
|
235
235
|
assert.match(
|
|
236
236
|
stray.out.join(""),
|
|
237
|
-
/^\{"hookSpecificOutput":\{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"`PLAN\.md`
|
|
237
|
+
/^\{"hookSpecificOutput":\{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"`PLAN\.md` does not belong at a paper folder's root/,
|
|
238
238
|
);
|
|
239
239
|
assert.deepEqual(hook(write("papers/p/NOTES.md")), {
|
|
240
240
|
code: 0,
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { describe, expect, it } from "vitest";
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
CURE_BY_DEFAULT,
|
|
9
|
+
CURE_BY_FILE,
|
|
9
10
|
KNOWN_CURES,
|
|
10
11
|
NOTHING_DECLARED,
|
|
11
12
|
PAPER_LAYOUT_TREE,
|
|
@@ -86,50 +87,61 @@ describe("judgeLayout — silent on the whole allowed set", () => {
|
|
|
86
87
|
});
|
|
87
88
|
|
|
88
89
|
describe("judgeLayout — reports", () => {
|
|
89
|
-
it(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
it.each([
|
|
91
|
+
["PLAN.md", "file", "a section of PIPELINE-STATUS.md"],
|
|
92
|
+
["Plan.md", "file", "a section of PIPELINE-STATUS.md"],
|
|
93
|
+
["plans", "dir", "a section of PIPELINE-STATUS.md"],
|
|
94
|
+
["DECISION-LOG.md", "file", "research/"],
|
|
95
|
+
["EMAILS.md", "file", "submission/"],
|
|
96
|
+
["data", "dir", "repro/data/"],
|
|
97
|
+
["artifact", "dir", "repro/"],
|
|
98
|
+
["archive", "dir", "extra/"],
|
|
99
|
+
["venue-corpus", "dir", "<papers-root>/venues/<venue>/"],
|
|
100
|
+
] as const)(
|
|
101
|
+
"a known name, %s (%s), goes to its one destination",
|
|
102
|
+
(name, kind, cure) => {
|
|
103
|
+
expect(judgeLayout([{ name, kind }], NOTHING_DECLARED)[0]?.cure).toBe(
|
|
104
|
+
cure,
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
);
|
|
99
108
|
|
|
100
109
|
it.each([
|
|
101
|
-
["
|
|
102
|
-
["
|
|
103
|
-
["
|
|
104
|
-
["
|
|
105
|
-
[
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
/^<papers-root>\/venues\/<venue>\/, outside the paper folder/,
|
|
114
|
-
],
|
|
115
|
-
["plans", "dir", /^a section of PIPELINE-STATUS\.md/],
|
|
116
|
-
["Plan.md", "file", /^a section of PIPELINE-STATUS\.md/],
|
|
117
|
-
] as const)("%s (%s) goes to its destination", (name, kind, cure) => {
|
|
118
|
-
expect(judgeLayout([{ name, kind }], NOTHING_DECLARED)[0]?.cure).toMatch(
|
|
119
|
-
cure,
|
|
120
|
-
);
|
|
121
|
-
});
|
|
110
|
+
["results-final-v2.csv", "repro/data/"],
|
|
111
|
+
["plot.py", "repro/tools/"],
|
|
112
|
+
["fig1.PNG", "figures/"],
|
|
113
|
+
["requirements.txt", "repro/tools/"],
|
|
114
|
+
["Makefile", "repro/tools/"],
|
|
115
|
+
["notes.md", "research/"],
|
|
116
|
+
])(
|
|
117
|
+
"an unlisted file, %s, goes to the folder its kind names",
|
|
118
|
+
(name, cure) => {
|
|
119
|
+
expect(judgeLayout([file(name)], NOTHING_DECLARED)[0]?.cure).toBe(cure);
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
122
|
|
|
123
|
-
it("an
|
|
124
|
-
expect(
|
|
125
|
-
|
|
123
|
+
it("anything else goes to extra/: an unlisted folder, a file without a known extension", () => {
|
|
124
|
+
expect(
|
|
125
|
+
judgeLayout(
|
|
126
|
+
[dir("corpus"), file("LICENSE"), file("fig1.pdf")],
|
|
127
|
+
NOTHING_DECLARED,
|
|
128
|
+
),
|
|
129
|
+
).toEqual([
|
|
130
|
+
{ name: "corpus/", kind: "dir", cure: CURE_BY_DEFAULT },
|
|
131
|
+
{ name: "LICENSE", kind: "file", cure: CURE_BY_DEFAULT },
|
|
132
|
+
// A root PDF may be a figure, a draft or a review: no one folder is right, and versions/ holds
|
|
133
|
+
// only cycle folders and lock.json (versions/layout).
|
|
134
|
+
{ name: "fig1.pdf", kind: "file", cure: CURE_BY_DEFAULT },
|
|
126
135
|
]);
|
|
136
|
+
expect(CURE_BY_DEFAULT).toBe("extra/");
|
|
127
137
|
});
|
|
128
138
|
|
|
129
|
-
it("a known file name used by a folder is
|
|
130
|
-
expect(
|
|
131
|
-
|
|
132
|
-
|
|
139
|
+
it("a known file name, or a file extension, used by a folder is neither: extra/", () => {
|
|
140
|
+
expect(
|
|
141
|
+
judgeLayout([dir("PLAN.md"), dir("runs.csv")], NOTHING_DECLARED).map(
|
|
142
|
+
(s) => s.cure,
|
|
143
|
+
),
|
|
144
|
+
).toEqual([CURE_BY_DEFAULT, CURE_BY_DEFAULT]);
|
|
133
145
|
});
|
|
134
146
|
});
|
|
135
147
|
|
|
@@ -227,19 +239,47 @@ describe("judgeLayout — reports by name, exactly", () => {
|
|
|
227
239
|
});
|
|
228
240
|
});
|
|
229
241
|
|
|
230
|
-
describe("strayMessage —
|
|
231
|
-
const
|
|
232
|
-
|
|
242
|
+
describe("strayMessage — one short line naming one destination", () => {
|
|
243
|
+
const CURES = [
|
|
244
|
+
...new Set([
|
|
245
|
+
...KNOWN_CURES.map((c) => c.cure),
|
|
246
|
+
...CURE_BY_FILE.map((c) => c.cure),
|
|
247
|
+
CURE_BY_DEFAULT,
|
|
248
|
+
]),
|
|
249
|
+
];
|
|
233
250
|
|
|
234
|
-
it(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
251
|
+
it.each(CURES)(
|
|
252
|
+
"for the destination %s: one line, the entry, the destination, extra/ as the fallback, no tree",
|
|
253
|
+
(cure) => {
|
|
254
|
+
const text = strayMessage({
|
|
255
|
+
name: "results-final-v2.csv",
|
|
256
|
+
kind: "file",
|
|
257
|
+
cure,
|
|
258
|
+
});
|
|
259
|
+
expect(text).not.toContain("\n");
|
|
260
|
+
expect(text.length).toBeLessThanOrEqual(120);
|
|
261
|
+
expect(text.startsWith("`results-final-v2.csv` ")).toBe(true);
|
|
262
|
+
expect(text).toContain(cure);
|
|
263
|
+
expect(text).toContain("extra/");
|
|
264
|
+
expect(text).not.toContain("<paper>/");
|
|
265
|
+
},
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
it("names no destination but its own: no other folder of the layout", () => {
|
|
269
|
+
const text = strayMessage({
|
|
270
|
+
name: "x.csv",
|
|
271
|
+
kind: "file",
|
|
272
|
+
cure: "repro/data/",
|
|
273
|
+
});
|
|
274
|
+
expect(
|
|
275
|
+
CURES.filter(
|
|
276
|
+
(c) => c !== "repro/data/" && c !== "extra/" && c !== "repro/",
|
|
277
|
+
).filter((c) => text.includes(c)),
|
|
278
|
+
).toEqual([]);
|
|
241
279
|
});
|
|
280
|
+
});
|
|
242
281
|
|
|
282
|
+
describe("PAPER_LAYOUT_TREE — the drawing the rule's page embeds", () => {
|
|
243
283
|
it("the layout it draws holds every allowed root entry, repro/'s own layout inside", () => {
|
|
244
284
|
const lines = PAPER_LAYOUT_TREE.split("\n");
|
|
245
285
|
expect(lines[0]).toBe("<paper>/");
|
|
@@ -31,7 +31,14 @@
|
|
|
31
31
|
*/
|
|
32
32
|
import { basename, extname } from "node:path";
|
|
33
33
|
import { leaf, renderTree, type TreeNode } from "./layout-tree.ts";
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
DATA_EXTENSIONS,
|
|
36
|
+
NOTE_EXTENSIONS,
|
|
37
|
+
REPRO_DIR,
|
|
38
|
+
REPRO_NODES,
|
|
39
|
+
SCRIPT_EXTENSIONS,
|
|
40
|
+
TOOL_FILES,
|
|
41
|
+
} from "./repro-layout.ts";
|
|
35
42
|
|
|
36
43
|
/** One entry at the paper folder's root: its name, and whether it is a folder. */
|
|
37
44
|
export interface LayoutEntry {
|
|
@@ -51,7 +58,7 @@ export interface Stray {
|
|
|
51
58
|
/** The entry's name; a folder's ends in a slash. */
|
|
52
59
|
readonly name: string;
|
|
53
60
|
readonly kind: "file" | "dir";
|
|
54
|
-
/** Where it goes: one destination
|
|
61
|
+
/** Where it goes: one destination, by its name, else by its kind, else `extra/`. */
|
|
55
62
|
readonly cure: string;
|
|
56
63
|
}
|
|
57
64
|
|
|
@@ -185,12 +192,10 @@ export const BUILD_BYPRODUCTS: readonly string[] = BYPRODUCT_EXTENSIONS.map(
|
|
|
185
192
|
export const OS_FILES: readonly string[] = [".DS_Store", "Thumbs.db"];
|
|
186
193
|
|
|
187
194
|
/** The live state of a paper — its stages, its plan, its scorecard — is one file. */
|
|
188
|
-
const STATUS_SECTIONS =
|
|
189
|
-
'a section of PIPELINE-STATUS.md — the paper\'s one live-state file holds its stages, its plan ("Plan / now") and its scorecard; move what is still live there and delete the file';
|
|
195
|
+
const STATUS_SECTIONS = "a section of PIPELINE-STATUS.md";
|
|
190
196
|
|
|
191
|
-
/** The shared corpus of a venue's accepted papers. */
|
|
192
|
-
const VENUE_CORPUS =
|
|
193
|
-
"<papers-root>/venues/<venue>/, outside the paper folder: one corpus per venue, shared by every paper that targets it";
|
|
197
|
+
/** The shared corpus of a venue's accepted papers, outside every paper folder. */
|
|
198
|
+
const VENUE_CORPUS = "<papers-root>/venues/<venue>/";
|
|
194
199
|
|
|
195
200
|
/**
|
|
196
201
|
* Names met in real paper folders, each with its one destination. Matched ignoring case, a file's
|
|
@@ -203,34 +208,43 @@ export const KNOWN_CURES: readonly {
|
|
|
203
208
|
}[] = [
|
|
204
209
|
{ name: "PLAN.md", kind: "file", cure: STATUS_SECTIONS },
|
|
205
210
|
{ name: "plans", kind: "dir", cure: STATUS_SECTIONS },
|
|
206
|
-
{ name: "DECISION-LOG.md", kind: "file", cure: "research/
|
|
207
|
-
{
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
name: "data",
|
|
214
|
-
kind: "dir",
|
|
215
|
-
cure: "repro/data/ (the data behind the numbers)",
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
name: "artifact",
|
|
219
|
-
kind: "dir",
|
|
220
|
-
cure: "repro/ — its scripts in repro/tools/, its data in repro/data/; the anonymized copy uploaded for review is about submitting and goes in submission/",
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
name: "archive",
|
|
224
|
-
kind: "dir",
|
|
225
|
-
cure: "versions/ for frozen PDFs, submission/ for an earlier attempt's forms, mails and checklists, extra/ for the rest",
|
|
226
|
-
},
|
|
211
|
+
{ name: "DECISION-LOG.md", kind: "file", cure: "research/" },
|
|
212
|
+
{ name: "EMAILS.md", kind: "file", cure: "submission/" },
|
|
213
|
+
{ name: "data", kind: "dir", cure: "repro/data/" },
|
|
214
|
+
{ name: "artifact", kind: "dir", cure: "repro/" },
|
|
215
|
+
{ name: "archive", kind: "dir", cure: `${ESCAPE_HATCH}/` },
|
|
227
216
|
{ name: "venue-corpus", kind: "dir", cure: VENUE_CORPUS },
|
|
228
217
|
{ name: "venues", kind: "dir", cure: VENUE_CORPUS },
|
|
229
218
|
];
|
|
230
219
|
|
|
231
|
-
/**
|
|
232
|
-
export const
|
|
233
|
-
"
|
|
220
|
+
/** The extensions of the images a figure is drawn from. */
|
|
221
|
+
export const IMAGE_EXTENSIONS: readonly string[] = [
|
|
222
|
+
".png",
|
|
223
|
+
".jpg",
|
|
224
|
+
".jpeg",
|
|
225
|
+
".gif",
|
|
226
|
+
".svg",
|
|
227
|
+
".eps",
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* For a file nobody listed: the folder its kind names, by its exact name or its extension (matched
|
|
232
|
+
* ignoring case). The same kinds `repro/allowed-files-only` sorts by. No `.pdf`: a root PDF may be
|
|
233
|
+
* a figure, a draft or a review, and `versions/` holds only cycle folders (`versions/layout`).
|
|
234
|
+
*/
|
|
235
|
+
export const CURE_BY_FILE: readonly {
|
|
236
|
+
readonly names: readonly string[];
|
|
237
|
+
readonly extensions: readonly string[];
|
|
238
|
+
readonly cure: string;
|
|
239
|
+
}[] = [
|
|
240
|
+
{ names: TOOL_FILES, extensions: SCRIPT_EXTENSIONS, cure: "repro/tools/" },
|
|
241
|
+
{ names: [], extensions: DATA_EXTENSIONS, cure: "repro/data/" },
|
|
242
|
+
{ names: [], extensions: IMAGE_EXTENSIONS, cure: "figures/" },
|
|
243
|
+
{ names: [], extensions: NOTE_EXTENSIONS, cure: "research/" },
|
|
244
|
+
];
|
|
245
|
+
|
|
246
|
+
/** For anything else: the folder that is never judged. */
|
|
247
|
+
export const CURE_BY_DEFAULT = `${ESCAPE_HATCH}/`;
|
|
234
248
|
|
|
235
249
|
const isAllowedFile = (name: string, declared: Declared): boolean =>
|
|
236
250
|
ROOT_FILES.includes(name) ||
|
|
@@ -244,12 +258,20 @@ const isAllowed = (e: LayoutEntry, declared: Declared): boolean =>
|
|
|
244
258
|
? ROOT_DIRS.includes(e.name) || declared.roots.includes(e.name)
|
|
245
259
|
: isAllowedFile(e.name, declared);
|
|
246
260
|
|
|
247
|
-
/** Where
|
|
261
|
+
/** Where `e` belongs: its listed destination, else its kind's folder, else `extra/`. */
|
|
248
262
|
function cureFor(e: LayoutEntry): string {
|
|
249
263
|
const known = KNOWN_CURES.find(
|
|
250
264
|
(c) => c.kind === e.kind && c.name.toLowerCase() === e.name.toLowerCase(),
|
|
251
265
|
);
|
|
252
|
-
|
|
266
|
+
if (known !== undefined) return known.cure;
|
|
267
|
+
const ext = extname(e.name).toLowerCase();
|
|
268
|
+
const byKind =
|
|
269
|
+
e.kind === "file"
|
|
270
|
+
? CURE_BY_FILE.find(
|
|
271
|
+
(c) => c.names.includes(e.name) || c.extensions.includes(ext),
|
|
272
|
+
)
|
|
273
|
+
: undefined;
|
|
274
|
+
return byKind?.cure ?? CURE_BY_DEFAULT;
|
|
253
275
|
}
|
|
254
276
|
|
|
255
277
|
/** The root entries that are not part of the layout, in the order given. Pure. */
|
|
@@ -289,7 +311,7 @@ export const PAPER_NODES: readonly TreeNode[] = [
|
|
|
289
311
|
})),
|
|
290
312
|
];
|
|
291
313
|
|
|
292
|
-
/** The drawing of the paper folder's layout
|
|
314
|
+
/** The drawing of the paper folder's layout, which the rule's page embeds. */
|
|
293
315
|
export const PAPER_LAYOUT_TREE: string = renderTree("<paper>/", PAPER_NODES);
|
|
294
316
|
|
|
295
317
|
/** The folder beside the paper folders that holds one corpus of accepted papers per venue. */
|
|
@@ -326,14 +348,11 @@ export const PAPERS_LAYOUT_TREE: string = renderTree(
|
|
|
326
348
|
|
|
327
349
|
/**
|
|
328
350
|
* The one text a stray entry is reported with, by the rule `paper/allowed-files-only` and by the hook that
|
|
329
|
-
* refuses to create such an entry
|
|
330
|
-
*
|
|
351
|
+
* refuses to create such an entry: one line, the entry and its one destination. The layout, and how
|
|
352
|
+
* each destination is picked, are on the rule's page, which the finding's rule id names.
|
|
331
353
|
*/
|
|
332
354
|
export function strayMessage(s: Stray): string {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
PAPER_LAYOUT_TREE,
|
|
337
|
-
`Rule paper/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/paper/allowed-files-only.md`,
|
|
338
|
-
].join("\n");
|
|
355
|
+
const fallback =
|
|
356
|
+
s.cure === CURE_BY_DEFAULT ? "the folder for its kind" : CURE_BY_DEFAULT;
|
|
357
|
+
return `\`${s.name}\` does not belong at a paper folder's root: move it to ${s.cure}, or ${fallback}.`;
|
|
339
358
|
}
|
|
@@ -75,7 +75,7 @@ describe("paper-folder-layout hook — denies a new stray entry", () => {
|
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
77
|
expect(out?.hookSpecificOutput.permissionDecisionReason).toMatch(
|
|
78
|
-
/^`PLAN\.md`
|
|
78
|
+
/^`PLAN\.md` does not belong at a paper folder's root: move it to a section of PIPELINE-STATUS\.md[^\n]*$/u,
|
|
79
79
|
);
|
|
80
80
|
});
|
|
81
81
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* created, not at the next lint. PreToolUse on `Edit|Write|MultiEdit` (`plugin/hooks/hooks.json`):
|
|
4
4
|
* when the file about to be written does not exist yet and would add an entry the layout does not
|
|
5
5
|
* allow — at a paper folder's root, or at the top of its `repro/` — the call is denied, and the
|
|
6
|
-
* reason is the rule's own message: where the entry goes
|
|
6
|
+
* reason is the rule's own message: where the entry goes (for `repro/`, also its layout drawn). The agent writes it
|
|
7
7
|
* where it belongs instead, in the same turn.
|
|
8
8
|
*
|
|
9
9
|
* ── WHAT IT NEVER BLOCKS ─────────────────────────────────────────────────────────
|
|
@@ -75,7 +75,7 @@ describe("paper/allowed-files-only — reports", () => {
|
|
|
75
75
|
),
|
|
76
76
|
).toEqual([
|
|
77
77
|
expect.stringMatching(
|
|
78
|
-
/^`archive\/`
|
|
78
|
+
/^`archive\/` does not belong at a paper folder's root: move it to extra\//,
|
|
79
79
|
),
|
|
80
80
|
]);
|
|
81
81
|
});
|
package/src/layout-docs.test.ts
CHANGED
|
@@ -11,6 +11,9 @@ import { dirname, join } from "node:path";
|
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { describe, expect, it } from "vitest";
|
|
13
13
|
import {
|
|
14
|
+
CURE_BY_DEFAULT,
|
|
15
|
+
CURE_BY_FILE,
|
|
16
|
+
KNOWN_CURES,
|
|
14
17
|
PAPER_LAYOUT_TREE,
|
|
15
18
|
PAPERS_LAYOUT_TREE,
|
|
16
19
|
} from "./domain/paper-layout.ts";
|
|
@@ -50,3 +53,47 @@ describe("the pages draw the layout the code enforces", () => {
|
|
|
50
53
|
expect(embedded("# a page\n")).toBeNull();
|
|
51
54
|
});
|
|
52
55
|
});
|
|
56
|
+
|
|
57
|
+
const tick = (s: string): string => `\`${s}\``;
|
|
58
|
+
|
|
59
|
+
/** Each destination the finding picks, with the backticked names or extensions its table row must hold. */
|
|
60
|
+
const ROWS: readonly (readonly string[])[] = [
|
|
61
|
+
...KNOWN_CURES.map((c) => [
|
|
62
|
+
tick(c.kind === "dir" ? `${c.name}/` : c.name),
|
|
63
|
+
c.cure,
|
|
64
|
+
]),
|
|
65
|
+
...CURE_BY_FILE.map((c) => [
|
|
66
|
+
...c.names.map(tick),
|
|
67
|
+
...c.extensions.map(tick),
|
|
68
|
+
tick(c.cure),
|
|
69
|
+
]),
|
|
70
|
+
[tick(CURE_BY_DEFAULT)],
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
/** The rows no single line of the page holds whole: a row lost, or its destination swapped. */
|
|
74
|
+
const unlisted = (page: string): readonly (readonly string[])[] => {
|
|
75
|
+
const lines = page.split("\n");
|
|
76
|
+
return ROWS.filter(
|
|
77
|
+
(row) => !lines.some((line) => row.every((cell) => line.includes(cell))),
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
describe("the rule's page lists every destination the one-line finding picks", () => {
|
|
82
|
+
const page = readFileSync(
|
|
83
|
+
join(ROOT, "docs/rules/paper/allowed-files-only.md"),
|
|
84
|
+
"utf8",
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
it("paper/allowed-files-only has a line per known entry and per extension group, with its destination", () => {
|
|
88
|
+
expect(unlisted(page)).toEqual([]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("a page whose two destinations are swapped, or without the list, is caught", () => {
|
|
92
|
+
const swapped = page
|
|
93
|
+
.replace("| `repro/data/` |", "| @@ |")
|
|
94
|
+
.replace("| `repro/tools/` |", "| `repro/data/` |")
|
|
95
|
+
.replace("| @@ |", "| `repro/tools/` |");
|
|
96
|
+
expect(unlisted(swapped).length).toBeGreaterThan(0);
|
|
97
|
+
expect(unlisted("# a page\n")).toEqual(ROWS);
|
|
98
|
+
});
|
|
99
|
+
});
|