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 stream names a LiveView or LiveComponent uses but never
defines. @streams holds only the streams that stream/4 or
stream_async/4 created, so a template reading @streams.post when
the module streams :posts raises KeyError on render, and
stream_insert/4, stream_delete/3, or stream_delete_by_dom_id/3
on an unknown name raises ArgumentError.
Before:
def mount(_params, _session, socket),
do: {:ok, stream(socket, :posts, Blog.list_posts())}
<div id="posts" phx-update="stream">
<div :for={{id, post} <- @streams.post} id={id}>{post.title}</div>
</div>After:
<div :for={{id, post} <- @streams.posts} id={id}>{post.title}</div>Definitions are stream/3,4, stream_async/3,4, and
stream_configure/3 calls with a literal atom name in the module's
own functions and in the project functions it calls, through remote
calls and imports at any depth. Reads come from its render/1
template, colocated or inline. The check skips a module when it and
those functions define no stream, when any of them names one
dynamically, or when it passes its socket to a function outside the
project and Phoenix, since that function may define streams the
check cannot see.
Confidence: medium. 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.