Linter: Make html-no-self-closing Action View Helper aware#1432
Merged
Linter: Make html-no-self-closing Action View Helper aware#1432
html-no-self-closing Action View Helper aware#1432Conversation
commit: |
🌿 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. |
marcoroth
added a commit
that referenced
this pull request
Mar 20, 2026
) While working on #1432 I noticed that our keyword argument extraction logic for Action View Tag Helpers doesn't 100% produce the right syntax tree for attributes. Given the following example: ```erb <%= tag.div(id:) %> ``` Now with this pull request and `action_view_helpers: true` it parses as: ```diff @ DocumentNode (location: (1:0)-(1:19)) └── children: (1 item) └── @ HTMLElementNode (location: (1:0)-(1:19)) ├── open_tag: │ └── @ ERBOpenTagNode (location: (1:0)-(1:19)) │ ├── tag_opening: "<%=" (location: (1:0)-(1:3)) │ ├── content: " tag.div(id:) " (location: (1:3)-(1:17)) │ ├── tag_closing: "%>" (location: (1:17)-(1:19)) │ ├── tag_name: "div" (location: (1:8)-(1:11)) │ └── children: (1 item) │ └── @ HTMLAttributeNode (location: (1:12)-(1:12)) │ ├── name: │ │ └── @ HTMLAttributeNameNode (location: (1:12)-(1:12)) │ │ └── children: (1 item) │ │ └── @ LiteralNode (location: (1:12)-(1:12)) │ │ └── content: "id" │ │ │ ├── equals: ":" (location: (1:12)-(1:12)) │ └── value: │ └── @ HTMLAttributeValueNode (location: (1:12)-(1:12)) │ ├── open_quote: ∅ │ ├── children: (1 item) │ │ └── @ RubyLiteralNode (location: (1:12)-(1:12)) - │ │ └── content: "id:" + │ │ └── content: "id" │ │ │ ├── close_quote: ∅ │ └── quoted: false │ ├── tag_name: "div" (location: (1:8)-(1:11)) ├── body: [] ├── close_tag: │ └── @ HTMLVirtualCloseTagNode (location: (1:19)-(1:19)) │ └── tag_name: "div" (location: (1:8)-(1:11)) │ ├── is_void: false └── element_source: "ActionView::Helpers::TagHelper#tag" ```
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.
Now that we have support for detecting Action View Tag helpers we can update the
html-no-self-closinglinter rule to make it Action View Tag helpers aware.Since the parser already transforms the nodes we don't need to change anything else about the existing rule.
With this pull request, the following doesn't get flagged anymore:
Previously, this was flagged as:
Resolves #567