Skip to content

Add ERB Lint to lint templates (RuboCop only covers .rb)#1988

Open
maebeale wants to merge 6 commits into
mainfrom
maebeale/erb-lint
Open

Add ERB Lint to lint templates (RuboCop only covers .rb)#1988
maebeale wants to merge 6 commits into
mainfrom
maebeale/erb-lint

Conversation

@maebeale

@maebeale maebeale commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

🤖 suggested review level: 3 Read 📖 new lint tooling + a large but purely mechanical autocorrect sweep — review the config/CI, skim the sweep

Why

RuboCop only parses .rb, so nothing checked the Ruby inside <% %> tags or the ERB/HTML conventions documented in CLAUDE.md — they were written down but unenforced. This adds an actual ERB linter.

What

  • erb_lint gem + .erb_lint.yml — conservative, fully-autocorrectable ruleset:
    • Mechanical HTML/ERB formatting (tag spacing, trailing whitespace, indentation, final newline).
    • An omakase-matching RuboCop subset applied to Ruby inside tags, one cop per documented CLAUDE.md rule: double quotes, hash syntax, brace/bracket/block-brace/paren/reference spacing, no trailing commas, no redundant .to_s, no semicolons. EnforcedStyle is pinned to omakase's values (several cops default to no_space in bare RuboCop).
    • Deliberately omits indentation/end-alignment cops — RuboCop extracts Ruby without its HTML indent context and can't see across split tags, so they misfire in ERB.
  • Wired into ai/lint (runs alongside RuboCop; --fix autocorrects both) and CI (new step in the RuboCop workflow).
  • Autocorrect sweep across templates — whitespace, quoting, spacing, and trailing-comma removal only. No behavioral changes.

Notes

  • erb_lint safely skips Ruby it can't extract from multi-line/split ERB tags, so a few single-quoted strings in such tags remain — not a miss.
  • The ruleset is easy to expand later (e.g. SelfClosingTag, ErbSafety/better-html, i18n HardCodedString); each addition just needs its own autocorrect pass.

maebeale and others added 2 commits July 14, 2026 19:10
RuboCop only parses .rb, so nothing checked the Ruby inside <% %> tags or
the ERB/HTML conventions documented in CLAUDE.md. Add erb_lint with a
conservative, fully-autocorrectable ruleset (mechanical HTML/ERB formatting
plus an omakase-matching RuboCop subset), wire it into ai/lint, and run it
in CI alongside RuboCop.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mechanical only: normalizes whitespace around/inside ERB tags and applies
the omakase Ruby style (double quotes, brace/bracket spacing) to code inside
<%= %> tags. No behavioral changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 14, 2026 23:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The HTML/ERB conventions are now enforced, not just documented; note that
and update the ai/lint command descriptions to mention ERB Lint.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 14, 2026 23:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@maebeale maebeale marked this pull request as ready for review July 14, 2026 23:33
maebeale and others added 2 commits July 14, 2026 19:40
The array/hash/block brace cops default to no_space in bare RuboCop but
omakase wants a space inside them; enabling the cops without pinning
EnforcedStyle silently enforced the opposite, so 772 array-bracket
violations went undetected. Pin the styles to omakase's values and extend
the subset to the other autocorrectable rules documented in CLAUDE.md:
block-brace spacing, no trailing commas, no redundant .to_s coercion, and
no semicolons.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Applies the newly-covered rules — omakase array/block-brace spacing and
trailing-comma removal — across templates. Mechanical only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 14, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

CI installs gems into vendor/bundle (bundler-cache), so `erb_lint --lint-all`
was linting third-party gem templates and failing on 237 offenses in files we
don't own. RuboCop excludes vendor by default; erb_lint doesn't, so exclude it
(plus node_modules and tmp) explicitly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 15, 2026 00:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@maebeale maebeale requested a review from jmilljr24 July 15, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants