Soundcheck.Check.Refactor.BareAssignsInTemplate (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 normal and works with any version of Elixir.

Explanation

Flags the bare assigns variable in template expressions. LiveView cannot tell which assigns such an expression depends on, so it re-renders it on every change, and LiveView gives no warning.

Before:

<p>{format_title(assigns)}</p>
<.card {assigns} />

After:

<p>{format_title(@title, @subtitle)}</p>
<.card title={@title} subtitle={@subtitle} />

@key, assigns.key, and assigns[:key] are tracked and never reported.

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.