Skip to content

Linter: Implement actionview-no-unused-strict-locals rule - #2012

Merged
marcoroth merged 1 commit into
mainfrom
actionview-no-unused-strict-locals
Aug 5, 2026
Merged

marcoroth merged 1 commit into
mainfrom
actionview-no-unused-strict-locals

Conversation

@marcoroth

@marcoroth marcoroth commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

This pull request implements the actionview-no-unused-strict-locals rule, which reports locals declared in a <%# locals: (...) %> declaration that the partial never references.

A strict locals declaration is the contract of a partial. Every name in it tells callers "this partial needs this value", and Rails raises ActionView::StrictLocalsError when a caller passes anything that is not declared. A name the template never reads makes that contract lie: callers keep computing and passing a value that is thrown away, and readers have to search the whole template before they can be sure it is unused. These usually appear when a partial gets refactored, the markup that used the value moves elsewhere, and the declaration stays behind.

<%# locals: (name:, age:) %>

<%= name %>
Strict local `age` is never used in this partial. Callers have to pass `age:` for a value the
template never renders. Remove it from the `locals:` declaration and from the call sites.

The message varies with whether the local is required, so an optional local reads Callers can pass size: ... instead.

Resolves #1566

@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 labels Aug 5, 2026
@marcoroth
marcoroth marked this pull request as ready for review August 5, 2026 11:04
@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 8358a10


✅ 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@2012
npx https://pkg.pr.new/@herb-tools/language-server@2012
npx https://pkg.pr.new/@herb-tools/linter@2012

commit: 8358a10

@marcoroth
marcoroth merged commit ebfb886 into main Aug 5, 2026
22 checks passed
@marcoroth
marcoroth deleted the actionview-no-unused-strict-locals branch August 5, 2026 11:15

This branch was successfully deployed

1 active deployment
herb-tools (Preview) — 8358a107 Deployed Aug 5, 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-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.

Linter Rule: Report unused strict locals

1 participant