Guide
Migration
From hand-rolled icon helpers to Glyphs components — mostly autocorrected.
What the cop rewrites#
# before # after
_lucide(:house, class: "size-4") LucideIcon(:house, class: "size-4")
_hero(:check) HeroIcon(:check)
_heroicon(:check) HeroIcon(:check)
icon("check", library: "lucide") LucideIcon("check")
icon("check") HeroIcon("check") # DefaultLibraryComponentThe steps#
- Add
gem "glyphs"; replaceinclude YourIconHelperwithinclude Glyphsin your component base class(es). - Add the RuboCop plugin and cop config (see RuboCop cops).
- Delete your icon helper first — otherwise the cop rewrites the helper's own internal
icon(...)delegation. - Run the autocorrect:
bundle exec rubocop -A --only Glyphs/LegacyIconHelper,Glyphs/PreferLibraryComponent- Move your old missing-icon logging into
Glyphs.configure(see Missing icons).
Custom helper names map via cop config — Mappings replaces the defaults when set:
.rubocop.yml
Glyphs/LegacyIconHelper:
Mappings:
_custom: CustomIcon
DefaultLibraryComponent: HeroIconAudit forced variants first#
If your helpers hardcoded variants (icon(name, variant: "light", ...) inside the helper body), confirm your rails_icons config reproduces them as default variants before autocorrecting — the components pass variant: nil and let the icons gem resolve the default. A drifted default silently changes which SVG renders. Glyphs/IconResolution validates against the default-variant directory, so a wrong default usually surfaces as a wall of "not found" offenses.