Skip to content

Linter: Implement erb-no-conditional-html-element rule#1150

Merged
marcoroth merged 1 commit intomainfrom
erb-no-conditional-html-element
Feb 13, 2026
Merged

Linter: Implement erb-no-conditional-html-element rule#1150
marcoroth merged 1 commit intomainfrom
erb-no-conditional-html-element

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Feb 12, 2026

This pull request adds a new linter rule erb-no-conditional-html-element which disallows the use of HTMLConditionalElementNode in templates.

The following snippet:

<% if @with_icon %>
  <div class="icon">
<% end %>

  <span>Content</span>

<% if @with_icon %>
  </div>
<% end %>

Now fails with:

Avoid opening and closing `<div>` tags in separate conditional blocks with the same condition. This pattern is difficult to read and maintain. Consider using a `capture` block instead: <% content = capture do %> ... your content here ... <% end %> <%= @with_icon ? content_tag(:div, content) : content %>

This is a follow up on #1146 as it introduced the new HTMLConditionalElementNode.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 12, 2026

npx https://pkg.pr.new/@herb-tools/formatter@1150
npx https://pkg.pr.new/@herb-tools/language-server@1150
npx https://pkg.pr.new/@herb-tools/linter@1150

commit: f8765a5

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit f8765a5


✅ Preview deployment has been cleaned up.

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.

1 participant