Skip to content

Latest commit

 

History

History
44 lines (27 loc) · 1.05 KB

File metadata and controls

44 lines (27 loc) · 1.05 KB

Linter Rule: Disallow Ruby comments immediately after ERB tags

Rule: erb-comment-syntax

Description

Disallow ERB tags that start with <% # (with a space before the #). Use the ERB comment syntax <%# instead.

Rationale

Ruby comments starting immediately after an ERB tag opening (e.g., <% # comment %>) can cause parsing issues in some contexts. The proper ERB comment syntax <%# comment %> is more reliable and explicitly designed for comments in templates.

For multi-line comments or actual Ruby code with comments, ensure the content starts on a new line after the opening tag.

Examples

✅ Good

<%# This is a proper ERB comment %>

<%
  # This is a proper ERB comment
%>

<%
  # Multi-line Ruby comment
  # spanning multiple lines
%>

🚫 Bad

<% # This should be an ERB comment %>

<%= # This should also be an ERB comment %>

<%== # This should also be an ERB comment %>

References