Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of low and works with any version of Elixir.
Explanation
Flags push_navigate, <.link navigate={...}>, and JS.navigate to
a route in a
different live_session than every route of the current LiveView.
LiveView navigates over the socket only within one live_session;
across sessions it falls back to a full page reload, which drops the
socket and reruns the plug pipeline and both mounts.
Before:
# in MyAppWeb.HomeLive, in live_session :public
<.link navigate={~p"/admin"}>Admin</.link>After, when the reload is intended:
<.link href={~p"/admin"}>Admin</.link>Or move both routes into one live_session when they share their
on_mount hooks and layout.
Only literal paths and ~p sigils are checked. Interpolated segments
match any route segment; the check reports only when every matching
route sits in another session. ignore_sessions lists session names
to skip as origin or target.
Confidence: low. Tier: semantic (run mix compile before mix credo).
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.
:ignore_sessions
live_session names (atoms) to skip as origin or target.
This parameter defaults to [].
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.