@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/dist/comments.cjs CHANGED
@@ -1061,9 +1061,9 @@ function analyzeParagraph(paragraph, options) {
1061
1061
  parentheticalOverflow: options.maxWidth === void 0 ? void 0 : options.maxWidth - options.width,
1062
1062
  keepFirstLine: paragraph.kind === "tag"
1063
1063
  };
1064
- const layOut = (from, settings) => {
1065
- const even2 = layoutTokens(from, firstLimit, restLimit, settings);
1066
- return { even: even2, wrapped: breakAfterSentence(even2, firstLimit, restLimit, settings) };
1064
+ const layOut = (from, settings, extra) => {
1065
+ const even2 = layoutTokens(from, firstLimit + extra, restLimit + extra, settings);
1066
+ return { even: even2, wrapped: breakAfterSentence(even2, firstLimit + extra, restLimit + extra, settings) };
1067
1067
  };
1068
1068
  const units = bindLineStarts(paragraph.kind === "tag" ? bindTagHead(tokens) : tokens, startsLine);
1069
1069
  const hardLimit = restLimit + (options.maxWidth === void 0 ? options.tolerance : options.maxWidth - options.width);
@@ -1080,9 +1080,9 @@ function analyzeParagraph(paragraph, options) {
1080
1080
  return { ...first, text, verbatim: false, hardBreak: HARD_BREAK.test(text) };
1081
1081
  });
1082
1082
  };
1083
- const settle = (settings) => {
1083
+ const settle = (settings, extra = 0) => {
1084
1084
  let current = units;
1085
- let { even: even2, wrapped: wrapped2 } = layOut(current, settings);
1085
+ let { even: even2, wrapped: wrapped2 } = layOut(current, settings, extra);
1086
1086
  for (; ; ) {
1087
1087
  const body = bodyOf(wrapped2);
1088
1088
  const rewrap = structureOf(body);
@@ -1097,11 +1097,19 @@ function analyzeParagraph(paragraph, options) {
1097
1097
  return { tier: "manual", reason: `rewrap would read as ${reading}` };
1098
1098
  }
1099
1099
  current = current.toSpliced(start - 1, 2, pair);
1100
- ({ even: even2, wrapped: wrapped2 } = layOut(current, settings));
1100
+ ({ even: even2, wrapped: wrapped2 } = layOut(current, settings, extra));
1101
1101
  }
1102
1102
  };
1103
- const settled = settle(layoutOptions);
1104
- const layout = "wrapped" in settled ? settled : settle({ ...layoutOptions, keepSteps: true });
1103
+ const layoutAt = (extra) => {
1104
+ const settings = {
1105
+ ...layoutOptions,
1106
+ tolerance: layoutOptions.tolerance - extra,
1107
+ parentheticalOverflow: layoutOptions.parentheticalOverflow === void 0 ? void 0 : layoutOptions.parentheticalOverflow - extra
1108
+ };
1109
+ const settled = settle(settings, extra);
1110
+ return "wrapped" in settled ? settled : settle({ ...settings, keepSteps: true }, extra);
1111
+ };
1112
+ const layout = layoutAt(0);
1105
1113
  if (!("wrapped" in layout)) {
1106
1114
  return keep(layout);
1107
1115
  }
@@ -1166,10 +1174,22 @@ function analyzeParagraph(paragraph, options) {
1166
1174
  }
1167
1175
  }
1168
1176
  }
1169
- const suggestion = wrapped.map(
1177
+ const isVerdict = (issue) => ISSUE_TIERS[issue.type] === "verdict";
1178
+ const matchesWiderLayout = () => {
1179
+ for (let extra = 1; extra <= layoutOptions.tolerance; extra += 1) {
1180
+ const wider = layoutAt(extra);
1181
+ if ("wrapped" in wider && sameLayout(wider.wrapped, currentLines)) {
1182
+ return true;
1183
+ }
1184
+ }
1185
+ return false;
1186
+ };
1187
+ const accepted = lineIssues.some((issue) => isVerdict(issue)) && matchesWiderLayout();
1188
+ const suggested = accepted ? currentLines : wrapped;
1189
+ const suggestion = suggested.map(
1170
1190
  (words, position) => `${prefix}${position === 0 ? paragraph.marker : hang}${words.join(" ")}`
1171
1191
  );
1172
- const wrapIssues = lineIssues.map((issue) => lineIssue(issue.type, paragraph.lines[issue.line], options));
1192
+ const wrapIssues = lineIssues.filter((issue) => !accepted || !isVerdict(issue)).map((issue) => lineIssue(issue.type, paragraph.lines[issue.line], options));
1173
1193
  const issues = byLine([...overflow, ...wrapIssues, ...styleIssues(paragraph, options)]);
1174
1194
  return { ...base, reflowable: true, issues, suggestion };
1175
1195
  }