Skip to content

Formatter: Respect maxLineLength for inline elements with ERB#889

Merged
marcoroth merged 1 commit into
mainfrom
formatter-inline-formatting
Nov 16, 2025
Merged

Formatter: Respect maxLineLength for inline elements with ERB#889
marcoroth merged 1 commit into
mainfrom
formatter-inline-formatting

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

Previously, inline elements containing ERB control flow could exceed the configured maxLineLength due to:

  1. A hardcoded 120-character limit that bypassed maxLineLength setting
  2. No detection of whether child elements could be rendered inline

This pull request fixes these issues and adds recursive inline detection.

Input

<div>
  <span>
    <% [10, 20, 30, 50, 100].each do |per| %>
      <%= link_to_unless per_page == per, per.to_s, params.merge({ action:, page: 1, per:, remote: }) %>
    <% end %>
  </span>
</div>

Before

<div><span><% [10, 20, 30, 50, 100].each do |per| %><%= link_to_unless per_page == per, per.to_s, params.merge({ action:, page: 1, per:, remote: }) %><% end %></span></div>

After

<div>
  <span>
    <% [10, 20, 30, 50, 100].each do |per| %>
      <%= link_to_unless per_page == per, per.to_s, params.merge({ action:, page: 1, per:, remote: }) %>
    <% end %>
  </span>
</div>

Resolves #882

@pkg-pr-new

pkg-pr-new Bot commented Nov 16, 2025

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@889
npx https://pkg.pr.new/@herb-tools/language-server@889
npx https://pkg.pr.new/@herb-tools/linter@889

commit: 6a5b749

@marcoroth marcoroth merged commit 47f7acc into main Nov 16, 2025
18 checks passed
@marcoroth marcoroth deleted the formatter-inline-formatting branch November 16, 2025 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatter: tags under div > span are combined into a single line

1 participant