Linter: Treat breadcrumb as a side-effecting helper in erb-no-unused-expressions#1845
Draft
6temes wants to merge 1 commit into
Draft
Linter: Treat breadcrumb as a side-effecting helper in erb-no-unused-expressions#18456temes wants to merge 1 commit into
breadcrumb as a side-effecting helper in erb-no-unused-expressions#18456temes wants to merge 1 commit into
Conversation
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.
What
Adds
breadcrumbtoSIDE_EFFECT_METHODSinerb-no-unused-expressions, so<% breadcrumb :key %>calls are no longer reported as unused expressions.Why
gretel — a widely used breadcrumbs gem — exposes
breadcrumbas a view helper that is called purely for its side effect. It sets the current breadcrumb trail and is meant to be used in a silent tag:Under the hood it just assigns the renderer and returns it:
This is the same shape as
content_for,provide, and theturbo_*helpers already on the allowlist: a bare, receiver-less call used for a side effect, whose return value is intentionally discarded (you can't meaningfully<%= %>it — that would print aGretel::Renderer). Today the rule flags every<% breadcrumb %>, so an app that renders breadcrumbs on most pages gets one offense per view, which in practice forces disabling the rule project-wide.Verification
valid casestest mirroring the existingprovide/ Turbo tests.0.10.1build: withbreadcrumballowlisted,<% breadcrumb :key %>passes while a genuine<% @foo %>is still reported.I wasn't able to run the full JS test suite locally (the workspace build pulls in the native/Emscripten toolchain), so I'd appreciate CI confirming the added test.