Skip to content

Linter: Implement erb-no-unused-expressions rule#1531

Merged
marcoroth merged 1 commit intomainfrom
erb-no-unused-expressions
Mar 29, 2026
Merged

Linter: Implement erb-no-unused-expressions rule#1531
marcoroth merged 1 commit intomainfrom
erb-no-unused-expressions

Conversation

@marcoroth
Copy link
Copy Markdown
Owner

@marcoroth marcoroth commented Mar 29, 2026

Disallow expressions inside silent ERB tags (<% %>) whose return values are discarded. Writing expressions like <% @user.name %> or <% helper_method(arg) %> evaluates the expression but discards the result, making the line functionally useless.

This rule detects and warns about silent ERB tags containing:

  • Method calls without blocks
  • Instance variable reads (@user)
  • Class variable reads (@@count)
  • Global variable reads ($global)
  • Constant reads (CONSTANT, Foo::Bar)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 29, 2026

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

commit: 769d2d8

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 29, 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 769d2d8


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth force-pushed the erb-no-unused-expressions branch from 65f5660 to 77cd7e0 Compare March 29, 2026 01:07
@marcoroth marcoroth force-pushed the erb-no-unused-expressions branch from 77cd7e0 to 769d2d8 Compare March 29, 2026 01:14
@marcoroth marcoroth merged commit c760f94 into main Mar 29, 2026
20 checks passed
@marcoroth marcoroth deleted the erb-no-unused-expressions branch March 29, 2026 01:43
@brunoprietog
Copy link
Copy Markdown

This could result in some false positives, such as when using the turbo_refreshes_with helper, which doesn't require <%=.

@marcoroth
Copy link
Copy Markdown
Owner Author

Thanks @brunoprietog great catch! I opened #1586 to allow for those Turbo methods that have side effects 🙌🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation linter linter-rule typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants