Skip to content

Linter: Fix erb-no-trailing-whitespace autofix inside HTML tags - #2016

Merged
marcoroth merged 1 commit into
mainfrom
erb-no-trailing-whitespace-inside-tags
Aug 6, 2026
Merged

marcoroth merged 1 commit into
mainfrom
erb-no-trailing-whitespace-inside-tags

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

This pull request updates erb-no-trailing-whitespace so its autofix also applies to trailing whitespace inside HTML tags, which it previously reported but could never fix.

The rule flags trailing whitespace anywhere in the source, but the autofix only knew how to rewrite HTMLTextNode and LiteralNode content.

Whitespace between attributes, after a tag name, or before a tag closing is tracked as a dedicated WhitespaceNode, so findNodeAtPosition returned null for those offenses, they were created without an autofixContext, and autofix() bailed on its first line. The offense was reported as [Correctable] and counted in N autocorrectable using --fix, but running --fix changed nothing and printed the same line again.

<div     data-a="foo" 
                   data-b="bar">
        lorem
        </div>

Everything inside tag markup was affected, while text content and attribute values already worked:

Related #1697 and #1909, which is the same class of misleading [Correctable] reporting for offenses --fix will not apply.

@github-actions github-actions Bot added linter @herb-tools/linter for HTML+ERB templates typescript TypeScript source across the javascript/ packages linter-rule Individual linter rules and their documentation linter-autofix Linter autofix behavior labels Aug 5, 2026
Comment thread javascript/packages/linter/src/rules/erb-no-trailing-whitespace.ts Fixed
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

🌿 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 b566eed


✅ Preview deployment has been cleaned up.

@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@2016
npx https://pkg.pr.new/@herb-tools/language-server@2016
npx https://pkg.pr.new/@herb-tools/linter@2016

commit: b566eed

@marcoroth
marcoroth force-pushed the erb-no-trailing-whitespace-inside-tags branch from b566eed to 4dac354 Compare August 6, 2026 09:43
@marcoroth
marcoroth marked this pull request as ready for review August 6, 2026 09:47
@marcoroth
marcoroth enabled auto-merge (squash) August 6, 2026 09:47
@marcoroth
marcoroth merged commit 96a36d0 into main Aug 6, 2026
20 of 21 checks passed
@marcoroth
marcoroth deleted the erb-no-trailing-whitespace-inside-tags branch August 6, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linter @herb-tools/linter for HTML+ERB templates linter-autofix Linter autofix behavior linter-rule Individual linter rules and their documentation typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants