@d3lm/lint-preset 1.6.0 → 1.6.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.
- package/README.md +14 -20
- package/dist/bin/comments.js +14 -1
- 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 +10 -8
- package/dist/comments.d.ts +10 -8
- package/dist/comments.js +14 -1
- package/dist/comments.js.map +1 -1
- package/package.json +1 -1
package/dist/comments.d.cts
CHANGED
|
@@ -84,10 +84,10 @@ interface ParagraphReport {
|
|
|
84
84
|
readonly reason?: string;
|
|
85
85
|
readonly issues: readonly IssueReport[];
|
|
86
86
|
/**
|
|
87
|
-
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
87
|
+
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is greedily
|
|
88
|
+
* wrapped to the width, or `null` when the paragraph isn't prose, e.g. code, a table, a diagram,
|
|
89
|
+
* or `@example`. A paragraph that the tolerance accepts as it is, with the layout for a wider
|
|
90
|
+
* width or with lines close to this one, keeps its lines.
|
|
91
91
|
*/
|
|
92
92
|
readonly suggestion: readonly string[] | null;
|
|
93
93
|
}
|
|
@@ -232,10 +232,12 @@ interface CommentsConfig {
|
|
|
232
232
|
*/
|
|
233
233
|
readonly singleLineWidth?: number;
|
|
234
234
|
/**
|
|
235
|
-
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph
|
|
236
|
-
* three or more lines. A paragraph that already has the layout for a wider `width`, up to
|
|
237
|
-
* plus this many columns, also passes as it is.
|
|
238
|
-
*
|
|
235
|
+
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph
|
|
236
|
+
* of three or more lines. A paragraph that already has the layout for a wider `width`, up to
|
|
237
|
+
* `width` plus this many columns, also passes as it is. So does a paragraph with as many lines
|
|
238
|
+
* as the rewrap whose lines are each at most this many columns shorter or longer than in the
|
|
239
|
+
* rewrap. It never goes past `maxWidth`. When `maxWidth` is omitted, it also sets a legacy hard
|
|
240
|
+
* limit of `width + tolerance`.
|
|
239
241
|
*/
|
|
240
242
|
readonly tolerance?: number;
|
|
241
243
|
/**
|
package/dist/comments.d.ts
CHANGED
|
@@ -84,10 +84,10 @@ interface ParagraphReport {
|
|
|
84
84
|
readonly reason?: string;
|
|
85
85
|
readonly issues: readonly IssueReport[];
|
|
86
86
|
/**
|
|
87
|
-
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
87
|
+
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is greedily
|
|
88
|
+
* wrapped to the width, or `null` when the paragraph isn't prose, e.g. code, a table, a diagram,
|
|
89
|
+
* or `@example`. A paragraph that the tolerance accepts as it is, with the layout for a wider
|
|
90
|
+
* width or with lines close to this one, keeps its lines.
|
|
91
91
|
*/
|
|
92
92
|
readonly suggestion: readonly string[] | null;
|
|
93
93
|
}
|
|
@@ -232,10 +232,12 @@ interface CommentsConfig {
|
|
|
232
232
|
*/
|
|
233
233
|
readonly singleLineWidth?: number;
|
|
234
234
|
/**
|
|
235
|
-
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph
|
|
236
|
-
* three or more lines. A paragraph that already has the layout for a wider `width`, up to
|
|
237
|
-
* plus this many columns, also passes as it is.
|
|
238
|
-
*
|
|
235
|
+
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph
|
|
236
|
+
* of three or more lines. A paragraph that already has the layout for a wider `width`, up to
|
|
237
|
+
* `width` plus this many columns, also passes as it is. So does a paragraph with as many lines
|
|
238
|
+
* as the rewrap whose lines are each at most this many columns shorter or longer than in the
|
|
239
|
+
* rewrap. It never goes past `maxWidth`. When `maxWidth` is omitted, it also sets a legacy hard
|
|
240
|
+
* limit of `width + tolerance`.
|
|
239
241
|
*/
|
|
240
242
|
readonly tolerance?: number;
|
|
241
243
|
/**
|
package/dist/comments.js
CHANGED
|
@@ -1383,7 +1383,20 @@ function analyzeParagraph(paragraph, options, language) {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
return false;
|
|
1385
1385
|
};
|
|
1386
|
-
const
|
|
1386
|
+
const staysNearLayout = () => {
|
|
1387
|
+
if (currentLines.length !== wrapped.length || splitTokenLine(currentLines, units) !== -1) {
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1390
|
+
return currentLines.every((words, position) => {
|
|
1391
|
+
const length = words.join(" ").length;
|
|
1392
|
+
const suggestedLength = wrapped[position].join(" ").length;
|
|
1393
|
+
const limit = (position === 0 ? firstLimit : restLimit) + layoutOptions.tolerance;
|
|
1394
|
+
return Math.abs(length - suggestedLength) <= layoutOptions.tolerance && length <= Math.max(suggestedLength, limit);
|
|
1395
|
+
});
|
|
1396
|
+
};
|
|
1397
|
+
const hasVerdict = lineIssues.some((issue) => isVerdict(issue));
|
|
1398
|
+
const onlyUnbalanced = lineIssues.every((issue) => issue.type === "unbalanced");
|
|
1399
|
+
const accepted = hasVerdict && (matchesWiderLayout() || onlyUnbalanced && staysNearLayout());
|
|
1387
1400
|
const suggested = accepted ? currentLines : wrapped;
|
|
1388
1401
|
const suggestion = suggested.map(
|
|
1389
1402
|
(words, position) => `${prefix}${position === 0 ? paragraph.marker : hang}${words.join(" ")}`
|