@d3lm/lint-preset 1.5.1 → 1.5.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 +4 -2
- package/dist/bin/comments.js +25 -24
- package/dist/bin/comments.js.map +1 -1
- package/dist/comments.cjs +14 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.d.cts +5 -3
- package/dist/comments.d.ts +5 -3
- package/dist/comments.js +14 -1
- package/dist/comments.js.map +1 -1
- package/package.json +1 -1
package/dist/comments.d.cts
CHANGED
|
@@ -9,7 +9,8 @@ interface WrapOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
readonly avoidSentenceOrphans: boolean;
|
|
11
11
|
/**
|
|
12
|
-
* Sets how many columns a line may exceed its limit before it counts as overflowing.
|
|
12
|
+
* Sets how many columns a line may exceed its limit before it counts as overflowing. A layout
|
|
13
|
+
* also uses them when that saves a line.
|
|
13
14
|
*/
|
|
14
15
|
readonly tolerance: number;
|
|
15
16
|
/**
|
|
@@ -210,8 +211,9 @@ interface CommentsConfig {
|
|
|
210
211
|
*/
|
|
211
212
|
readonly singleLineWidth?: number;
|
|
212
213
|
/**
|
|
213
|
-
* Sets
|
|
214
|
-
*
|
|
214
|
+
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph of
|
|
215
|
+
* three or more lines. It never goes past `maxWidth`. When `maxWidth` is omitted, it also sets a
|
|
216
|
+
* legacy hard limit of `width + tolerance`.
|
|
215
217
|
*/
|
|
216
218
|
readonly tolerance?: number;
|
|
217
219
|
/**
|
package/dist/comments.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ interface WrapOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
readonly avoidSentenceOrphans: boolean;
|
|
11
11
|
/**
|
|
12
|
-
* Sets how many columns a line may exceed its limit before it counts as overflowing.
|
|
12
|
+
* Sets how many columns a line may exceed its limit before it counts as overflowing. A layout
|
|
13
|
+
* also uses them when that saves a line.
|
|
13
14
|
*/
|
|
14
15
|
readonly tolerance: number;
|
|
15
16
|
/**
|
|
@@ -210,8 +211,9 @@ interface CommentsConfig {
|
|
|
210
211
|
*/
|
|
211
212
|
readonly singleLineWidth?: number;
|
|
212
213
|
/**
|
|
213
|
-
* Sets
|
|
214
|
-
*
|
|
214
|
+
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph of
|
|
215
|
+
* three or more lines. It never goes past `maxWidth`. When `maxWidth` is omitted, it also sets a
|
|
216
|
+
* legacy hard limit of `width + tolerance`.
|
|
215
217
|
*/
|
|
216
218
|
readonly tolerance?: number;
|
|
217
219
|
/**
|
package/dist/comments.js
CHANGED
|
@@ -535,6 +535,19 @@ function layoutLines(tokens, firstLimit, restLimit, options) {
|
|
|
535
535
|
return lines;
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
|
+
if (options.tolerance > 0 && greedy.length > 2) {
|
|
539
|
+
const fewer = balanceTokens(
|
|
540
|
+
tokens,
|
|
541
|
+
firstLimit + options.tolerance,
|
|
542
|
+
restLimit + options.tolerance,
|
|
543
|
+
greedy.length - 1,
|
|
544
|
+
options,
|
|
545
|
+
restLimit
|
|
546
|
+
);
|
|
547
|
+
if (fewer && !hasStep(fewer, restLimit - firstLimit)) {
|
|
548
|
+
return fewer;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
538
551
|
const balanced = balanceTokens(tokens, firstLimit, restLimit, greedy.length, options);
|
|
539
552
|
if (balanced) {
|
|
540
553
|
return balanced;
|
|
@@ -1282,7 +1295,7 @@ When rules pull in different directions, the earlier one wins.
|
|
|
1282
1295
|
|
|
1283
1296
|
## Layout
|
|
1284
1297
|
|
|
1285
|
-
- 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. 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.
|
|
1298
|
+
- 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.
|
|
1286
1299
|
- Don't end a line with the first word of a new sentence, clause, or parenthetical, like \`This\` after a period, \`the\` after a comma, or \`(the\`. Move it to the next line instead.
|
|
1287
1300
|
- 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.
|
|
1288
1301
|
- 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.
|