Skip to content

Linter: Fix false positives for pattern matching in erb-no-unused-literals - #2784

Merged
marcoroth merged 1 commit into
marcoroth:mainfrom
markokajzer:linter-unused-literals-pattern-matching
Oct 7, 2026
Merged

marcoroth merged 1 commit into
marcoroth:mainfrom
markokajzer:linter-unused-literals-pattern-matching

Conversation

@markokajzer

Copy link
Copy Markdown
Contributor

Rightward and one-line pattern matching were reported as unused literals, because the hash pattern keys were visited as symbol literals:

<% summary => { diff_count:, coding_import_form_result_id: } %>
Avoid using silent ERB tags for literals. `diff_count:` is evaluated but never used or output.

The rule now only visits the value being matched for => and in, not the pattern. A literal as the matched value (<% "a" => { size: } %>) is still reported.

@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 labels Oct 6, 2026
@markokajzer markokajzer changed the title Linter: Don't flag pattern matching patterns in erb-no-unused-literals Linter: Fix false positives for pattern matching in erb-no-unused-literals Oct 6, 2026

@marcoroth marcoroth left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @markokajzer!

Looks like at least somebody is using rightwards assignments in ERB files 馃檲

@marcoroth
marcoroth merged commit 97f8807 into marcoroth:main Oct 7, 2026
18 checks passed
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-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