paperlint 18.2.2 β 18.3.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/dist/readability.d.ts +12 -9
- package/dist/readability.d.ts.map +1 -1
- package/dist/readability.js +3 -3
- package/dist/readability.js.map +1 -1
- package/docs/optional-rules.md +2 -2
- package/docs/rules/tex/max-paragraph-numbers.md +13 -7
- package/docs/rules/tex/max-paragraph-words.md +17 -28
- package/docs/rules.md +2 -2
- package/package.json +1 -1
- package/scripts/grow-real-papers/archive.test.ts +294 -0
- package/scripts/grow-real-papers/archive.ts +287 -0
- package/scripts/grow-real-papers/collect.test.ts +329 -0
- package/scripts/grow-real-papers/collect.ts +316 -0
- package/scripts/grow-real-papers/http.test.ts +95 -0
- package/scripts/grow-real-papers/http.ts +76 -0
- package/scripts/grow-real-papers/main.test.ts +295 -0
- package/scripts/grow-real-papers/main.ts +221 -0
- package/scripts/grow-real-papers/paper.test.ts +305 -0
- package/scripts/grow-real-papers/paper.ts +241 -0
- package/scripts/grow-real-papers/rules.test.ts +222 -0
- package/scripts/grow-real-papers/rules.ts +250 -0
- package/scripts/grow-real-papers/sources.test.ts +275 -0
- package/scripts/grow-real-papers/sources.ts +239 -0
- package/scripts/grow-real-papers/testkit.ts +79 -0
- package/src/readability.test.ts +44 -41
- package/src/readability.ts +12 -9
- package/src/rule-cases.test.ts +6 -6
package/src/readability.test.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { latexReader } from "./adapters/latex/index.ts";
|
|
|
7
7
|
import { memoryFiles } from "./adapters/memory/index.ts";
|
|
8
8
|
import { sourcesCodec } from "./adapters/sources-record/index.ts";
|
|
9
9
|
import {
|
|
10
|
+
DEFAULT_MAX_PARAGRAPH_NUMBERS,
|
|
10
11
|
DEFAULT_MAX_PARAGRAPH_WORDS,
|
|
11
12
|
judgeCaptionWords,
|
|
12
13
|
judgeParagraphNumbers,
|
|
@@ -44,21 +45,21 @@ const found = (body: string) =>
|
|
|
44
45
|
).map((f) => f.data);
|
|
45
46
|
|
|
46
47
|
describe("tex/max-paragraph-words β a paragraph over the ceiling, and only that", () => {
|
|
47
|
-
it("π΄
|
|
48
|
+
it("π΄ 251 words: fires, with the count, the ceiling and the paragraph's first words", () => {
|
|
48
49
|
// Guards: the case that was a false green once β a long single sentence tripped a sentence
|
|
49
50
|
// ceiling and never the paragraph one. Here every sentence is at most ten words.
|
|
50
|
-
expect(found(paragraph(
|
|
51
|
+
expect(found(paragraph(251))).toEqual([
|
|
51
52
|
{
|
|
52
|
-
words:
|
|
53
|
-
max:
|
|
53
|
+
words: 251,
|
|
54
|
+
max: 250,
|
|
54
55
|
head: "The rule reads the body and counts whatβ¦",
|
|
55
56
|
},
|
|
56
57
|
]);
|
|
57
58
|
});
|
|
58
59
|
|
|
59
|
-
it("
|
|
60
|
-
// Guards: the ceiling is inclusive β
|
|
61
|
-
expect(found(paragraph(
|
|
60
|
+
it("250 words and a short paragraph: silent", () => {
|
|
61
|
+
// Guards: the ceiling is inclusive β 250 is allowed.
|
|
62
|
+
expect(found(paragraph(250))).toEqual([]);
|
|
62
63
|
expect(found(paragraph(30))).toEqual([]);
|
|
63
64
|
});
|
|
64
65
|
|
|
@@ -89,9 +90,9 @@ describe("maxOf β the ceiling a config sets", () => {
|
|
|
89
90
|
it("the option when it is set, the default otherwise", () => {
|
|
90
91
|
// Guards: ESLint has validated the option; anything else falls back to the default.
|
|
91
92
|
expect(maxOf([{ max: 120 }])).toBe(120);
|
|
92
|
-
expect(maxOf([])).toBe(
|
|
93
|
-
expect(maxOf(undefined)).toBe(
|
|
94
|
-
expect(maxOf(["warn"])).toBe(
|
|
93
|
+
expect(maxOf([])).toBe(250);
|
|
94
|
+
expect(maxOf(undefined)).toBe(250);
|
|
95
|
+
expect(maxOf(["warn"])).toBe(250);
|
|
95
96
|
});
|
|
96
97
|
});
|
|
97
98
|
|
|
@@ -128,13 +129,13 @@ describe("the rule, through its create()", () => {
|
|
|
128
129
|
};
|
|
129
130
|
|
|
130
131
|
it("reports at the paragraph's first line, with its message id", () => {
|
|
131
|
-
expect(reported(paragraph(
|
|
132
|
+
expect(reported(paragraph(260))).toEqual([
|
|
132
133
|
{
|
|
133
134
|
loc: { start: { line: 3, column: 0 }, end: { line: 3, column: 0 } },
|
|
134
135
|
messageId: "paragraph",
|
|
135
136
|
data: {
|
|
136
|
-
words:
|
|
137
|
-
max:
|
|
137
|
+
words: 260,
|
|
138
|
+
max: 250,
|
|
138
139
|
head: "The rule reads the body and counts whatβ¦",
|
|
139
140
|
},
|
|
140
141
|
},
|
|
@@ -143,65 +144,67 @@ describe("the rule, through its create()", () => {
|
|
|
143
144
|
|
|
144
145
|
it("a source without a raw text is read from its text", () => {
|
|
145
146
|
// Guards: ESLint's source code may carry no `raw`; the rule falls back to `text`.
|
|
146
|
-
expect(reported(paragraph(
|
|
147
|
+
expect(reported(paragraph(260), [], false)).toHaveLength(1);
|
|
147
148
|
});
|
|
148
149
|
|
|
149
|
-
it("an option moves the ceiling:
|
|
150
|
-
expect(reported(paragraph(
|
|
151
|
-
expect(reported(paragraph(
|
|
150
|
+
it("an option moves the ceiling: 240 words fire under max 120, not under the default", () => {
|
|
151
|
+
expect(reported(paragraph(240), [{ max: 120 }])).toHaveLength(1);
|
|
152
|
+
expect(reported(paragraph(240))).toHaveLength(0);
|
|
152
153
|
});
|
|
153
154
|
});
|
|
154
155
|
|
|
155
156
|
/** What the numbers judge finds in `body` at the default ceiling. */
|
|
156
157
|
const numbersFound = (body: string) => {
|
|
157
158
|
const src = doc(body);
|
|
158
|
-
return judgeParagraphNumbers(
|
|
159
|
-
(
|
|
160
|
-
|
|
159
|
+
return judgeParagraphNumbers(
|
|
160
|
+
latexReader.bodyProse(src),
|
|
161
|
+
DEFAULT_MAX_PARAGRAPH_NUMBERS,
|
|
162
|
+
).map((f) => f.data);
|
|
161
163
|
};
|
|
162
164
|
|
|
163
165
|
describe("tex/max-paragraph-numbers", () => {
|
|
164
|
-
it("π΄
|
|
165
|
-
const
|
|
166
|
-
"We ran 1 and 2.5 and 30\\% and 4,000 and \\numA{} and \\numTotal and 7 and 8.";
|
|
167
|
-
expect(numbersFound(
|
|
168
|
-
expect(numbersFound(`${
|
|
169
|
-
{ numbers:
|
|
166
|
+
it("π΄ eleven numbers fire, ten stay quiet; citations and references are not numbers, a hand-typed place is", () => {
|
|
167
|
+
const ten =
|
|
168
|
+
"We ran 1 and 2.5 and 30\\% and 4,000 and \\numA{} and \\numTotal and 7 and 8 and 9 and 10.";
|
|
169
|
+
expect(numbersFound(ten)).toEqual([]);
|
|
170
|
+
expect(numbersFound(`${ten} Then 11.`)).toEqual([
|
|
171
|
+
{ numbers: 11, max: 10, head: "We ran 1 and 2.5 and 30% andβ¦" },
|
|
170
172
|
]);
|
|
171
173
|
// Guards: a citation key and a reference are not quantities.
|
|
172
|
-
expect(
|
|
173
|
-
|
|
174
|
-
)
|
|
174
|
+
expect(numbersFound(`${ten} See \\cite{k2024} and \\ref{sec:1}.`)).toEqual(
|
|
175
|
+
[],
|
|
176
|
+
);
|
|
175
177
|
// A place typed by hand is a number like any other; written with \\ref it is not.
|
|
176
|
-
expect(numbersFound(`${
|
|
177
|
-
{ numbers:
|
|
178
|
+
expect(numbersFound(`${ten} See Section 3.2.`)).toEqual([
|
|
179
|
+
{ numbers: 11, max: 10, head: "We ran 1 and 2.5 and 30% andβ¦" },
|
|
178
180
|
]);
|
|
179
|
-
expect(numbersFound(`${
|
|
181
|
+
expect(numbersFound(`${ten} See Section \\ref{sec:x}.`)).toEqual([]);
|
|
180
182
|
});
|
|
181
183
|
|
|
182
|
-
/**
|
|
183
|
-
const
|
|
184
|
+
/** Ten numbers a reader sees, none of them a `\numβ¦` macro. */
|
|
185
|
+
const TEN =
|
|
186
|
+
"We ran 1 and 2 and 3 and 4 and 5 and 6 and 7 and 8 and 9 and 10 times.";
|
|
184
187
|
|
|
185
|
-
it("π΄ a `\\numβ¦` macro in the paragraph's prose counts: the
|
|
186
|
-
expect(numbersFound(`${
|
|
187
|
-
{ numbers:
|
|
188
|
+
it("π΄ a `\\numβ¦` macro in the paragraph's prose counts: the eleventh fires", () => {
|
|
189
|
+
expect(numbersFound(`${TEN} Then \\numFoo{} more.`)).toEqual([
|
|
190
|
+
{ numbers: 11, max: 10, head: "We ran 1 and 2 and 3 andβ¦" },
|
|
188
191
|
]);
|
|
189
192
|
});
|
|
190
193
|
|
|
191
194
|
it("π΄ a `\\numβ¦` macro inside inline math is math, not prose: not counted", () => {
|
|
192
195
|
// Guards: the source between the paragraph's first and last piece holds the macro.
|
|
193
|
-
expect(numbersFound(`${
|
|
196
|
+
expect(numbersFound(`${TEN} Then $\\num{9}$ more.`)).toEqual([]);
|
|
194
197
|
});
|
|
195
198
|
|
|
196
199
|
it("π΄ a `\\numβ¦` macro on a commented-out line is not counted", () => {
|
|
197
200
|
// Guards: a comment changes nothing on the page, so it cannot add a number.
|
|
198
|
-
expect(numbersFound(`${
|
|
201
|
+
expect(numbersFound(`${TEN}\n% \\numFoo\nThen more.`)).toEqual([]);
|
|
199
202
|
});
|
|
200
203
|
|
|
201
204
|
it("π΄ a `\\numβ¦` macro in a footnote counts for the footnote, not for the paragraph it hangs from", () => {
|
|
202
205
|
// Guards: a footnote is a passage of its own; its numbers are its own.
|
|
203
206
|
expect(
|
|
204
|
-
numbersFound(`${
|
|
207
|
+
numbersFound(`${TEN}\\footnote{See \\numFoo{}.} Then more.`),
|
|
205
208
|
).toEqual([]);
|
|
206
209
|
});
|
|
207
210
|
});
|
|
@@ -291,7 +294,7 @@ describe("the new rules, through create()", () => {
|
|
|
291
294
|
const long = Array.from({ length: 60 }, () => "word").join(" ");
|
|
292
295
|
expect(run(maxSentenceWordsRule(deps), `${long}.`)).toHaveLength(1);
|
|
293
296
|
expect(
|
|
294
|
-
run(maxParagraphNumbersRule(deps), "1 2 3 4 5 6 7 8 9."),
|
|
297
|
+
run(maxParagraphNumbersRule(deps), "1 2 3 4 5 6 7 8 9 10 11."),
|
|
295
298
|
).toHaveLength(1);
|
|
296
299
|
expect(run(maxParagraphWordsRule(deps), "Short.")).toHaveLength(0);
|
|
297
300
|
});
|
package/src/readability.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THE PARAGRAPH CEILING β `tex/max-paragraph-words`, a rule of the `tex` plugin over the body's
|
|
3
|
-
* prose: a paragraph runs past `max` words (default
|
|
3
|
+
* prose: a paragraph runs past `max` words (default 250).
|
|
4
4
|
*
|
|
5
5
|
* ββ OFF BY DEFAULT βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
6
6
|
* No call for papers states a paragraph limit, so no venue is a source for the number. The rule is
|
|
7
7
|
* registered and silent until a project turns it on in its `rules`, as `tex/heading-case` is. The
|
|
8
8
|
* name and the `max` option follow ESLint's own `max-lines`, `max-len`, `max-statements`.
|
|
9
9
|
*
|
|
10
|
-
* ββ WHERE
|
|
11
|
-
* The
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* ββ WHERE 250 COMES FROM βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
+
* The 99th percentile of paragraph length over the accepted real papers in
|
|
12
|
+
* `fixtures/real-papers/accepted/` (96 papers with at least 2,500 body words, 7,994 paragraphs,
|
|
13
|
+
* measured with this rule's counter): p99 is 252, so 250 leaves about 1% of accepted paragraphs
|
|
14
|
+
* over it. The author chose it on 2026-11-20. It rests on what 99% of accepted paragraphs pass, not
|
|
15
|
+
* on reviewer evidence: a pilot on ICLR 2025 presentation scores found no link between long
|
|
16
|
+
* paragraphs and the score (inconclusive). The measurement is on the rule's page. A paragraph is
|
|
17
|
+
* at most `max` words; 250 is allowed.
|
|
15
18
|
*
|
|
16
19
|
* ββ WHAT IT READS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
17
20
|
* The body's prose through the `LatexReader` port (`bodyProse`): paragraphs, list items and
|
|
@@ -40,10 +43,10 @@ import {
|
|
|
40
43
|
} from "./tex-venue-rules.ts";
|
|
41
44
|
|
|
42
45
|
/** The ceiling when the config sets none: the largest paragraph that does not fire. */
|
|
43
|
-
export const DEFAULT_MAX_PARAGRAPH_WORDS =
|
|
46
|
+
export const DEFAULT_MAX_PARAGRAPH_WORDS = 250;
|
|
44
47
|
|
|
45
|
-
/** The numbers ceiling when the config sets none:
|
|
46
|
-
export const DEFAULT_MAX_PARAGRAPH_NUMBERS =
|
|
48
|
+
/** The numbers ceiling when the config sets none: an eleventh number fires. */
|
|
49
|
+
export const DEFAULT_MAX_PARAGRAPH_NUMBERS = 10;
|
|
47
50
|
|
|
48
51
|
/** The sentence ceiling when the config sets none: a 56th word fires. */
|
|
49
52
|
export const DEFAULT_MAX_SENTENCE_WORDS = 55;
|
package/src/rule-cases.test.ts
CHANGED
|
@@ -1373,21 +1373,21 @@ const CASES: Readonly<Record<string, RuleCases>> = {
|
|
|
1373
1373
|
// below): its cases turn it on in the paper's paperlint.json, as study/declare-sample's do.
|
|
1374
1374
|
"tex/max-paragraph-words": {
|
|
1375
1375
|
reports: {
|
|
1376
|
-
tree: paper(tex(wordsParagraph(
|
|
1376
|
+
tree: paper(tex(wordsParagraph(251)), MAX_PARAGRAPH_WORDS_ON),
|
|
1377
1377
|
file: TEX_FILE,
|
|
1378
1378
|
severity: 1,
|
|
1379
1379
|
line: 3,
|
|
1380
1380
|
},
|
|
1381
|
-
silent: paper(tex(wordsParagraph(
|
|
1381
|
+
silent: paper(tex(wordsParagraph(250)), MAX_PARAGRAPH_WORDS_ON),
|
|
1382
1382
|
},
|
|
1383
1383
|
"tex/max-paragraph-numbers": {
|
|
1384
1384
|
reports: {
|
|
1385
|
-
tree: paper(tex(numbersParagraph(
|
|
1385
|
+
tree: paper(tex(numbersParagraph(11)), CEILINGS_ON),
|
|
1386
1386
|
file: TEX_FILE,
|
|
1387
1387
|
severity: 1,
|
|
1388
1388
|
line: 3,
|
|
1389
1389
|
},
|
|
1390
|
-
silent: paper(tex(numbersParagraph(
|
|
1390
|
+
silent: paper(tex(numbersParagraph(10)), CEILINGS_ON),
|
|
1391
1391
|
},
|
|
1392
1392
|
"tex/max-sentence-words": {
|
|
1393
1393
|
reports: {
|
|
@@ -1842,10 +1842,10 @@ describe("tex/max-paragraph-words is off by default", () => {
|
|
|
1842
1842
|
});
|
|
1843
1843
|
|
|
1844
1844
|
describe("the other two ceilings are off by default", () => {
|
|
1845
|
-
it("
|
|
1845
|
+
it("eleven numbers and a 56-word sentence produce nothing under the default config", async () => {
|
|
1846
1846
|
const ids = async (tree: Record<string, string>) =>
|
|
1847
1847
|
(await lintTree(tree)).map((m) => m.ruleId);
|
|
1848
|
-
const body = `${numbersParagraph(
|
|
1848
|
+
const body = `${numbersParagraph(11)} ${longSentence(56)}`;
|
|
1849
1849
|
const off = await ids(paper(tex(body)));
|
|
1850
1850
|
expect(off).not.toContain("tex/max-paragraph-numbers");
|
|
1851
1851
|
expect(off).not.toContain("tex/max-sentence-words");
|