paperlint 18.4.0 → 18.4.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.
@@ -1,46 +1,29 @@
1
+ import type { ConfigBlock, RuleBlock, RuleEntry } from "./rules-config.ts";
1
2
  /**
2
- * THE FILES PAPERLINT OWNS — read off its own config, and made the only thing ESLint may reach.
3
- *
4
- * paperlint's blocks name the files they lint (`PIPELINE-STATUS.md`, `paper.tex`, `reviews/*.md`,
5
- * …). That list is the whole scope of `paperlint lint`, and this module turns it
6
- * into two things ESLint understands:
7
- *
8
- * 1. **A global ignore of everything else** (`scopeToOwned`). Handing ESLint a directory is not
9
- * enough: its built-in defaults lint every JavaScript file it finds, whatever our config says.
10
- * Measured on a consumer project with vendored code under a paper's `repro/` folder: 1,877
11
- * files, 74 errors ("'return' outside of function", "Definition for rule … was not found"),
12
- * zero of them on a paper file, exit 1 — and nothing in the settings could turn it off. With
13
- * the ignore, a stray script under the papers directory is never enumerated at all, and a file
14
- * named on the command line can be asked about (`ESLint#isPathIgnored`) with ESLint's own
15
- * matcher instead of a hand-written one.
16
- *
17
- * 2. **Each rule scoped to the files it was written for** (`ruleOwners` + `narrowToOwners`).
18
- * One plugin NAME is bound to different plugin objects in different blocks: `paper` holds
19
- * `stages`/`source`/`author-list` beside `PIPELINE-STATUS.md` and `typography` beside
20
- * `paper.tex`. So a consumer block that named `paper/source`
21
- * for every file under the papers directory reached `paper.tex`, where `paper` has no `source`
22
- * — and ESLint threw `Could not find "source" in plugin "paper"` from inside `lintFiles`,
23
- * after paperlint's own validation had (correctly) accepted the id. A block is therefore split
24
- * per owner and its `files` ANDed with the owner's (ESLint's nested-array form), so a rule can
25
- * only land where its plugin is registered.
26
- *
27
- * Both read ONE definition of "the files paperlint lints": `ownedScopes`, each own block's `files`
28
- * together with its `ignores`. The globs alone are not that definition. The sibling-card block
29
- * claims every markdown file under `siblings/` EXCEPT the index, and a rule whose plugin is
30
- * registered for every file (`pdf`) used to keep the consumer block's `files` as they were — so a
31
- * venue preset's rules reached `siblings/README.md`, a block with no `language` matched it, and
32
- * ESLint parsed the markdown as JavaScript (#101). Now every generated block narrows to scopes,
33
- * exceptions included, and a plugin registered everywhere owns exactly what paperlint lints.
34
- *
35
- * ESLint's semantics that this leans on, each measured against ESLint 10 before writing it:
36
- * - a global-ignore pattern that matches a DIRECTORY hides everything inside it, so directories
37
- * must be un-ignored (`!` + a pattern ending in a slash) before owned files can be;
38
- * - that un-ignores `node_modules/` and `.git/` too — ESLint's own defaults — so they are
39
- * re-ignored after, or a `paper.tex` inside a dependency would be linted;
40
- * - later global-ignore patterns win, across blocks, in config order;
41
- * - `files: [["a", "b"]]` matches a file only when BOTH patterns match.
3
+ * Which papers' own files paperlint's blocks claim. `any` is the config's SHAPE, for the rule list and
4
+ * the docs: a file in any folder. `papers` is what `paperlint lint` runs on: the real papers, as glob
5
+ * prefixes relative to ESLint's `cwd` ("" for `cwd` itself), so a copy of a paper kept inside one (a
6
+ * review snapshot, a build copy) is claimed by no block (#582).
42
7
  */
43
- import type { ConfigBlock, RuleBlock, RuleEntry } from "./rules-config.ts";
8
+ export type PaperScope = {
9
+ readonly kind: "any";
10
+ } | {
11
+ readonly kind: "papers";
12
+ readonly cwd: string;
13
+ readonly prefixes: readonly string[];
14
+ };
15
+ export declare const ANY_PAPER: PaperScope;
16
+ /** The papers `dirs` under ESLint's `cwd`: the scope `paperlint lint` lints. Pure. */
17
+ export declare const papersScope: (dirs: readonly string[], cwd: string) => PaperScope;
18
+ /** A glob of a paper's own file (`paper.tex`, `reviews/*.md`) in each paper of `scope`. Pure. */
19
+ export declare const paperFiles: (scope: PaperScope, glob: string) => readonly string[];
20
+ /**
21
+ * A glob relative to `cwd`, as the block whose `basePath` is `base` must write it — ESLint reads a
22
+ * block's patterns from its `basePath`, and a paper's own settings carry the paper's folder. None
23
+ * when the glob names files outside `base`: that block can never reach them. A glob that starts with
24
+ * `**` matches at any depth and is kept as it is. Pure.
25
+ */
26
+ export declare const rebaseGlob: (glob: string, cwd: string, base: string) => readonly string[];
44
27
  /**
45
28
  * A set of files paperlint lints: an own block's globs and the exceptions that block makes. A file is
46
29
  * in it when it matches one of `files` and none of `ignores`.
@@ -81,5 +64,5 @@ export declare function ruleOwners(own: readonly ConfigBlock[]): Map<string, rea
81
64
  * of this config registers (the LaTeX block is absent when its parser did not load) gets no block:
82
65
  * it has no file to reach in this run, and naming it to ESLint would only crash.
83
66
  */
84
- export declare function narrowToOwners(block: RuleBlock, owners: ReadonlyMap<string, readonly OwnedScope[]>): ScopedBlock[];
67
+ export declare function narrowToOwners(block: RuleBlock, owners: ReadonlyMap<string, readonly OwnedScope[]>, papers?: PaperScope): ScopedBlock[];
85
68
  //# sourceMappingURL=paper-files.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paper-files.d.ts","sourceRoot":"","sources":["../src/paper-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE3E;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;AAEpD,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC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,CAC5B,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC,EAClD,MAAM,GAAE,UAAsB,GAC7B,WAAW,EAAE,CAkBf"}
@@ -1,3 +1,76 @@
1
+ /**
2
+ * THE FILES PAPERLINT OWNS — read off its own config, and made the only thing ESLint may reach.
3
+ *
4
+ * paperlint's blocks name the files they lint (`PIPELINE-STATUS.md`, `paper.tex`, `reviews/*.md`,
5
+ * …). That list is the whole scope of `paperlint lint`, and this module turns it
6
+ * into two things ESLint understands:
7
+ *
8
+ * 1. **A global ignore of everything else** (`scopeToOwned`). Handing ESLint a directory is not
9
+ * enough: its built-in defaults lint every JavaScript file it finds, whatever our config says.
10
+ * Measured on a consumer project with vendored code under a paper's `repro/` folder: 1,877
11
+ * files, 74 errors ("'return' outside of function", "Definition for rule … was not found"),
12
+ * zero of them on a paper file, exit 1 — and nothing in the settings could turn it off. With
13
+ * the ignore, a stray script under the papers directory is never enumerated at all, and a file
14
+ * named on the command line can be asked about (`ESLint#isPathIgnored`) with ESLint's own
15
+ * matcher instead of a hand-written one.
16
+ *
17
+ * 2. **Each rule scoped to the files it was written for** (`ruleOwners` + `narrowToOwners`).
18
+ * One plugin NAME is bound to different plugin objects in different blocks: `paper` holds
19
+ * `stages`/`source`/`author-list` beside `PIPELINE-STATUS.md` and `typography` beside
20
+ * `paper.tex`. So a consumer block that named `paper/source`
21
+ * for every file under the papers directory reached `paper.tex`, where `paper` has no `source`
22
+ * — and ESLint threw `Could not find "source" in plugin "paper"` from inside `lintFiles`,
23
+ * after paperlint's own validation had (correctly) accepted the id. A block is therefore split
24
+ * per owner and its `files` ANDed with the owner's (ESLint's nested-array form), so a rule can
25
+ * only land where its plugin is registered.
26
+ *
27
+ * Both read ONE definition of "the files paperlint lints": `ownedScopes`, each own block's `files`
28
+ * together with its `ignores`. The globs alone are not that definition. The sibling-card block
29
+ * claims every markdown file under `siblings/` EXCEPT the index, and a rule whose plugin is
30
+ * registered for every file (`pdf`) used to keep the consumer block's `files` as they were — so a
31
+ * venue preset's rules reached `siblings/README.md`, a block with no `language` matched it, and
32
+ * ESLint parsed the markdown as JavaScript (#101). Now every generated block narrows to scopes,
33
+ * exceptions included, and a plugin registered everywhere owns exactly what paperlint lints.
34
+ *
35
+ * ESLint's semantics that this leans on, each measured against ESLint 10 before writing it:
36
+ * - a global-ignore pattern that matches a DIRECTORY hides everything inside it, so directories
37
+ * must be un-ignored (`!` + a pattern ending in a slash) before owned files can be;
38
+ * - that un-ignores `node_modules/` and `.git/` too — ESLint's own defaults — so they are
39
+ * re-ignored after, or a `paper.tex` inside a dependency would be linted;
40
+ * - later global-ignore patterns win, across blocks, in config order;
41
+ * - `files: [["a", "b"]]` matches a file only when BOTH patterns match.
42
+ */
43
+ import { relative, sep } from "node:path";
44
+ export const ANY_PAPER = { kind: "any" };
45
+ /** The characters a glob reads as syntax, escaped so a folder's name matches only itself. Pure. */
46
+ const literalGlob = (path) => path.replace(/[\\*?[\]{}()!+@]/gu, "\\$&");
47
+ /** `to` relative to `from`, `/`-separated. Pure. */
48
+ const posixRelative = (from, to) => relative(from, to).split(sep).join("/");
49
+ /** The papers `dirs` under ESLint's `cwd`: the scope `paperlint lint` lints. Pure. */
50
+ export const papersScope = (dirs, cwd) => ({
51
+ kind: "papers",
52
+ cwd,
53
+ prefixes: dirs.map((d) => literalGlob(posixRelative(cwd, d))),
54
+ });
55
+ /** A glob of a paper's own file (`paper.tex`, `reviews/*.md`) in each paper of `scope`. Pure. */
56
+ export const paperFiles = (scope, glob) => scope.kind === "any"
57
+ ? [`**/${glob}`]
58
+ : scope.prefixes.map((p) => (p === "" ? glob : `${p}/${glob}`));
59
+ /**
60
+ * A glob relative to `cwd`, as the block whose `basePath` is `base` must write it — ESLint reads a
61
+ * block's patterns from its `basePath`, and a paper's own settings carry the paper's folder. None
62
+ * when the glob names files outside `base`: that block can never reach them. A glob that starts with
63
+ * `**` matches at any depth and is kept as it is. Pure.
64
+ */
65
+ export const rebaseGlob = (glob, cwd, base) => {
66
+ if (glob.startsWith("**"))
67
+ return [glob];
68
+ const up = posixRelative(base, cwd);
69
+ if (!up.startsWith(".."))
70
+ return [up === "" ? glob : `${literalGlob(up)}/${glob}`];
71
+ const down = `${literalGlob(posixRelative(cwd, base))}/`;
72
+ return glob.startsWith(down) ? [glob.slice(down.length)] : [];
73
+ };
1
74
  /** A block's `files`, the string globs only. */
2
75
  const globsOf = (files) => files.filter((f) => typeof f === "string");
3
76
  const stringsOf = (xs) => (xs ?? []).filter((x) => typeof x === "string");
@@ -68,7 +141,7 @@ export function ruleOwners(own) {
68
141
  * of this config registers (the LaTeX block is absent when its parser did not load) gets no block:
69
142
  * it has no file to reach in this run, and naming it to ESLint would only crash.
70
143
  */
71
- export function narrowToOwners(block, owners) {
144
+ export function narrowToOwners(block, owners, papers = ANY_PAPER) {
72
145
  // Keyed by the owner's JSON, so rules with equal owners share one group of blocks.
73
146
  const groups = new Map();
74
147
  const ownerOf = new Map();
@@ -80,19 +153,38 @@ export function narrowToOwners(block, owners) {
80
153
  groups.set(key, { ...groups.get(key), [id]: entry });
81
154
  ownerOf.set(key, owner);
82
155
  }
83
- return [...ownerOf].flatMap(([key, owner]) => owner.map((scope) => within(block, scope, { ...groups.get(key) })));
156
+ return [...ownerOf].flatMap(([key, owner]) => owner.flatMap((scope) => within(block, rebased(scope, papers, block.basePath), {
157
+ ...groups.get(key),
158
+ })));
159
+ }
160
+ /**
161
+ * `scope` as the block with `basePath` `base` must write it. The scope's globs are relative to ESLint's
162
+ * `cwd`; a paper's own settings are read from the paper's folder (#582).
163
+ */
164
+ function rebased(scope, papers, base) {
165
+ if (papers.kind === "any")
166
+ return scope;
167
+ const onto = (globs) => globs.flatMap((g) => rebaseGlob(g, papers.cwd, base));
168
+ return { files: onto(scope.files), ignores: onto(scope.ignores) };
84
169
  }
85
- /** `block`'s rules over the files both it and `scope` claim, minus both sets of exceptions. */
170
+ /**
171
+ * `block`'s rules over the files both it and `scope` claim, minus both sets of exceptions; none when
172
+ * the scope claims no file the block can reach (ESLint refuses an empty `files`).
173
+ */
86
174
  function within(block, scope, rules) {
175
+ if (scope.files.length === 0)
176
+ return [];
87
177
  const files = block.files
88
178
  ? block.files.flatMap((f) => scope.files.map((o) => [f, o]))
89
179
  : scope.files;
90
180
  const ignores = [...(block.ignores ?? []), ...scope.ignores];
91
- return {
92
- basePath: block.basePath,
93
- files,
94
- ...(ignores.length ? { ignores } : {}),
95
- rules,
96
- };
181
+ return [
182
+ {
183
+ basePath: block.basePath,
184
+ files,
185
+ ...(ignores.length ? { ignores } : {}),
186
+ rules,
187
+ },
188
+ ];
97
189
  }
98
190
  //# sourceMappingURL=paper-files.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"paper-files.js","sourceRoot":"","sources":["../src/paper-files.ts"],"names":[],"mappings":"AAgEA,gDAAgD;AAChD,MAAM,OAAO,GAAG,CAAC,KAAyB,EAAY,EAAE,CACtD,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;AAE1D,MAAM,SAAS,GAAG,CAAC,EAAkC,EAAY,EAAE,CACjE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,MAA6B,EAAgB,EAAE;IAC7D,MAAM,SAAS,GAAG,IAAI,GAAG,EAAsB,CAAC;IAChD,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE;YACjB,KAAK,E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AI,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7D,OAAO;QACL;YACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,KAAK;YACL,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,KAAK;SACN;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperlint",
3
- "version": "18.4.0",
3
+ "version": "18.4.1",
4
4
  "description": "A linter for scientific papers written in LaTeX: catches mistakes before you submit to a conference or journal.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli.test.ts CHANGED
@@ -824,6 +824,128 @@ test("lint: a path that shares nothing with the project but the filesystem root
824
824
  );
825
825
  });
826
826
 
827
+ /** A scorecard that fails `paper/stages`: its stage names a PDF that does not exist. */
828
+ const FAILING_STATUS =
829
+ "---\nstages:\n - stage: submitted\n date: 2026-07-22\n pdf: versions/none.pdf\n bytes: 1\n---\n";
830
+
831
+ test("lint: a copy of a paper inside it (a review snapshot, a build copy) is not linted as a paper (#582)", async () => {
832
+ const dir = writeTree(join(root, "lint-copies"), {
833
+ "paperlint.json": JSON.stringify({ papersDir: "papers" }),
834
+ "papers/p/paper.tex": "% P\n",
835
+ "papers/p/PIPELINE-STATUS.md": "---\n---\n",
836
+ "papers/p/reviews/2026-11-20-second-opinion/paper.tex": "% P\n",
837
+ "papers/p/reviews/2026-11-20-second-opinion/PIPELINE-STATUS.md":
838
+ FAILING_STATUS,
839
+ "papers/p/research/data/cut/runs/a/paper.tex": "% P\n",
840
+ "papers/p/research/data/cut/runs/a/PIPELINE-STATUS.md": FAILING_STATUS,
841
+ });
842
+ const r = await cli(["lint"], dir);
843
+ assert.deepEqual(
844
+ { code: r.code, copies: /second-opinion|runs\/a/.test(r.out) },
845
+ { code: 0, copies: false },
846
+ );
847
+ });
848
+
849
+ test.each([
850
+ ["a review card", "archive/p/reviews/r.md"],
851
+ ["its reviews/ folder", "archive/p/reviews"],
852
+ ])(
853
+ "lint: %s named outside the papers directory is judged as its paper's own (#582)",
854
+ async (_, path) => {
855
+ const dir = writeTree(
856
+ join(root, `lint-owner-${path.replaceAll("/", "-")}`),
857
+ {
858
+ "paperlint.json": JSON.stringify({ papersDir: "papers" }),
859
+ "archive/p/paper.tex": "% P\n",
860
+ "archive/p/PIPELINE-STATUS.md": "---\n---\n",
861
+ // A finding without a status: the review schema refuses it.
862
+ "archive/p/reviews/r.md": "---\nfindings:\n - id: 1\n---\n# R\n",
863
+ // A snapshot of the paper beside the card: the paper still owns the card.
864
+ "archive/p/reviews/snapshot/paper.tex": "% P\n",
865
+ "archive/p/reviews/snapshot/PIPELINE-STATUS.md": FAILING_STATUS,
866
+ },
867
+ );
868
+ const r = await cli(["lint", path], dir);
869
+ assert.deepEqual(
870
+ {
871
+ code: r.code,
872
+ card: /archive\/p\/reviews\/r\.md/.test(r.out),
873
+ snapshot: /reviews\/snapshot/.test(r.out),
874
+ },
875
+ { code: 1, card: true, snapshot: false },
876
+ );
877
+ },
878
+ );
879
+
880
+ test("lint: a review card of a paper with only its source, outside the papers directory, is judged (#582)", async () => {
881
+ const dir = writeTree(join(root, "lint-owner-source-only"), {
882
+ "paperlint.json": JSON.stringify({ papersDir: "papers" }),
883
+ "archive/p/paper.tex": "% P\n",
884
+ "archive/p/reviews/r.md": "---\nfindings:\n - id: 1\n---\n# R\n",
885
+ });
886
+ const r = await cli(["lint", "archive/p/reviews/r.md"], dir);
887
+ assert.deepEqual(
888
+ { code: r.code, card: /archive\/p\/reviews\/r\.md/.test(r.out) },
889
+ { code: 1, card: true },
890
+ );
891
+ });
892
+
893
+ test("lint: a copy straight under a paper is not linted as a paper (#582)", async () => {
894
+ // The layout rule reports the stray `old/` itself; what must not happen is the copy's own
895
+ // scorecard being judged as a second paper's.
896
+ const dir = writeTree(join(root, "lint-direct-copy"), {
897
+ "paperlint.json": JSON.stringify({ papersDir: "papers" }),
898
+ "papers/p/paper.tex": "% P\n",
899
+ "papers/p/PIPELINE-STATUS.md": "---\n---\n",
900
+ "papers/p/old/paper.tex": "% P\n",
901
+ "papers/p/old/PIPELINE-STATUS.md": FAILING_STATUS,
902
+ });
903
+ const r = await cli(["lint", "papers/p"], dir);
904
+ assert.equal(/papers\/p\/old\/PIPELINE-STATUS\.md/.test(r.out), false);
905
+ });
906
+
907
+ test("lint: a paper more than one folder below a named folder is found and judged (#582)", async () => {
908
+ const dir = writeTree(join(root, "lint-deep-container"), {
909
+ "paperlint.json": JSON.stringify({ papersDir: "papers" }),
910
+ "archive/2025/p/paper.tex": "% P\n",
911
+ "archive/2025/p/PIPELINE-STATUS.md": FAILING_STATUS,
912
+ });
913
+ const r = await cli(["lint", "archive"], dir);
914
+ assert.deepEqual(
915
+ { code: r.code, deep: /archive\/2025\/p\/PIPELINE-STATUS\.md/.test(r.out) },
916
+ { code: 1, deep: true },
917
+ );
918
+ });
919
+
920
+ test("lint: `lint .` from the project root reaches papers outside papersDir (#582)", async () => {
921
+ // The root holds paperlint.json, the project's settings, and is no paper: the walk goes on.
922
+ const dir = writeTree(join(root, "lint-project-root"), {
923
+ "paperlint.json": JSON.stringify({ papersDir: "papers" }),
924
+ "papers/p/paper.tex": "% P\n",
925
+ "papers/p/PIPELINE-STATUS.md": "---\n---\n",
926
+ "archive/2025/q/paper.tex": "% P\n",
927
+ "archive/2025/q/PIPELINE-STATUS.md": FAILING_STATUS,
928
+ });
929
+ const r = await cli(["lint", "."], dir);
930
+ assert.deepEqual(
931
+ { code: r.code, q: /archive\/2025\/q\/PIPELINE-STATUS\.md/.test(r.out) },
932
+ { code: 1, q: true },
933
+ );
934
+ });
935
+
936
+ test("lint: the same failing scorecard as the paper's own is reported, so the test above can fail (#582)", async () => {
937
+ const dir = writeTree(join(root, "lint-own-status"), {
938
+ "paperlint.json": JSON.stringify({ papersDir: "papers" }),
939
+ "papers/p/paper.tex": "% P\n",
940
+ "papers/p/PIPELINE-STATUS.md": FAILING_STATUS,
941
+ });
942
+ const r = await cli(["lint"], dir);
943
+ assert.deepEqual(
944
+ { code: r.code, own: /papers\/p\/PIPELINE-STATUS\.md/.test(r.out) },
945
+ { code: 1, own: true },
946
+ );
947
+ });
948
+
827
949
  /**
828
950
  * `new` at a terminal: stdin and stdout claim to be TTYs (a preload), and each prompt is answered
829
951
  * when it appears — a pipe written all at once is swallowed by the first question.
package/src/cli.ts CHANGED
@@ -24,7 +24,7 @@
24
24
  * replaced it: silently breaking someone else's workflow is worse than asking them to fix a line.
25
25
  */
26
26
  import { ESLint, type Linter } from "eslint";
27
- import { readFileSync, existsSync, statSync } from "node:fs";
27
+ import { readFileSync, readdirSync, existsSync, statSync } from "node:fs";
28
28
  import { createRequire } from "node:module";
29
29
  import { stripVTControlCharacters } from "node:util";
30
30
  import { spawnSync } from "node:child_process";
@@ -119,11 +119,15 @@ import type { PortalKind, SupportedPortal } from "./domain/submission.ts";
119
119
  import type { PortalSite } from "./ports/submission-portal.ts";
120
120
  import type { CheckReferences } from "./ports/check-references.ts";
121
121
  import {
122
+ ANY_PAPER,
122
123
  narrowToOwners,
123
124
  ownedPatterns,
125
+ paperFiles,
126
+ papersScope,
124
127
  ruleOwners,
125
128
  scopeToOwned,
126
129
  } from "./paper-files.ts";
130
+ import type { PaperScope } from "./paper-files.ts";
127
131
  import {
128
132
  paperPreset,
129
133
  settingsProblemLine,
@@ -214,6 +218,7 @@ import {
214
218
  } from "./folder-layout-rule.ts";
215
219
  import { folderLayoutHook } from "./folder-layout-hook.ts";
216
220
  import { paperFolderOf, writtenPath } from "./domain/paper-folder.ts";
221
+ import { papersReached, type PaperTree } from "./domain/paper-dirs.ts";
217
222
  import {
218
223
  NOTICE_HOOKS,
219
224
  collector,
@@ -573,7 +578,11 @@ const TALK_RULE_DEPS = {
573
578
  export function buildConfig(
574
579
  opts: PaperlintConfig = {},
575
580
  texLanguage: unknown,
581
+ // The papers whose own files the blocks claim (`PaperScope`): any folder for the config's shape,
582
+ // the real papers for `paperlint lint`, so a copy kept inside one is claimed by no block (#582).
583
+ papers: PaperScope = ANY_PAPER,
576
584
  ): ConfigBlock[] {
585
+ const own = (glob: string): readonly string[] => paperFiles(papers, glob);
577
586
  const paperRules = { ...typography.rules };
578
587
  // The reference rules judge `_build/references.json`, and only on `paper.tex`.
579
588
  const texPaperRules = {
@@ -614,7 +623,7 @@ export function buildConfig(
614
623
  },
615
624
  },
616
625
  {
617
- files: ["**/PIPELINE-STATUS.md"],
626
+ files: own("PIPELINE-STATUS.md"),
618
627
  // Every paper folder has one: the rules about the folder itself (its stages, its frozen
619
628
  // sources, its name) are judged here, once per paper.
620
629
  plugins: {
@@ -654,7 +663,7 @@ export function buildConfig(
654
663
  },
655
664
  },
656
665
  {
657
- files: ["**/reviews/*.md"],
666
+ files: own("reviews/*.md"),
658
667
  plugins: { markdown, review: reviewFrontmatter },
659
668
  ...md,
660
669
  // A review's frontmatter is a record, validated by paperlint's JSON Schema
@@ -664,7 +673,7 @@ export function buildConfig(
664
673
  {
665
674
  // A sibling card says how much of the competing paper was read (`read:`). The cards are
666
675
  // written by this package's analyze-sibling-paper skill; its README is an index, not a card.
667
- files: ["**/siblings/*.md"],
676
+ files: own("siblings/*.md"),
668
677
  ignores: ["**/siblings/README.md"],
669
678
  plugins: { markdown, sibling: siblingFrontmatter },
670
679
  ...md,
@@ -676,7 +685,7 @@ export function buildConfig(
676
685
  // corpus without a single `.tex` would be refusing to work where work is possible.
677
686
  if (texLanguage)
678
687
  cfg.push({
679
- files: ["**/paper.tex"],
688
+ files: own("paper.tex"),
680
689
  plugins: {
681
690
  tex: {
682
691
  languages: { latex: texLanguage },
@@ -760,9 +769,11 @@ export function buildConfig(
760
769
  // PIPELINE-STATUS.md than beside paper.tex, and ESLint throws on a rule its plugin lacks.
761
770
  cfg.push(
762
771
  ...fragments,
763
- ...(opts.rules ?? []).flatMap((b) => narrowToOwners(b, owners)),
772
+ ...(opts.rules ?? []).flatMap((b) => narrowToOwners(b, owners, papers)),
764
773
  );
765
- return cfg;
774
+ // With no paper to claim, an own block's `files` is empty, and ESLint refuses an empty `files`: the
775
+ // block goes, and nothing is linted, which the run then says (#582).
776
+ return cfg.filter((b) => b.files === undefined || b.files.length > 0);
766
777
  }
767
778
 
768
779
  /**
@@ -928,16 +939,34 @@ export async function silentOptionalRules(
928
939
  return [...turnedOn].filter((id) => !reached.has(id));
929
940
  }
930
941
 
931
- /**
932
- * The paper directories `paths` reach: each directory and the papers under it. A FILE named on the
933
- * command line belongs to the paper it sits in.
934
- */
935
- function paperDirs(paths: readonly string[]): readonly string[] {
936
- const dirs = paths.map((p) =>
937
- existsSync(p) && statSync(p).isFile() ? dirname(p) : p,
942
+ /** The disk as the paper-reach rule sees it (`src/domain/paper-dirs.ts`). */
943
+ const PAPER_TREE: PaperTree = {
944
+ ...nodeFiles,
945
+ subfolders: (dir) => {
946
+ try {
947
+ return readdirSync(dir, { withFileTypes: true })
948
+ .filter(
949
+ (e) =>
950
+ e.isDirectory() &&
951
+ !e.name.startsWith(".") &&
952
+ e.name !== "node_modules" &&
953
+ e.name !== ESCAPE_HATCH,
954
+ )
955
+ .map((e) => join(dir, e.name));
956
+ } catch {
957
+ return [];
958
+ }
959
+ },
960
+ };
961
+
962
+ /** The papers `paths` reach: a file counts as the folder it sits in (#582). */
963
+ const paperDirs = (paths: readonly string[]): readonly string[] =>
964
+ papersReached(
965
+ paths.map((p) =>
966
+ resolve(existsSync(p) && statSync(p).isFile() ? dirname(p) : p),
967
+ ),
968
+ PAPER_TREE,
938
969
  );
939
- return [...new Set(dirs.flatMap((p) => [p, ...papersIn(p)]))];
940
- }
941
970
 
942
971
  /**
943
972
  * Every linted paper's rules, as ESLint blocks scoped to that paper, in two groups: what its venue
@@ -2515,11 +2544,16 @@ async function paperEslint(
2515
2544
  ? paperBodies(paperDirs([...paths, ...papersRoots(cfg)]), RECORD_DEPS)
2516
2545
  : [];
2517
2546
 
2547
+ const cwd = lintRoot(cfg.root, paths);
2548
+ // The papers whose own files the config names: the ones `paths` reach and the project's. A copy of
2549
+ // a paper kept inside it (a review snapshot, a build copy) is in no such list, so no block claims
2550
+ // it (#582).
2551
+ const claimed = papersScope(paperDirs([...paths, ...papersRoots(cfg)]), cwd);
2518
2552
  const eslint = new ESLint({
2519
- cwd: lintRoot(cfg.root, paths),
2553
+ cwd,
2520
2554
  overrideConfigFile: true,
2521
2555
  overrideConfig: eslintConfig([
2522
- ...buildConfig(opts, texLanguage),
2556
+ ...buildConfig(opts, texLanguage, claimed),
2523
2557
  ...includeBlocks(bodies),
2524
2558
  ]),
2525
2559
  fix,
@@ -0,0 +1,91 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { dirname } from "node:path";
3
+ import { papersReached, type PaperTree } from "./paper-dirs.ts";
4
+
5
+ /** A disk holding exactly `files`, its folders the ones those files imply. */
6
+ const treeOf = (files: readonly string[]): PaperTree => {
7
+ const dirs = new Set(
8
+ files.flatMap((f) => {
9
+ const up = (d: string): readonly string[] =>
10
+ d === "/" ? [] : [d, ...up(dirname(d))];
11
+ return up(dirname(f));
12
+ }),
13
+ );
14
+ return {
15
+ isFile: (p) => files.includes(p),
16
+ subfolders: (dir) =>
17
+ [...dirs]
18
+ .filter((d) => dirname(d) === dir && !d.endsWith("/extra"))
19
+ .sort(),
20
+ };
21
+ };
22
+
23
+ /** The project every row reads: three papers, a source-only one, a copy in each place one is kept. */
24
+ const PROJECT = treeOf([
25
+ "/w/paperlint.json",
26
+ "/w/papers/p/paper.tex",
27
+ "/w/papers/p/PIPELINE-STATUS.md",
28
+ "/w/papers/p/reviews/r.md",
29
+ "/w/papers/p/reviews/snapshot/paper.tex",
30
+ "/w/papers/p/reviews/snapshot/PIPELINE-STATUS.md",
31
+ "/w/papers/p/old/paper.tex",
32
+ "/w/papers/p/_build/paper.tex",
33
+ "/w/papers/p/extra/2025/paper.tex",
34
+ "/w/papers/q/PIPELINE-STATUS.md",
35
+ "/w/archive/2025/s/paper.tex",
36
+ "/w/archive/2025/s/reviews/r.md",
37
+ "/w/archive/2025/s/reviews/snapshot/PIPELINE-STATUS.md",
38
+ "/w/archive/notes/todo.md",
39
+ ]);
40
+
41
+ describe("the papers a path reaches (#582)", () => {
42
+ test.each([
43
+ [
44
+ "the project root: every paper below it, none inside one",
45
+ ["/w"],
46
+ ["/w/archive/2025/s", "/w/papers/p", "/w/papers/q"],
47
+ ],
48
+ ["a papers directory", ["/w/papers"], ["/w/papers/p", "/w/papers/q"]],
49
+ [
50
+ "a folder two levels above a paper",
51
+ ["/w/archive"],
52
+ ["/w/archive/2025/s"],
53
+ ],
54
+ ["a paper with both markers", ["/w/papers/p"], ["/w/papers/p"]],
55
+ ["a paper with only its scorecard", ["/w/papers/q"], ["/w/papers/q"]],
56
+ [
57
+ "a paper with only its source",
58
+ ["/w/archive/2025/s"],
59
+ ["/w/archive/2025/s"],
60
+ ],
61
+ [
62
+ "a review card's folder, a snapshot beside it",
63
+ ["/w/papers/p/reviews"],
64
+ ["/w/papers/p"],
65
+ ],
66
+ [
67
+ "the same, in a source-only paper",
68
+ ["/w/archive/2025/s/reviews"],
69
+ ["/w/archive/2025/s"],
70
+ ],
71
+ [
72
+ "a build copy named itself",
73
+ ["/w/papers/p/_build"],
74
+ ["/w/papers/p/_build"],
75
+ ],
76
+ [
77
+ "a snapshot named itself",
78
+ ["/w/papers/p/reviews/snapshot"],
79
+ ["/w/papers/p/reviews/snapshot"],
80
+ ],
81
+ ["a folder with no paper at or below it", ["/w/archive/notes"], []],
82
+ ["a paper kept under extra/", ["/w/papers/p/extra/2025"], ["/w/papers/p"]],
83
+ [
84
+ "two paths reaching one paper",
85
+ ["/w/papers/p", "/w/papers/p/reviews"],
86
+ ["/w/papers/p"],
87
+ ],
88
+ ] as const)("%s", (_, dirs, papers) => {
89
+ expect(papersReached(dirs, PROJECT)).toEqual(papers);
90
+ });
91
+ });