Repository navigation
Linter: Improve erb-no-output-control-flow offense message - #2008
Merged
Merged
Conversation
🌿 Interactive Playground and Documentation PreviewA preview deployment has been built for this pull request. Try out the changes live in the interactive playground: 🌱 Grown from commit ✅ Preview deployment has been cleaned up. |
commit: |
marcoroth
marked this pull request as ready for review
August 5, 2026 08:44
marcoroth
added a commit
that referenced
this pull request
Aug 5, 2026
Follow up on #2008. This pull request makes `erb-no-output-control-flow` autocorrectable. Now that the offense message spells out the exact replacement, the rule can also apply it. The fix is a single token mutation, `<%=` becomes `<%`, which covers every shape the rule reports: `if`, `unless`, `elsif`, `else`, `end` and iteration blocks. ```diff - <%= if condition? %> + <% if condition? %> <p>Content</p> - <%= elsif another_condition? %> + <% elsif another_condition? %> <p>Content</p> - <%= end %> + <% end %> ```
marcoroth
added a commit
that referenced
this pull request
Aug 6, 2026
Similar to #2008, this pull request updates the offense message of `erb-no-unused-expressions` so that it shows the actual ERB tag that was reported and the actual tag it suggests, instead of the generic `<%= ... %>` placeholder. Previously the message named the expression on its own and always pointed at a placeholder for the fix, which left it up to the reader to assemble the suggestion themselves. Both halves of the message are now built from the reported tag: ```html+erb <!DoCTyPe <% hello world %> hello world this is inside the doctype> ``` ```diff - [error] Avoid unused expressions in silent ERB tags. `hello world` is evaluated but its return value is discarded. Use `<%= ... %>` to output the value or remove the expression. (erb-no-unused-expressions) + [error] Avoid unused expressions in silent ERB tags. `<% hello world %>` is evaluated but its return value is discarded. Use `<%= hello world %>` to output the value or remove the expression. (erb-no-unused-expressions) ```
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the offense message of
erb-no-output-control-flowso that it names the keyword that was actually used and suggests the actual corrected tag, instead of a generic placeholder.Previously the keyword came from a static node type to name mapping, which meant
elsifwas reported asif, sinceelsifis parsed as anERBIfNode:The keyword and the suggested replacement are now both derived from the content of the reported tag, the same way the iteration block branch of this rule already builds its suggestion: