Linter: Fix html-no-self-closing to preserve indentation#1753
Merged
marcoroth merged 1 commit intoJun 5, 2026
Merged
Conversation
When autofixing multiline self-closing tags (e.g. `<img\n />`), the rule was stripping the indentation whitespace before `/>`, causing the resulting `>` to appear at column 0. This introduces an `isIndentation` helper that detects when a trailing whitespace node represents indentation (i.e. it follows a newline sibling) and preserves it during the fix.
marcoroth
approved these changes
Jun 5, 2026
marcoroth
left a comment
Owner
There was a problem hiding this comment.
Awesome, thanks for this great catch @fgkolf! 🙏🏼
P.S. I wasn't sure whether I should open an issue first. Let me know if you'd prefer that for completeness' sake.
Whatever is more comfortable for you, but you definitely don't need to open an issue first just for the sake of opening an issue if you already have a proposed solution for the fix, thank you! 🙌🏼
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.
👋 I came across the following issue with the
html-no-self-closingrule:When autofixing nested elements whose closing tag appears on a new line, the self-closing tag is correctly fixed, but the indentation is lost and the closing bracket is placed at column 0.
This can be verified with the following example:
Before
After
With this fix
P.S. I wasn't sure whether I should open an issue first. Let me know if you'd prefer that for completeness' sake.