Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of high and works with any version of Elixir.
Explanation
Flags HTML elements with phx-hook but no id. LiveView tracks hook
instances by DOM id: without one it logs "no DOM ID for hook" in the
browser and never mounts the hook.
Before:
<div phx-hook="Chart"></div>After:
<div id="revenue-chart" phx-hook="Chart"></div>The check skips elements that spread attributes ({@rest}), which
may carry the id, and function component calls, which may set it on
the element they render.
Confidence: high. Tier: syntactic (works without compiling).
Check-Specific Parameters
Use the following parameters to configure this check:
:excluded_paths
Paths to skip (atoms, binaries as path segments, or regexes).
This parameter defaults to [~r/\/test\//, "test"].
:strict
Unused.
This parameter defaults to false.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.