Skip to content

Linter: Fix erb-no-duplicate-branch-elements autofixes - #2051

Merged
marcoroth merged 1 commit into
mainfrom
duplicate-branch-elements-unsafe-autofix
Aug 7, 2026
Merged

marcoroth merged 1 commit into
mainfrom
duplicate-branch-elements-unsafe-autofix

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

Removing a conditional whose branches are all identical also deletes the condition, which drops any assignment or side effect it performs. That fix now requires --fix-unsafely.

Wrapping the conditional in a shared tag is never offered for pre, textarea, script, or style, because the reindent puts the branch markup on its own indented lines and changes the text they render or submit. Those tags are still hoisted out when identical in every branch, which leaves their content untouched.

…behavior

Removing a conditional whose branches are all identical also deletes the condition, which drops any assignment or side effect it performs. That fix now requires `--fix-unsafely`.

Wrapping the conditional in a shared tag is never offered for `pre`, `textarea`, `script`, or `style`, because the reindent puts the branch markup on its own indented lines and changes the text they render or submit. Those tags are still hoisted out when identical in every branch, which leaves their content untouched.
@github-actions github-actions Bot added documentation Improvements or additions to documentation 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 7, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

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

commit: 2deaa8d

@github-actions

github-actions Bot commented Aug 7, 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 2deaa8d


✅ Preview deployment has been cleaned up.

@marcoroth
marcoroth merged commit c26ef19 into main Aug 7, 2026
22 checks passed
@marcoroth
marcoroth deleted the duplicate-branch-elements-unsafe-autofix branch August 7, 2026 01:03

This branch was successfully deployed

1 active deployment
herb-tools (Preview) — 2deaa8db Deployed Aug 7, 2026 by github-actions[bot]
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 @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.

1 participant