@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/dist/comments.cjs CHANGED
@@ -1387,7 +1387,20 @@ function analyzeParagraph(paragraph, options, language) {
1387
1387
  }
1388
1388
  return false;
1389
1389
  };
1390
- const accepted = lineIssues.some((issue) => isVerdict(issue)) && matchesWiderLayout();
1390
+ const staysNearLayout = () => {
1391
+ if (currentLines.length !== wrapped.length || splitTokenLine(currentLines, units) !== -1) {
1392
+ return false;
1393
+ }
1394
+ return currentLines.every((words, position) => {
1395
+ const length = words.join(" ").length;
1396
+ const suggestedLength = wrapped[position].join(" ").length;
1397
+ const limit = (position === 0 ? firstLimit : restLimit) + layoutOptions.tolerance;
1398
+ return Math.abs(length - suggestedLength) <= layoutOptions.tolerance && length <= Math.max(suggestedLength, limit);
1399
+ });
1400
+ };
1401
+ const hasVerdict = lineIssues.some((issue) => isVerdict(issue));
1402
+ const onlyUnbalanced = lineIssues.every((issue) => issue.type === "unbalanced");
1403
+ const accepted = hasVerdict && (matchesWiderLayout() || onlyUnbalanced && staysNearLayout());
1391
1404
  const suggested = accepted ? currentLines : wrapped;
1392
1405
  const suggestion = suggested.map(
1393
1406
  (words, position) => `${prefix}${position === 0 ? paragraph.marker : hang}${words.join(" ")}`