paperlint 17.1.0 → 17.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +2 -2
- package/README.md +6 -4
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +28 -29
- package/dist/cli.js.map +1 -1
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +6 -1
- package/dist/presets.js.map +1 -1
- package/dist/register-bands.d.ts +1 -7
- package/dist/register-bands.d.ts.map +1 -1
- package/dist/register-bands.js +12 -19
- package/dist/register-bands.js.map +1 -1
- package/dist/rule-sets.d.ts +43 -0
- package/dist/rule-sets.d.ts.map +1 -0
- package/dist/rule-sets.js +59 -0
- package/dist/rule-sets.js.map +1 -0
- package/dist/rules-config.d.ts +2 -1
- package/dist/rules-config.d.ts.map +1 -1
- package/dist/rules-config.js +17 -3
- package/dist/rules-config.js.map +1 -1
- package/docs/configuration.md +9 -2
- package/docs/optional-rules.md +48 -6
- package/docs/rules/tex/claim-emphasis.md +1 -1
- package/docs/rules/tex/claim-provenance.md +3 -3
- package/docs/rules/tex/contrast-frames.md +1 -1
- package/docs/rules/tex/max-caption-words.md +1 -1
- package/docs/rules/tex/max-paragraph-numbers.md +1 -1
- package/docs/rules/tex/max-paragraph-words.md +1 -1
- package/docs/rules/tex/max-sentence-words.md +1 -1
- package/docs/rules/tex/negated-sentences.md +1 -1
- package/docs/rules/tex/register.md +1 -1
- package/docs/rules/tex/relation-markers.md +1 -1
- package/docs/rules.md +18 -16
- package/fixtures/real-papers.test.ts +3 -0
- package/package.json +1 -1
- package/presets/aidc.jsonc +2 -1
- package/presets/aidc.md +4 -3
- package/src/cli.harness.mjs +25 -5
- package/src/cli.ts +43 -30
- package/src/lint-fix.test.ts +15 -2
- package/src/paper-includes.test.ts +62 -1
- package/src/presets.ts +8 -1
- package/src/register-bands.ts +13 -23
- package/src/rule-cases.test.ts +155 -16
- package/src/rule-sets.test.ts +150 -0
- package/src/rule-sets.ts +63 -0
- package/src/rules-config.ts +31 -3
package/docs/rules.md
CHANGED
|
@@ -27,9 +27,9 @@ reads and when it fails. Errors fail `paperlint lint`; warnings print and do not
|
|
|
27
27
|
| [`repro/study-result`](rules/repro/study-result.md) | error | `repro/studies.json`, each done study's `plan.json` (v2) and `result.json` | a done study whose plan is v2 and whose `result.json` is missing, lacks the number its claim is judged by, crosses that threshold without saying `"claim": "lost"`, lacks a labelling step's kappa or has one below the plan's bar, shows a failed self-test, counts no drop for a declared funnel reason, or audits its extractor on too few files or finds its recall below the plan's bar — [page](rules/repro/study-result.md) |
|
|
28
28
|
| [`paper/sources-fresh`](rules/paper/sources-fresh.md) | warn | `paper.tex` → `_build/sources.json` | the paper has not been built (no record of the files TeX read), or a file changed since the last build (its SHA-256 differs) — run `npx paperlint build` |
|
|
29
29
|
| `paper/author-list` | error | `paper.tex` → `_build/references.json`, `_build/sources.json` | an entry's authors are not those of the version it cites — typically the arXiv preprint's list under a published venue. Checked online by `paperlint build` (DBLP), reported on the entry's own line (or at the top of `paper.tex`, naming the entry's file); silent without a current build record |
|
|
30
|
-
| `paper/section-word` |
|
|
31
|
-
| `paper/leading-zero` |
|
|
32
|
-
| `paper/figure-ref-style` |
|
|
30
|
+
| `paper/section-word` | opt-in: `paperlint:writing` | `paper.tex` and its body files | `§` or `\S\ref` instead of the word Section. **Fixable:** `--fix` writes `Section~\ref{…}` / `Section 5` |
|
|
31
|
+
| `paper/leading-zero` | opt-in: `paperlint:writing` | `paper.tex` and its body files | a decimal below 1 without its leading zero (`.05` instead of `0.05`, IEEE / ISO 80000-1 style), counted only where the reader sees it — prose, math and table cells, not macro options, column specs, comments, code or tikz. A number right after `¶` or `§` (`¶¶.42`) is a paragraph designator and is not reported; in a paragraph that cites numbers that way, another bare decimal is reported without a fix, with the zero as a suggestion. **Fixable** |
|
|
32
|
+
| `paper/figure-ref-style` | opt-in: `paperlint:writing` | `paper.tex` and its body files | `Fig.~\ref` and `Figure~\ref` mixed in one document; each minority occurrence is reported. **Fixable:** `--fix` writes the majority form |
|
|
33
33
|
| [`bib/reachable-entry`](rules/bib/reachable-entry.md) | warn | `paper.tex` → `_build/sources.json`: the databases the last build's bibtex opened | an entry has no doi, url or arXiv id — a reader has nothing to follow. Reported on the entry in the `filecontents` block of `paper.tex` that wrote its `.bib`, or at the top of `paper.tex` with the entry's file and line first; silent until a build records the paper; no fix, the link has to be looked up — [page](rules/bib/reachable-entry.md) |
|
|
34
34
|
| `paper/cite-exists` | error | `paper.tex` → `_build/references.json` | an entry's doi or arXiv id resolves to nothing, or to a different work. Checked online by `paperlint build`; a work that was merely not found is not a finding |
|
|
35
35
|
| `paper/refs-fresh` | error | `paper.tex` → `_build/references.json` | the databases bibtex opened changed since the build checked them (their SHA-256 differs) — run `npx paperlint build` |
|
|
@@ -42,16 +42,16 @@ reads and when it fails. Errors fail `paperlint lint`; warnings print and do not
|
|
|
42
42
|
| [`format/layout-override`](rules/format/layout-override.md) | error | `paper.tex` → `paperlint.json` | the source changes the page layout the venue's template sets for the whole document — `geometry`, a layout `\setlength`, `\linespread`, `\baselinestretch` — [page](rules/format/layout-override.md) |
|
|
43
43
|
| [`anonymity/identity`](rules/anonymity/identity.md) | error | `paper.tex` → `_build/paper.facts.json` | a double-blind venue (`"blind": true`) and no `identity` declared, or a declared name, handle, email or project in the PDF's text, metadata or link targets — [page](rules/anonymity/identity.md) |
|
|
44
44
|
| [`tex/venue-leftover`](rules/tex/venue-leftover.md) | warn | `paper.tex` → `paperlint.json` | the text names another shipped venue than the one the paper extends («Submission to VenueA 2026» in a paper now set for VenueB) — [page](rules/tex/venue-leftover.md) |
|
|
45
|
-
| [`tex/claim-provenance`](rules/tex/claim-provenance.md) |
|
|
46
|
-
| [`tex/register`](rules/tex/register.md) |
|
|
47
|
-
| [`tex/contrast-frames`](rules/tex/contrast-frames.md) |
|
|
48
|
-
| [`tex/claim-emphasis`](rules/tex/claim-emphasis.md) |
|
|
49
|
-
| [`tex/relation-markers`](rules/tex/relation-markers.md) |
|
|
50
|
-
| [`tex/negated-sentences`](rules/tex/negated-sentences.md) |
|
|
51
|
-
| [`tex/max-paragraph-words`](rules/tex/max-paragraph-words.md) |
|
|
52
|
-
| [`tex/max-paragraph-numbers`](rules/tex/max-paragraph-numbers.md) |
|
|
53
|
-
| [`tex/max-sentence-words`](rules/tex/max-sentence-words.md) |
|
|
54
|
-
| [`tex/max-caption-words`](rules/tex/max-caption-words.md) |
|
|
45
|
+
| [`tex/claim-provenance`](rules/tex/claim-provenance.md) | opt-in: `paperlint:writing` | `paper.tex` | a sentence of the body states a number and does not say whose it is — no citation or link, no _we_/_our_, no `\ref` or "Table 2", no sample ("n = 134", "48 runs") — [page](rules/tex/claim-provenance.md) |
|
|
46
|
+
| [`tex/register`](rules/tex/register.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes | the body runs to a post's register: more than 0.8 sentences per 1000 words open with _And_, _So_, _But_, _Nor_, _Or_ or _Yet_ — the limit is an option — [page](rules/tex/register.md) |
|
|
47
|
+
| [`tex/contrast-frames`](rules/tex/contrast-frames.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes → `paperlint.json` | contrast frames (_X, not Y_, _not X but Y_, _rather than_, _instead of_, _as opposed to_) per 10,000 words fall outside the band the venue preset's anchors set (AIDC: 0–10.4, from five accepted ACSAC papers); above it, each frame is reported too — [page](rules/tex/contrast-frames.md) |
|
|
48
|
+
| [`tex/claim-emphasis`](rules/tex/claim-emphasis.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes → `paperlint.json` | claims set in bold inside a sentence (six words or more, or holding a number; not a term, not a label opening a paragraph) per 10,000 words fall outside the preset's band (AIDC: 0–17.8); above it, each is reported too — [page](rules/tex/claim-emphasis.md) |
|
|
49
|
+
| [`tex/relation-markers`](rules/tex/relation-markers.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes → `paperlint.json` | words that name how a sentence relates to the one before (_because_, _therefore_, _however_, _for example_ …) per 10,000 words fall outside the preset's band (AIDC: 25.4–135.0) — the floor that catches relations left to infer — [page](rules/tex/relation-markers.md) |
|
|
50
|
+
| [`tex/negated-sentences`](rules/tex/negated-sentences.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes → `paperlint.json` | the share of body sentences holding a negator (_not_, _no_, _never_, _without_ …) falls outside the preset's band (AIDC: 3.0–21.8%, from five accepted ACSAC papers); _X, not Y_ is counted here and by `tex/contrast-frames` — [page](rules/tex/negated-sentences.md) |
|
|
51
|
+
| [`tex/max-paragraph-words`](rules/tex/max-paragraph-words.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes | a paragraph of the body runs past `max` words (default 150) — a wall of text; no call for papers states a limit — [page](rules/tex/max-paragraph-words.md) |
|
|
52
|
+
| [`tex/max-paragraph-numbers`](rules/tex/max-paragraph-numbers.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes | a paragraph of the body holds more than `max` numbers (default 8) — a table written in prose — [page](rules/tex/max-paragraph-numbers.md) |
|
|
53
|
+
| [`tex/max-sentence-words`](rules/tex/max-sentence-words.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes | a sentence of the body runs past `max` words (default 55) — [page](rules/tex/max-sentence-words.md) |
|
|
54
|
+
| [`tex/max-caption-words`](rules/tex/max-caption-words.md) | opt-in: `paperlint:writing` | `paper.tex` and the files it includes | a caption runs past `max` words (default 100), or one of its sentences past `maxSentence` (default 40) — [page](rules/tex/max-caption-words.md) |
|
|
55
55
|
| [`tex/term-before-definition`](rules/tex/term-before-definition.md) | optional; off until a project turns it on | `paper.tex` and the files it includes | a term the body defines (an `\emph` phrase of 1–4 words, by default) is used before that definition; reported once, at the first earlier use — [page](rules/tex/term-before-definition.md) |
|
|
56
56
|
| [`tex/term-defined-twice`](rules/tex/term-defined-twice.md) | optional; off until a project turns it on | `paper.tex` and the files it includes | a term the body defines is set as a definition again — [page](rules/tex/term-defined-twice.md) |
|
|
57
57
|
| `review/frontmatter` | error | `reviews/*.md` | the review's frontmatter fails paperlint's JSON Schema — a `findings` record without `id`/`status`, an unknown field, or a `cause` outside `skill-defect` · `missing-skill` · `hook` · `rule`. A review with no `findings` key is not checked for findings |
|
|
@@ -91,9 +91,11 @@ LLMs are used», which no rule can know; an author who used none says so in the
|
|
|
91
91
|
The `talk/*` rules judge a talk's finished files and are silent for a paper that declares no
|
|
92
92
|
`talk` (but `talk/undeclared`): [`talk.md`](talk.md).
|
|
93
93
|
|
|
94
|
-
Optional rules — off unless you turn them on in the `rules` setting
|
|
95
|
-
|
|
96
|
-
`
|
|
94
|
+
Optional rules — off unless you or your venue preset turn them on in the `rules` setting — are on
|
|
95
|
+
their own page: [`optional-rules.md`](optional-rules.md). The rules that flag the writing rather
|
|
96
|
+
than what the venue decides (the level `opt-in: paperlint:writing` above) are one named set, turned
|
|
97
|
+
on in one line: `"rules": { "paperlint:writing": "warn" }`
|
|
98
|
+
([`optional-rules.md`](optional-rules.md#the-writing-set-paperlintwriting)).
|
|
97
99
|
|
|
98
100
|
## A deliberate exception: a disable directive, with the reason
|
|
99
101
|
|
|
@@ -33,6 +33,7 @@ import { useTempDir, writeTree } from "../test/support.ts";
|
|
|
33
33
|
import {
|
|
34
34
|
compareToBaseline,
|
|
35
35
|
countByPaper,
|
|
36
|
+
RECORDED_OPT_IN,
|
|
36
37
|
recordedFindings,
|
|
37
38
|
} from "./accepted-papers/baseline.ts";
|
|
38
39
|
|
|
@@ -54,6 +55,8 @@ const PAPERS = FOLDERS.flatMap((root) =>
|
|
|
54
55
|
async function lintAll(): Promise<ReturnType<typeof countByPaper>> {
|
|
55
56
|
const dir = writeTree(useTempDir("paperlint-real-papers-"), {
|
|
56
57
|
"package.json": '{"name":"consumer","private":true}',
|
|
58
|
+
// The opt-in rules the baselines count, on for every paper (baseline.ts says why).
|
|
59
|
+
"paperlint.json": JSON.stringify({ rules: RECORDED_OPT_IN }),
|
|
57
60
|
});
|
|
58
61
|
for (const { name, dir: from } of PAPERS) {
|
|
59
62
|
cpSync(from, join(dir, "papers", name), {
|
package/package.json
CHANGED
package/presets/aidc.jsonc
CHANGED
|
@@ -87,7 +87,8 @@
|
|
|
87
87
|
// contrast frames anchors 1.3–5.5 band 0–10.4
|
|
88
88
|
// claims in bold anchors 0.0–10.4 band 0–17.8
|
|
89
89
|
// relation markers anchors 39.4–112.8 band 25.4–135.0
|
|
90
|
-
// and, as a percent of the body's sentences (tex/negated-sentences
|
|
90
|
+
// and, as a percent of the body's sentences (tex/negated-sentences). All four rules are off by
|
|
91
|
+
// default and judge these bands only when a paper turns on the set paperlint:writing:
|
|
91
92
|
// negated sentences anchors 5.3–17.8% band 3.0–21.8%
|
|
92
93
|
"register": {
|
|
93
94
|
"anchors": [
|
package/presets/aidc.md
CHANGED
|
@@ -61,9 +61,10 @@ See `docs/rules/format/page-limit.md`.
|
|
|
61
61
|
submission through HotCRP's API on that site.
|
|
62
62
|
- **Names**: `AIDC` and `ACSAC`, what `tex/venue-leftover` looks for in another venue's paper.
|
|
63
63
|
- **The register of the body** (`register`): the workshop's first edition has no accepted papers,
|
|
64
|
-
so the bands of `tex/contrast-frames`, `tex/claim-emphasis
|
|
65
|
-
`tex/negated-sentences
|
|
66
|
-
|
|
64
|
+
so the bands of `tex/contrast-frames`, `tex/claim-emphasis`, `tex/relation-markers` and
|
|
65
|
+
`tex/negated-sentences` are set by five accepted ACSAC papers on the same template, in
|
|
66
|
+
`fixtures/accepted-papers/`. The four rules are off by default, here too; the opt-in set
|
|
67
|
+
`paperlint:writing` turns them on ([optional rules](../docs/optional-rules.md)).
|
|
67
68
|
|
|
68
69
|
## What the preset resolves to
|
|
69
70
|
|
package/src/cli.harness.mjs
CHANGED
|
@@ -917,9 +917,13 @@ check(
|
|
|
917
917
|
join(paper, "PIPELINE-STATUS.md"),
|
|
918
918
|
`---\nstages:\n - stage: submitted\n date: 2026-07-22\n pdf: versions/2026-07-22-submitted.pdf\n bytes: 100\n source: versions/s.tex\n sourceBytes: 4\n---\n# S\n\n| id | note |\n|---|---|\n| cites | bib-authors run |\n`,
|
|
919
919
|
);
|
|
920
|
+
// `paper/section-word` is in the opt-in writing set: on for every paper here.
|
|
920
921
|
writeFileSync(
|
|
921
922
|
join(root, "paperlint.json"),
|
|
922
|
-
JSON.stringify({
|
|
923
|
+
JSON.stringify({
|
|
924
|
+
[PAPERS_DIR_FIELD]: "papers",
|
|
925
|
+
rules: { "paperlint:writing": "warn" },
|
|
926
|
+
}),
|
|
923
927
|
);
|
|
924
928
|
|
|
925
929
|
const lax = await cli(["lint"], root);
|
|
@@ -1036,10 +1040,17 @@ check(
|
|
|
1036
1040
|
// (`"papers/p"`). Keys are computed against ESLint's `cwd`, so a run started from a
|
|
1037
1041
|
// subdirectory, or with `--config` from elsewhere, silently stopped honouring the debt.
|
|
1038
1042
|
{
|
|
1043
|
+
// A message that names the paper's own `paperlint.json` names it as the reader typed it, so
|
|
1044
|
+
// relative to where the run started: that path is the run's, like the file paths, and is masked.
|
|
1039
1045
|
const findings = (r) => {
|
|
1040
1046
|
try {
|
|
1041
1047
|
return JSON.parse(r.stdout)
|
|
1042
|
-
.flatMap((x) =>
|
|
1048
|
+
.flatMap((x) =>
|
|
1049
|
+
x.messages.map(
|
|
1050
|
+
(m) =>
|
|
1051
|
+
`${m.ruleId}: ${m.message.replace(/\S*papers\/p\/paperlint\.json/g, "<paper>/paperlint.json")}`,
|
|
1052
|
+
),
|
|
1053
|
+
)
|
|
1043
1054
|
.sort();
|
|
1044
1055
|
} catch {
|
|
1045
1056
|
return [`UNPARSABLE: ${r.out}`];
|
|
@@ -1052,8 +1063,14 @@ check(
|
|
|
1052
1063
|
try {
|
|
1053
1064
|
const paper = join(tree, "papers", "p");
|
|
1054
1065
|
mkdirSync(paper, { recursive: true });
|
|
1055
|
-
// Two findings of different kinds: a structural one (no scorecard) and a rule one (`§`).
|
|
1066
|
+
// Two findings of different kinds: a structural one (no scorecard) and a rule one (`§`). The
|
|
1067
|
+
// `§` rule is in the opt-in writing set, turned on in the paper's own file, which is read
|
|
1068
|
+
// wherever the command runs.
|
|
1056
1069
|
writeFileSync(join(paper, "paper.tex"), tex("See § 3 and §4."));
|
|
1070
|
+
writeFileSync(
|
|
1071
|
+
join(paper, "paperlint.json"),
|
|
1072
|
+
JSON.stringify({ rules: { "paperlint:writing": "warn" } }),
|
|
1073
|
+
);
|
|
1057
1074
|
|
|
1058
1075
|
const inside = await cli(["lint", "--json", "papers"], tree);
|
|
1059
1076
|
const outside = await cli(
|
|
@@ -1077,12 +1094,15 @@ check(
|
|
|
1077
1094
|
);
|
|
1078
1095
|
|
|
1079
1096
|
// A `rules` block, its `files` relative to the config's directory, turns the `§` rule off
|
|
1080
|
-
// for this paper — and it must reach the paper from wherever the command runs.
|
|
1097
|
+
// for this paper — and it must reach the paper from wherever the command runs. The set moves
|
|
1098
|
+
// to the root file, before the block: a paper's own file would win over the root's.
|
|
1099
|
+
rmSync(join(paper, "paperlint.json"));
|
|
1081
1100
|
writeFileSync(
|
|
1082
1101
|
join(tree, "paperlint.json"),
|
|
1083
1102
|
JSON.stringify({
|
|
1084
1103
|
[PAPERS_DIR_FIELD]: "papers",
|
|
1085
1104
|
rules: [
|
|
1105
|
+
{ rules: { "paperlint:writing": "warn" } },
|
|
1086
1106
|
{ files: ["papers/p/**"], rules: { "paper/section-word": "off" } },
|
|
1087
1107
|
],
|
|
1088
1108
|
}),
|
|
@@ -1859,7 +1879,7 @@ console.log(
|
|
|
1859
1879
|
),
|
|
1860
1880
|
);
|
|
1861
1881
|
settings({
|
|
1862
|
-
rules: [{ files: ["papers/**"], rules: { "
|
|
1882
|
+
rules: [{ files: ["papers/**"], rules: { "tex/future-promise": "off" } }],
|
|
1863
1883
|
});
|
|
1864
1884
|
check(
|
|
1865
1885
|
"a built-in rule's severity can be changed the same way",
|
package/src/cli.ts
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
FRAGMENT_FILES,
|
|
48
48
|
includeBlocks,
|
|
49
49
|
paperBodies,
|
|
50
|
+
type PaperBody,
|
|
50
51
|
} from "./paper-includes.ts";
|
|
51
52
|
import { omit } from "remeda";
|
|
52
53
|
import { refusalOf } from "./unowned-file.ts";
|
|
@@ -89,10 +90,7 @@ import {
|
|
|
89
90
|
import { claimProvenanceRule } from "./claim-provenance.ts";
|
|
90
91
|
import { termDefinitionRules } from "./term-definition-rules.ts";
|
|
91
92
|
import { registerRule } from "./register.ts";
|
|
92
|
-
import {
|
|
93
|
-
REGISTER_BAND_RULE_LEVELS,
|
|
94
|
-
registerBandRules,
|
|
95
|
-
} from "./register-bands.ts";
|
|
93
|
+
import { registerBandRules } from "./register-bands.ts";
|
|
96
94
|
import { headingCaseRule } from "./heading-case.ts";
|
|
97
95
|
import {
|
|
98
96
|
maxParagraphNumbersRule,
|
|
@@ -577,11 +575,10 @@ export function buildConfig(
|
|
|
577
575
|
...referenceRules(RECORDED_DEPS),
|
|
578
576
|
...sourcesRules(RECORD_DEPS),
|
|
579
577
|
};
|
|
580
|
-
//
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
};
|
|
578
|
+
// The typography rules (each fixes what it reports, `--fix`), `tex/claim-provenance`,
|
|
579
|
+
// `tex/register` and the register bands are registered here and on for no file: they flag the
|
|
580
|
+
// writing, not what the venue decides, so they are in the opt-in set `paperlint:writing`
|
|
581
|
+
// (src/rule-sets.ts).
|
|
585
582
|
const md = MARKDOWN_WITH_FRONTMATTER;
|
|
586
583
|
|
|
587
584
|
const cfg: ConfigBlock[] = [
|
|
@@ -687,19 +684,10 @@ export function buildConfig(
|
|
|
687
684
|
},
|
|
688
685
|
language: "tex/latex",
|
|
689
686
|
rules: {
|
|
690
|
-
...prose,
|
|
691
687
|
...REFERENCE_RULE_LEVELS,
|
|
692
688
|
...SOURCES_RULE_LEVELS,
|
|
693
|
-
"paper/figure-ref-style": "warn",
|
|
694
689
|
...BIB_RULE_LEVELS,
|
|
695
690
|
"tex/future-promise": "warn",
|
|
696
|
-
// A number with no owner: a prose rule, on beside the others above.
|
|
697
|
-
"tex/claim-provenance": "warn",
|
|
698
|
-
// Sentence-initial conjunctions over the whole body: register, not vocabulary.
|
|
699
|
-
"tex/register": "warn",
|
|
700
|
-
// Contrast frames, claims in bold, relation markers: each against the band the venue
|
|
701
|
-
// preset's anchors set, silent for a preset without anchors (src/register-bands.ts).
|
|
702
|
-
...REGISTER_BAND_RULE_LEVELS,
|
|
703
691
|
"tex/acm-frontmatter-override": "error",
|
|
704
692
|
// Silent for a paper whose paperlint.json names no venue (src/venue-rules.ts).
|
|
705
693
|
...VENUE_RULE_LEVELS,
|
|
@@ -737,12 +725,9 @@ export function buildConfig(
|
|
|
737
725
|
},
|
|
738
726
|
},
|
|
739
727
|
language: "tex/latex",
|
|
740
|
-
rules
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
"paper/figure-ref-style": "warn",
|
|
744
|
-
"tex/future-promise": "warn",
|
|
745
|
-
},
|
|
728
|
+
// The typography rules are registered here so the writing set reaches a body file too;
|
|
729
|
+
// like on `paper.tex`, they are on only where a `rules` setting turns them on.
|
|
730
|
+
rules: { "tex/future-promise": "warn" },
|
|
746
731
|
},
|
|
747
732
|
]
|
|
748
733
|
: [];
|
|
@@ -872,7 +857,22 @@ export const OPTIONAL_RULES: ReadonlySet<string> = new Set(
|
|
|
872
857
|
* project. Judged against the run alone, `paperlint lint papers/c` failed on a block written for
|
|
873
858
|
* papers a and b (#103) — a block that reaches a paper outside this run is not dead. A glob that
|
|
874
859
|
* reaches no paper of the project at all still fails, from a subset as from the whole.
|
|
860
|
+
*
|
|
861
|
+
* A paper's rules reach it through its `PIPELINE-STATUS.md` too, and the typography rules through
|
|
862
|
+
* every body file handed to ESLint (`bodyFiles`): a block whose `files` name only `sections/*.tex`
|
|
863
|
+
* runs there, and was refused as reaching nothing until those files were probed as well. They are
|
|
864
|
+
* the files read from each paper's record BEFORE the run (`bodyFilesOf`), never read again after
|
|
865
|
+
* it: `--fix` rewrites a body file, the record no longer matches it, and a second read found no
|
|
866
|
+
* body files and refused a run whose rule had just fixed one.
|
|
875
867
|
*/
|
|
868
|
+
/** The body files `bodies` handed to ESLint, for the paper whose `paper.tex` is `main`. */
|
|
869
|
+
const bodyFilesOf =
|
|
870
|
+
(bodies: readonly PaperBody[]) =>
|
|
871
|
+
(main: string): readonly string[] =>
|
|
872
|
+
bodies
|
|
873
|
+
.filter((b) => resolve(b.main) === resolve(main))
|
|
874
|
+
.flatMap((b) => b.files);
|
|
875
|
+
|
|
876
876
|
/** What `calculateConfigForFile` answers, read for its rules: undefined for a file outside ESLint's cwd or scope. */
|
|
877
877
|
const ComputedConfig = z
|
|
878
878
|
.object({ rules: z.record(z.string(), z.unknown()).optional() })
|
|
@@ -882,6 +882,7 @@ export async function silentOptionalRules(
|
|
|
882
882
|
eslint: Pick<ESLint, "calculateConfigForFile">,
|
|
883
883
|
files: readonly string[],
|
|
884
884
|
opts: PaperlintConfig,
|
|
885
|
+
bodyFiles: (main: string) => readonly string[] = () => [],
|
|
885
886
|
): Promise<string[]> {
|
|
886
887
|
const turnedOn = new Set(
|
|
887
888
|
(opts.rules ?? []).flatMap((b) =>
|
|
@@ -891,11 +892,11 @@ export async function silentOptionalRules(
|
|
|
891
892
|
),
|
|
892
893
|
);
|
|
893
894
|
const reached = new Set<string>();
|
|
894
|
-
// A paper's rules reach it through
|
|
895
|
-
//
|
|
895
|
+
// A paper's rules reach it through `paper.tex`, the `PIPELINE-STATUS.md` beside it, where the
|
|
896
|
+
// rules about the paper folder itself run, and the body files its last build recorded.
|
|
896
897
|
const probes = [
|
|
897
898
|
...new Set(files.filter((p) => basename(p) === MAIN)),
|
|
898
|
-
].flatMap((f) => [f, join(dirname(f), STATUS_FILE)]);
|
|
899
|
+
].flatMap((f) => [f, join(dirname(f), STATUS_FILE), ...bodyFiles(f)]);
|
|
899
900
|
for (const probe of probes) {
|
|
900
901
|
// Undefined for a file outside ESLint's cwd or scope: it reaches nothing.
|
|
901
902
|
const cfg = ComputedConfig.parse(
|
|
@@ -2367,7 +2368,7 @@ export async function run(
|
|
|
2367
2368
|
stats: true,
|
|
2368
2369
|
});
|
|
2369
2370
|
if (!engine.ok) return (err(engine.error), 2);
|
|
2370
|
-
const { eslint, opts: withPapers } = engine.value;
|
|
2371
|
+
const { eslint, opts: withPapers, bodies } = engine.value;
|
|
2371
2372
|
|
|
2372
2373
|
const unowned = await firstUnownedFile(eslint, paths);
|
|
2373
2374
|
if (unowned !== null) {
|
|
@@ -2424,6 +2425,7 @@ export async function run(
|
|
|
2424
2425
|
.flatMap((r) => papersIn(r))
|
|
2425
2426
|
.map((d) => join(d, MAIN))
|
|
2426
2427
|
.filter((f) => existsSync(f)),
|
|
2428
|
+
bodies,
|
|
2427
2429
|
});
|
|
2428
2430
|
hooksLine(root, err, skillLinks);
|
|
2429
2431
|
// On stderr, so `--json` leaves stdout a clean array.
|
|
@@ -2455,7 +2457,14 @@ async function paperEslint(
|
|
|
2455
2457
|
/** ESLint's own per-rule timings on each result (`paperlint lint` reads them; the hook does not). */
|
|
2456
2458
|
readonly stats: boolean;
|
|
2457
2459
|
},
|
|
2458
|
-
): Promise<
|
|
2460
|
+
): Promise<
|
|
2461
|
+
Parsed<{
|
|
2462
|
+
eslint: ESLint;
|
|
2463
|
+
opts: PaperlintConfig;
|
|
2464
|
+
/** The body files handed to ESLint, read from each paper's record BEFORE the run (`--fix` may change them). */
|
|
2465
|
+
bodies: readonly PaperBody[];
|
|
2466
|
+
}>
|
|
2467
|
+
> {
|
|
2459
2468
|
// The order, most general first so the most specific wins (ESLint: a later block wins): each
|
|
2460
2469
|
// paper's venue preset → the root paperlint.json → the paper's own paperlint.json.
|
|
2461
2470
|
const papers = paperRuleBlocks(paths);
|
|
@@ -2491,7 +2500,7 @@ async function paperEslint(
|
|
|
2491
2500
|
fix,
|
|
2492
2501
|
stats,
|
|
2493
2502
|
});
|
|
2494
|
-
return { ok: true, value: { eslint, opts } };
|
|
2503
|
+
return { ok: true, value: { eslint, opts, bodies } };
|
|
2495
2504
|
}
|
|
2496
2505
|
|
|
2497
2506
|
/**
|
|
@@ -2635,6 +2644,7 @@ async function reportLint(
|
|
|
2635
2644
|
where,
|
|
2636
2645
|
opts,
|
|
2637
2646
|
projectPapers,
|
|
2647
|
+
bodies,
|
|
2638
2648
|
}: {
|
|
2639
2649
|
a: Args;
|
|
2640
2650
|
log: typeof console.log;
|
|
@@ -2642,12 +2652,15 @@ async function reportLint(
|
|
|
2642
2652
|
where: string;
|
|
2643
2653
|
opts: PaperlintConfig;
|
|
2644
2654
|
projectPapers: readonly string[];
|
|
2655
|
+
/** The body files handed to ESLint, as read before the run. */
|
|
2656
|
+
bodies: readonly PaperBody[];
|
|
2645
2657
|
},
|
|
2646
2658
|
): Promise<number> {
|
|
2647
2659
|
const silent = await silentOptionalRules(
|
|
2648
2660
|
eslint,
|
|
2649
2661
|
[...results.map((r) => r.filePath), ...projectPapers],
|
|
2650
2662
|
opts,
|
|
2663
|
+
bodyFilesOf(bodies),
|
|
2651
2664
|
);
|
|
2652
2665
|
if (silent.length > 0) {
|
|
2653
2666
|
err(
|
package/src/lint-fix.test.ts
CHANGED
|
@@ -59,9 +59,12 @@ const ruleIds = (stdout: string): string[] =>
|
|
|
59
59
|
r.messages.map((m) => m.ruleId ?? "(fatal)"),
|
|
60
60
|
);
|
|
61
61
|
|
|
62
|
+
/** The writing set on for every paper: the typography rules `--fix` rewrites are in it. */
|
|
63
|
+
const WRITING = { rules: { "paperlint:writing": "warn" } };
|
|
64
|
+
|
|
62
65
|
describe("paperlint lint --fix", () => {
|
|
63
66
|
it("🔴 three `§` and a bare decimal → --fix → zero findings, and the file says Section", async () => {
|
|
64
|
-
const root = project(
|
|
67
|
+
const root = project(WRITING);
|
|
65
68
|
const before = ruleIds((await lint(root)).out);
|
|
66
69
|
expect(before.filter((r) => r === "paper/section-word")).toHaveLength(3);
|
|
67
70
|
expect(before).toContain("paper/leading-zero");
|
|
@@ -74,12 +77,22 @@ describe("paperlint lint --fix", () => {
|
|
|
74
77
|
});
|
|
75
78
|
|
|
76
79
|
it("without --fix nothing is written", async () => {
|
|
77
|
-
const root = project(
|
|
80
|
+
const root = project(WRITING);
|
|
78
81
|
await lint(root);
|
|
79
82
|
expect(readFileSync(join(root, "papers/a/paper.tex"), "utf8")).toMatch(
|
|
80
83
|
/§5/,
|
|
81
84
|
);
|
|
82
85
|
});
|
|
86
|
+
|
|
87
|
+
it("🔴 without the writing set, the same paper gets no typography finding and --fix writes nothing", async () => {
|
|
88
|
+
const root = project({});
|
|
89
|
+
const ids = ruleIds((await lint(root, ["--fix"])).out);
|
|
90
|
+
expect(ids).not.toContain("paper/section-word");
|
|
91
|
+
expect(ids).not.toContain("paper/leading-zero");
|
|
92
|
+
expect(readFileSync(join(root, "papers/a/paper.tex"), "utf8")).toBe(
|
|
93
|
+
PAPER("See §5, §6 and §7; $p < .05$."),
|
|
94
|
+
);
|
|
95
|
+
});
|
|
83
96
|
});
|
|
84
97
|
|
|
85
98
|
describe("sibling cards: `read:` is required, from the package's own schema", () => {
|
|
@@ -55,6 +55,10 @@ function project(
|
|
|
55
55
|
dirs.push(root);
|
|
56
56
|
const all: Record<string, string> = {
|
|
57
57
|
"package.json": JSON.stringify({ name: "c", private: true }),
|
|
58
|
+
// The typography rules these cases read are opt-in, in the writing set: on for every paper.
|
|
59
|
+
"paperlint.json": JSON.stringify({
|
|
60
|
+
rules: { "paperlint:writing": "warn" },
|
|
61
|
+
}),
|
|
58
62
|
"papers/a/PIPELINE-STATUS.md": "---\nstages: []\n---\n",
|
|
59
63
|
"papers/a/paper.tex": doc(
|
|
60
64
|
"{article}",
|
|
@@ -215,11 +219,68 @@ describe("a built paper whose files are clean", () => {
|
|
|
215
219
|
});
|
|
216
220
|
expect({ code, out }).toEqual({
|
|
217
221
|
code: 0,
|
|
218
|
-
|
|
222
|
+
// The root file that turns the writing set on is named first, as every found config is.
|
|
223
|
+
out: ["config: paperlint.json", "✓ 3 file(s) checked, no findings"],
|
|
219
224
|
});
|
|
220
225
|
});
|
|
221
226
|
});
|
|
222
227
|
|
|
228
|
+
describe("an opt-in rule turned on for a paper's body files only", () => {
|
|
229
|
+
/** `paper/leading-zero` on for `files` alone, in the root file: no writing set. */
|
|
230
|
+
const onlyFor = (files: string[]) => ({
|
|
231
|
+
"paperlint.json": JSON.stringify({
|
|
232
|
+
rules: [{ files, rules: { "paper/leading-zero": "warn" } }],
|
|
233
|
+
}),
|
|
234
|
+
});
|
|
235
|
+
const lintCode = async (root: string, args: string[] = []) => {
|
|
236
|
+
const out: string[] = [];
|
|
237
|
+
const err: string[] = [];
|
|
238
|
+
const code = await run(["lint", "--json", ...args], {
|
|
239
|
+
cwd: root,
|
|
240
|
+
log: (s: string) => out.push(s),
|
|
241
|
+
err: (s: string) => err.push(s),
|
|
242
|
+
});
|
|
243
|
+
return { code, out: out.join("\n"), err: err.join("\n") };
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
it("🔴 reaches the included file it runs on: the run reports there, and is not refused as a rule no paper gets", async () => {
|
|
247
|
+
const r = await lintCode(project(onlyFor(["papers/a/sections/**/*.tex"])));
|
|
248
|
+
expect(r.err).not.toMatch(/no paper\.tex of the project gets it/);
|
|
249
|
+
expect(r.code).toBe(0);
|
|
250
|
+
const intro = lintReport(r.out).find((f) =>
|
|
251
|
+
f.filePath.endsWith("papers/a/sections/intro.tex"),
|
|
252
|
+
);
|
|
253
|
+
expect(intro?.messages.map((m) => m.ruleId)).toEqual([
|
|
254
|
+
"paper/leading-zero",
|
|
255
|
+
]);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it("🔴 with --fix too: the fix rewrites the included file, which leaves the build's record behind it, and the run is still not refused", async () => {
|
|
259
|
+
const root = project(onlyFor(["papers/a/sections/**/*.tex"]));
|
|
260
|
+
const r = await lintCode(root, ["--fix"]);
|
|
261
|
+
expect(r.err).not.toMatch(/no paper\.tex of the project gets it/);
|
|
262
|
+
expect(r.code).toBe(0);
|
|
263
|
+
expect(lintReport(r.out).length).toBeGreaterThan(0);
|
|
264
|
+
expect(
|
|
265
|
+
readFileSync(join(root, "papers/a/sections/intro.tex"), "utf8"),
|
|
266
|
+
).toBe(INTRO.replace(".05", "0.05"));
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it.each([[[]], [["--fix"]]])(
|
|
270
|
+
"a glob that reaches no file of any paper still fails the run (args %j)",
|
|
271
|
+
async (args) => {
|
|
272
|
+
const r = await lintCode(
|
|
273
|
+
project(onlyFor(["papers/a/nothing/**/*.tex"])),
|
|
274
|
+
args,
|
|
275
|
+
);
|
|
276
|
+
expect(r.code).toBe(1);
|
|
277
|
+
expect(r.err).toMatch(
|
|
278
|
+
/^paper\/leading-zero is turned on in "rules", but no paper\.tex of the project gets it/m,
|
|
279
|
+
);
|
|
280
|
+
},
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
|
|
223
284
|
describe("a paper whose record is missing, stale or silent about a file", () => {
|
|
224
285
|
it("🔴 a paper no build has recorded is paper.tex alone: its includes are not linted, and paper/sources-fresh says so", async () => {
|
|
225
286
|
const { byFile } = await lint(project({}, null));
|
package/src/presets.ts
CHANGED
|
@@ -68,6 +68,7 @@ import {
|
|
|
68
68
|
} from "./paper-settings.ts";
|
|
69
69
|
import { CONFIG_FILE } from "#lib/paper-config";
|
|
70
70
|
import { messageOf } from "./domain/text.ts";
|
|
71
|
+
import { setMembers } from "./rule-sets.ts";
|
|
71
72
|
import type { RegisterAnchor } from "./domain/register.ts";
|
|
72
73
|
import type { VenueTalk } from "./domain/talk.ts";
|
|
73
74
|
import type { VenuePortal } from "./domain/submission.ts";
|
|
@@ -508,6 +509,12 @@ export const venueOf = ({
|
|
|
508
509
|
export const shippedVenueNames = (deps: PresetDeps): readonly ShippedVenue[] =>
|
|
509
510
|
resolveShipped(deps).map(venueOf);
|
|
510
511
|
|
|
512
|
+
/** For a rule set named where a venue belongs, where the set goes instead; "" otherwise. Pure. */
|
|
513
|
+
const ruleSetHint = (spec: string): string =>
|
|
514
|
+
setMembers(spec) === null
|
|
515
|
+
? ""
|
|
516
|
+
: `. ${spec} is a rule set, not a venue: turn it on in "rules": { "${spec}": "warn" }`;
|
|
517
|
+
|
|
511
518
|
/**
|
|
512
519
|
* One line for a problem, naming what to change. `key` is the setting that named the spec of an
|
|
513
520
|
* `unsupported` or `not-found` problem. Pure.
|
|
@@ -520,7 +527,7 @@ export function presetProblemText(
|
|
|
520
527
|
case "unsupported":
|
|
521
528
|
return `"${key}": "${p.spec}" — a preset is \`paperlint:<name>\` (shipped) or a path starting with ./ or ../ (your own); npm presets: not yet supported. Did you mean "${shippedSpec(p.spec)}"?`;
|
|
522
529
|
case "not-found":
|
|
523
|
-
return `"${key}": "${p.spec}" names no preset (${p.file}); shipped presets (${SHIPPED_PREFIX}<name>): ${p.shipped.join(", ")}`;
|
|
530
|
+
return `"${key}": "${p.spec}" names no preset (${p.file}); shipped presets (${SHIPPED_PREFIX}<name>): ${p.shipped.join(", ")}${ruleSetHint(p.spec)}`;
|
|
524
531
|
case "cycle":
|
|
525
532
|
return `the presets extend each other in a cycle: ${p.chain.join(" → ")}`;
|
|
526
533
|
case "too-deep":
|