Rbtz.CredoChecks.Design.RawSvgInHeex (rbtz_credo_checks v0.2.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of normal and works with any version of Elixir.

Explanation

Forbids raw <svg> tags in HEEx templates.

Icons should come from the FyrUI.SVG module via <.svg_lucide_*> function components (or <.svg_hero_*> when a Lucide variant is not available). The component approach keeps icon naming consistent across the app, supports compile-time icon-set verification, and avoids copy-pasting raw SVG markup across files.

The check inspects every ~H sigil and every .heex template referenced via embed_templates. Detection is line-by-line: a <svg whose first attribute sits on the next line is not flagged.

Bad

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
  <path d="..." />
</svg>

Good

<.svg_lucide_search />

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.