Reference

RuboCop cops

Icon-name validation and legacy-helper autocorrection, shipped with the gem.

Setup#

A lint_roller plugin — RuboCop >= 1.72.

.rubocop.yml
plugins:
  - glyphs

Glyphs/LegacyIconHelper:
  Include:
    - app/**/*.rb
    - spec/**/*.rb
Glyphs/IconResolution:
  Include:
    - app/**/*.rb
  IconsPath: app/assets/svg/icons

RuboCop never becomes a runtime dependency of your app — the plugin constant loads lazily, only inside a RuboCop process. Classic require: [glyphs/rubocop] also works, but then you enable the cops yourself.

Glyphs/LegacyIconHelper#

Rewrites legacy helper calls to Glyphs components — _lucide, _phosphor, _hero, _heroicon, _tabler and bare icon() (with library:/from: literal extraction, or DefaultLibraryComponent when absent). Dynamic or unmapped libraries are flagged without autocorrection.

OptionDefaultMeaning
Mappingsthe five helpers abovehelper → component; replaces the defaults when set
DefaultLibraryComponentHeroIcontarget for bare icon() calls
LibraryComponentsall 13 librarieslibrary: literal → component

Glyphs/IconResolution#

Validates statically-known icon names against your synced SVG directories — variant-aware (a literal variant: selects the directory it validates against), with fuzzy typo suggestions (Damerau–Levenshtein + part scoring), autocorrection for unambiguous matches and the Lucide v1 renames, and detection of raw iconify <library>--<name> class strings (single-class spans are autocorrected to component calls). Legacy helper calls are validated too, so the cop protects you before and after migration.

OptionDefaultMeaning
IconsPathapp/assets/svg/iconsroot of the synced SVG tree
Librarieslucide/phosphor/heroicons/tabler/sidekickiconscomponent → { Dir:, DefaultVariant: }; merges over the defaults

Dynamic names, dynamic variants, unknown components, and a missing IconsPath are all skipped silently — the cop never guesses.

Glyphs/PreferLibraryComponent#

Rewrites generic Icon(name, library: <literal>) kit calls to the library-specific component and drops the library: pair. Dynamic libraries are flagged without autocorrection.

Icon(:house, library: :lucide) # => LucideIcon(:house)