@d3lm/lint-preset 1.6.1 → 1.6.2
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/README.md +1 -1
- package/dist/bin/comments.js +7 -6
- package/dist/bin/comments.js.map +1 -1
- package/dist/{chunk-SMTCD6GW.js → chunk-3H72UCKF.js} +1 -1
- package/dist/{chunk-SMTCD6GW.js.map → chunk-3H72UCKF.js.map} +1 -1
- package/dist/{chunk-M3BAUCCR.cjs → chunk-HEEMZMIV.cjs} +1 -1
- package/dist/{chunk-M3BAUCCR.cjs.map → chunk-HEEMZMIV.cjs.map} +1 -1
- package/dist/comments.cjs +5 -4
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.d.cts +17 -15
- package/dist/comments.d.ts +17 -15
- package/dist/comments.js +5 -4
- package/dist/comments.js.map +1 -1
- package/dist/eslint.cjs +9 -9
- package/dist/eslint.js +1 -1
- package/dist/oxlint.cjs +5 -5
- package/dist/oxlint.cjs.map +1 -1
- package/dist/oxlint.js +1 -1
- package/dist/oxlint.js.map +1 -1
- package/package.json +1 -1
package/dist/comments.d.cts
CHANGED
|
@@ -2,11 +2,12 @@ type StyleIssueType = 'semicolon' | 'em-dash' | 'dash' | 'label-colon' | 'emphas
|
|
|
2
2
|
|
|
3
3
|
interface WrapOptions {
|
|
4
4
|
/**
|
|
5
|
-
* Sets whether a line may not end with the first word of a sentence
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the first
|
|
9
|
-
* the
|
|
5
|
+
* Sets whether a line may not end with the first word of a sentence or parenthetical, like
|
|
6
|
+
* `This` or `(the`, or with the first word after a semicolon or colon. Such a word moves to
|
|
7
|
+
* the next line instead. The word after a comma may end a line. It also sets whether a line
|
|
8
|
+
* avoids ending with the first two words of a sentence, and whether the first of two lines
|
|
9
|
+
* ends with a sentence instead of the start of the next one, as long as the second line is
|
|
10
|
+
* then no longer than the first.
|
|
10
11
|
*/
|
|
11
12
|
readonly avoidSentenceOrphans: boolean;
|
|
12
13
|
/**
|
|
@@ -54,9 +55,9 @@ interface AnalyzeOptions extends WrapOptions {
|
|
|
54
55
|
*/
|
|
55
56
|
readonly maxWidth?: number;
|
|
56
57
|
/**
|
|
57
|
-
* Sets the maximum length of the line that holds a comment whose whole text is one
|
|
58
|
-
*
|
|
59
|
-
*
|
|
58
|
+
* Sets the maximum length of the line that holds a comment whose whole text is one prose
|
|
59
|
+
* paragraph. Such a comment stays on one line up to this length plus `tolerance`, even past
|
|
60
|
+
* `width`, but never past `maxWidth`. It defaults to `width`.
|
|
60
61
|
*/
|
|
61
62
|
readonly singleLineWidth?: number;
|
|
62
63
|
readonly tabWidth: number;
|
|
@@ -228,7 +229,7 @@ interface CommentsConfig {
|
|
|
228
229
|
* Sets the maximum length of the line that holds a comment whose whole text is one prose
|
|
229
230
|
* paragraph. Such a comment stays on one line up to this length plus `tolerance`, even past
|
|
230
231
|
* `width`, and is wrapped to `width` beyond it. Defaults to 120, and the line never exceeds
|
|
231
|
-
* `maxWidth
|
|
232
|
+
* the `maxWidth` limit.
|
|
232
233
|
*/
|
|
233
234
|
readonly singleLineWidth?: number;
|
|
234
235
|
/**
|
|
@@ -242,12 +243,13 @@ interface CommentsConfig {
|
|
|
242
243
|
readonly tolerance?: number;
|
|
243
244
|
/**
|
|
244
245
|
* Keep the first word of a new sentence or parenthetical off the end of a line, e.g.
|
|
245
|
-
* `...the module. This` or `...reflows (the` followed by the rest on the next line.
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* the
|
|
249
|
-
*
|
|
250
|
-
*
|
|
246
|
+
* `...the module. This` or `...reflows (the` followed by the rest on the next line. The same
|
|
247
|
+
* goes for the first word after a semicolon or colon, but not after a comma, so a line may
|
|
248
|
+
* end with `...the paths, and`. A paragraph of two lines also ends its first line with a
|
|
249
|
+
* sentence when the rest fits on the second line and is no longer than the first, instead
|
|
250
|
+
* of with the start of the next sentence, like `...the module. This one`. Other lines avoid
|
|
251
|
+
* ending with the first two words of a sentence, like `...opens. It allocates`, unless that
|
|
252
|
+
* makes them much less even. Defaults to `true`.
|
|
251
253
|
*/
|
|
252
254
|
readonly avoidSentenceOrphans?: boolean;
|
|
253
255
|
/**
|
package/dist/comments.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ type StyleIssueType = 'semicolon' | 'em-dash' | 'dash' | 'label-colon' | 'emphas
|
|
|
2
2
|
|
|
3
3
|
interface WrapOptions {
|
|
4
4
|
/**
|
|
5
|
-
* Sets whether a line may not end with the first word of a sentence
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the first
|
|
9
|
-
* the
|
|
5
|
+
* Sets whether a line may not end with the first word of a sentence or parenthetical, like
|
|
6
|
+
* `This` or `(the`, or with the first word after a semicolon or colon. Such a word moves to
|
|
7
|
+
* the next line instead. The word after a comma may end a line. It also sets whether a line
|
|
8
|
+
* avoids ending with the first two words of a sentence, and whether the first of two lines
|
|
9
|
+
* ends with a sentence instead of the start of the next one, as long as the second line is
|
|
10
|
+
* then no longer than the first.
|
|
10
11
|
*/
|
|
11
12
|
readonly avoidSentenceOrphans: boolean;
|
|
12
13
|
/**
|
|
@@ -54,9 +55,9 @@ interface AnalyzeOptions extends WrapOptions {
|
|
|
54
55
|
*/
|
|
55
56
|
readonly maxWidth?: number;
|
|
56
57
|
/**
|
|
57
|
-
* Sets the maximum length of the line that holds a comment whose whole text is one
|
|
58
|
-
*
|
|
59
|
-
*
|
|
58
|
+
* Sets the maximum length of the line that holds a comment whose whole text is one prose
|
|
59
|
+
* paragraph. Such a comment stays on one line up to this length plus `tolerance`, even past
|
|
60
|
+
* `width`, but never past `maxWidth`. It defaults to `width`.
|
|
60
61
|
*/
|
|
61
62
|
readonly singleLineWidth?: number;
|
|
62
63
|
readonly tabWidth: number;
|
|
@@ -228,7 +229,7 @@ interface CommentsConfig {
|
|
|
228
229
|
* Sets the maximum length of the line that holds a comment whose whole text is one prose
|
|
229
230
|
* paragraph. Such a comment stays on one line up to this length plus `tolerance`, even past
|
|
230
231
|
* `width`, and is wrapped to `width` beyond it. Defaults to 120, and the line never exceeds
|
|
231
|
-
* `maxWidth
|
|
232
|
+
* the `maxWidth` limit.
|
|
232
233
|
*/
|
|
233
234
|
readonly singleLineWidth?: number;
|
|
234
235
|
/**
|
|
@@ -242,12 +243,13 @@ interface CommentsConfig {
|
|
|
242
243
|
readonly tolerance?: number;
|
|
243
244
|
/**
|
|
244
245
|
* Keep the first word of a new sentence or parenthetical off the end of a line, e.g.
|
|
245
|
-
* `...the module. This` or `...reflows (the` followed by the rest on the next line.
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* the
|
|
249
|
-
*
|
|
250
|
-
*
|
|
246
|
+
* `...the module. This` or `...reflows (the` followed by the rest on the next line. The same
|
|
247
|
+
* goes for the first word after a semicolon or colon, but not after a comma, so a line may
|
|
248
|
+
* end with `...the paths, and`. A paragraph of two lines also ends its first line with a
|
|
249
|
+
* sentence when the rest fits on the second line and is no longer than the first, instead
|
|
250
|
+
* of with the start of the next sentence, like `...the module. This one`. Other lines avoid
|
|
251
|
+
* ending with the first two words of a sentence, like `...opens. It allocates`, unless that
|
|
252
|
+
* makes them much less even. Defaults to `true`.
|
|
251
253
|
*/
|
|
252
254
|
readonly avoidSentenceOrphans?: boolean;
|
|
253
255
|
/**
|
package/dist/comments.js
CHANGED
|
@@ -128,6 +128,7 @@ function findStyleIssues(lines) {
|
|
|
128
128
|
// src/comments/wrap.ts
|
|
129
129
|
var CLAUSE_END = /[.!?,;:]["')\]*_]*$/;
|
|
130
130
|
var SENTENCE_END = /[.!?]["')\]*_]*$/;
|
|
131
|
+
var STATEMENT_END = /[.!?;:]["')\]*_]*$/;
|
|
131
132
|
var ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
132
133
|
"e.g.",
|
|
133
134
|
"i.e.",
|
|
@@ -359,8 +360,8 @@ function bindParentheticals(tokens, limit) {
|
|
|
359
360
|
}
|
|
360
361
|
return units;
|
|
361
362
|
}
|
|
362
|
-
function
|
|
363
|
-
return
|
|
363
|
+
function endsStatement(token) {
|
|
364
|
+
return STATEMENT_END.test(token) && !isAbbreviation(token);
|
|
364
365
|
}
|
|
365
366
|
function endsSentence(token) {
|
|
366
367
|
return SENTENCE_END.test(token) && !isAbbreviation(token);
|
|
@@ -369,7 +370,7 @@ function opensAside(token) {
|
|
|
369
370
|
return /^[([]/.test(token) && !/[)\]]["'`.,;:!?]*$/.test(token);
|
|
370
371
|
}
|
|
371
372
|
function isOrphan(previous, token) {
|
|
372
|
-
return opensAside(token) ||
|
|
373
|
+
return opensAside(token) || endsStatement(previous) && !CLAUSE_END.test(token);
|
|
373
374
|
}
|
|
374
375
|
function startsBlock(token) {
|
|
375
376
|
return /^(?:\+|-+|=+|\*+|_{3,}|\d+[.)]|#{1,6})$/.test(token) || /^(?:>|@[A-Za-z]|`{3}|~{3}|\||<(?:\/?[A-Za-z]|[!?]))/.test(token);
|
|
@@ -1743,7 +1744,7 @@ When rules pull in different directions, the earlier one wins.
|
|
|
1743
1744
|
## Layout
|
|
1744
1745
|
|
|
1745
1746
|
- After you finish, the tool rewraps prose paragraphs, list items, and JSDoc tag descriptions. The width is a preferred target. A parenthetical may extend a line up to the configured maximum so it stays together, and lines may go up to the configured tolerance past the width when that saves a line. In longer paragraphs, balanced lines take priority over keeping every parenthetical on one line. The tool also avoids short last lines where possible. Leave these line breaks to the tool, except for the sentence-orphan case below.
|
|
1746
|
-
- Don't end a line with the first word of a new sentence
|
|
1747
|
+
- Don't end a line with the first word of a new sentence or parenthetical, like \`This\` after a period or \`(the\`, or with the first word after a semicolon or colon. Move it to the next line instead. The same goes for the first two words of a sentence, like \`It allocates\` after a period, when the note points at them. A long word, like an identifier or a code span, may stay at the end of a line when moving it would leave that line far shorter than the lines around it. Then leave the line breaks as they are. The word after a comma is no such word. A line may end with it, like \`and\` in \`...the teardown paths, and\`.
|
|
1747
1748
|
- In a paragraph of two lines, the first line ends with a sentence whenever the rest fits on the second line and is no longer than the first. Don't end it with the start of the next sentence, like \`A wrap\` in \`...lay out differently. A wrap\`. Move those words to the second line instead.
|
|
1748
1749
|
- A comment whose whole text is one paragraph stays on a single line when that line fits a separate, larger single-line width, even past the width. Only a longer comment wraps to the width.
|
|
1749
1750
|
- Separate paragraphs with an empty comment line.
|