Soundcheck.Check.Warning.InvalidLiveRender (soundcheck v0.1.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 high and works with any version of Elixir.

Explanation

Flags nested live_render(socket, View, opts) calls that LiveView rejects: opts carry no :id, which raises ArgumentError, or View is not a LiveView, which raises when it renders.

Before:

{live_render(@socket, MyAppWeb.ClockLive)}

After:

{live_render(@socket, MyAppWeb.ClockLive, id: "clock")}

Only calls whose first argument is the socket (@socket or a variable named socket) count: live_render(conn, ...) from a controller template needs no id. The :id check needs literal options; the module check expands the alias as the calling module expands it and skips modules it cannot load.

Confidence: high. Tier: semantic for the module check (run mix compile before mix credo); the :id check 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.