@d3lm/lint-preset 1.5.5 → 1.5.6
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 +3 -1
- package/dist/bin/comments.js +32 -11
- package/dist/bin/comments.js.map +1 -1
- package/dist/comments.cjs +30 -10
- 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 +30 -10
- package/dist/comments.js.map +1 -1
- package/package.json +1 -1
package/dist/comments.d.cts
CHANGED
|
@@ -75,7 +75,8 @@ interface ParagraphReport {
|
|
|
75
75
|
/**
|
|
76
76
|
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is
|
|
77
77
|
* greedily wrapped to the width, or `null` when the paragraph isn't prose, e.g. code,
|
|
78
|
-
* a table, a diagram, or `@example`.
|
|
78
|
+
* a table, a diagram, or `@example`. A paragraph that is accepted with the layout for a
|
|
79
|
+
* wider width within the tolerance keeps its lines.
|
|
79
80
|
*/
|
|
80
81
|
readonly suggestion: readonly string[] | null;
|
|
81
82
|
}
|
|
@@ -214,8 +215,9 @@ interface CommentsConfig {
|
|
|
214
215
|
readonly singleLineWidth?: number;
|
|
215
216
|
/**
|
|
216
217
|
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph of
|
|
217
|
-
* three or more lines.
|
|
218
|
-
*
|
|
218
|
+
* three or more lines. A paragraph that already has the layout for a wider `width`, up to `width`
|
|
219
|
+
* plus this many columns, also passes as it is. It never goes past `maxWidth`. When `maxWidth` is
|
|
220
|
+
* omitted, it also sets a legacy hard limit of `width + tolerance`.
|
|
219
221
|
*/
|
|
220
222
|
readonly tolerance?: number;
|
|
221
223
|
/**
|
package/dist/comments.d.ts
CHANGED
|
@@ -75,7 +75,8 @@ interface ParagraphReport {
|
|
|
75
75
|
/**
|
|
76
76
|
* Holds the exact source lines for `startLine` through `endLine` when the paragraph is
|
|
77
77
|
* greedily wrapped to the width, or `null` when the paragraph isn't prose, e.g. code,
|
|
78
|
-
* a table, a diagram, or `@example`.
|
|
78
|
+
* a table, a diagram, or `@example`. A paragraph that is accepted with the layout for a
|
|
79
|
+
* wider width within the tolerance keeps its lines.
|
|
79
80
|
*/
|
|
80
81
|
readonly suggestion: readonly string[] | null;
|
|
81
82
|
}
|
|
@@ -214,8 +215,9 @@ interface CommentsConfig {
|
|
|
214
215
|
readonly singleLineWidth?: number;
|
|
215
216
|
/**
|
|
216
217
|
* Sets how many columns prose lines may go past `width` when that saves a line in a paragraph of
|
|
217
|
-
* three or more lines.
|
|
218
|
-
*
|
|
218
|
+
* three or more lines. A paragraph that already has the layout for a wider `width`, up to `width`
|
|
219
|
+
* plus this many columns, also passes as it is. It never goes past `maxWidth`. When `maxWidth` is
|
|
220
|
+
* omitted, it also sets a legacy hard limit of `width + tolerance`.
|
|
219
221
|
*/
|
|
220
222
|
readonly tolerance?: number;
|
|
221
223
|
/**
|
package/dist/comments.js
CHANGED
|
@@ -1059,9 +1059,9 @@ function analyzeParagraph(paragraph, options) {
|
|
|
1059
1059
|
parentheticalOverflow: options.maxWidth === void 0 ? void 0 : options.maxWidth - options.width,
|
|
1060
1060
|
keepFirstLine: paragraph.kind === "tag"
|
|
1061
1061
|
};
|
|
1062
|
-
const layOut = (from, settings) => {
|
|
1063
|
-
const even2 = layoutTokens(from, firstLimit, restLimit, settings);
|
|
1064
|
-
return { even: even2, wrapped: breakAfterSentence(even2, firstLimit, restLimit, settings) };
|
|
1062
|
+
const layOut = (from, settings, extra) => {
|
|
1063
|
+
const even2 = layoutTokens(from, firstLimit + extra, restLimit + extra, settings);
|
|
1064
|
+
return { even: even2, wrapped: breakAfterSentence(even2, firstLimit + extra, restLimit + extra, settings) };
|
|
1065
1065
|
};
|
|
1066
1066
|
const units = bindLineStarts(paragraph.kind === "tag" ? bindTagHead(tokens) : tokens, startsLine);
|
|
1067
1067
|
const hardLimit = restLimit + (options.maxWidth === void 0 ? options.tolerance : options.maxWidth - options.width);
|
|
@@ -1078,9 +1078,9 @@ function analyzeParagraph(paragraph, options) {
|
|
|
1078
1078
|
return { ...first, text, verbatim: false, hardBreak: HARD_BREAK.test(text) };
|
|
1079
1079
|
});
|
|
1080
1080
|
};
|
|
1081
|
-
const settle = (settings) => {
|
|
1081
|
+
const settle = (settings, extra = 0) => {
|
|
1082
1082
|
let current = units;
|
|
1083
|
-
let { even: even2, wrapped: wrapped2 } = layOut(current, settings);
|
|
1083
|
+
let { even: even2, wrapped: wrapped2 } = layOut(current, settings, extra);
|
|
1084
1084
|
for (; ; ) {
|
|
1085
1085
|
const body = bodyOf(wrapped2);
|
|
1086
1086
|
const rewrap = structureOf(body);
|
|
@@ -1095,11 +1095,19 @@ function analyzeParagraph(paragraph, options) {
|
|
|
1095
1095
|
return { tier: "manual", reason: `rewrap would read as ${reading}` };
|
|
1096
1096
|
}
|
|
1097
1097
|
current = current.toSpliced(start - 1, 2, pair);
|
|
1098
|
-
({ even: even2, wrapped: wrapped2 } = layOut(current, settings));
|
|
1098
|
+
({ even: even2, wrapped: wrapped2 } = layOut(current, settings, extra));
|
|
1099
1099
|
}
|
|
1100
1100
|
};
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1101
|
+
const layoutAt = (extra) => {
|
|
1102
|
+
const settings = {
|
|
1103
|
+
...layoutOptions,
|
|
1104
|
+
tolerance: layoutOptions.tolerance - extra,
|
|
1105
|
+
parentheticalOverflow: layoutOptions.parentheticalOverflow === void 0 ? void 0 : layoutOptions.parentheticalOverflow - extra
|
|
1106
|
+
};
|
|
1107
|
+
const settled = settle(settings, extra);
|
|
1108
|
+
return "wrapped" in settled ? settled : settle({ ...settings, keepSteps: true }, extra);
|
|
1109
|
+
};
|
|
1110
|
+
const layout = layoutAt(0);
|
|
1103
1111
|
if (!("wrapped" in layout)) {
|
|
1104
1112
|
return keep(layout);
|
|
1105
1113
|
}
|
|
@@ -1164,10 +1172,22 @@ function analyzeParagraph(paragraph, options) {
|
|
|
1164
1172
|
}
|
|
1165
1173
|
}
|
|
1166
1174
|
}
|
|
1167
|
-
const
|
|
1175
|
+
const isVerdict = (issue) => ISSUE_TIERS[issue.type] === "verdict";
|
|
1176
|
+
const matchesWiderLayout = () => {
|
|
1177
|
+
for (let extra = 1; extra <= layoutOptions.tolerance; extra += 1) {
|
|
1178
|
+
const wider = layoutAt(extra);
|
|
1179
|
+
if ("wrapped" in wider && sameLayout(wider.wrapped, currentLines)) {
|
|
1180
|
+
return true;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
return false;
|
|
1184
|
+
};
|
|
1185
|
+
const accepted = lineIssues.some((issue) => isVerdict(issue)) && matchesWiderLayout();
|
|
1186
|
+
const suggested = accepted ? currentLines : wrapped;
|
|
1187
|
+
const suggestion = suggested.map(
|
|
1168
1188
|
(words, position) => `${prefix}${position === 0 ? paragraph.marker : hang}${words.join(" ")}`
|
|
1169
1189
|
);
|
|
1170
|
-
const wrapIssues = lineIssues.map((issue) => lineIssue(issue.type, paragraph.lines[issue.line], options));
|
|
1190
|
+
const wrapIssues = lineIssues.filter((issue) => !accepted || !isVerdict(issue)).map((issue) => lineIssue(issue.type, paragraph.lines[issue.line], options));
|
|
1171
1191
|
const issues = byLine([...overflow, ...wrapIssues, ...styleIssues(paragraph, options)]);
|
|
1172
1192
|
return { ...base, reflowable: true, issues, suggestion };
|
|
1173
1193
|
}
|