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 direct children of a phx-update="stream" container that lack
an id={...} expression. LiveView tracks stream items by DOM id: a
child without one, or with a literal id that every item repeats, breaks
inserts, updates, and deletes. LiveView reports this only in the
browser.
Before:
<ul id="posts" phx-update="stream">
<li :for={{_id, post} <- @streams.posts}>{post.title}</li>
</ul>After:
<ul id="posts" phx-update="stream">
<li :for={{id, post} <- @streams.posts} id={id}>{post.title}</li>
</ul>A static child with a literal id, such as the empty-state element
LiveView's docs show (<li id="posts-empty" class="only:block hidden">),
renders once and is fine. Component children are skipped: the element
they render is not visible in the template.
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.