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
Discourages indirect access to the special HEEx assigns variable.
Avoid:
~H"<h1>{Map.get(assigns, :title)}</h1>"
~H"<h1>{assigns[:title]}</h1>"Initialize the assign before rendering and access it directly:
~H"<h1>{@title}</h1>"Direct access makes the template's inputs visible and requires missing values
to be handled at the rendering boundary. This check reports literal keys in
both two- and three-argument Map.get calls, as well as bracket access. It
ignores dynamic keys because they cannot be safely rewritten to direct HEEx
assign access.
Embedded ~H templates are checked during normal Credo runs over Elixir
files. Standalone .html.heex templates require enabling
Bylaw.Credo.Plugin.HEExSources.
Configure this check with an empty option list:
{Bylaw.Credo.Check.HEEx.NoIndirectAssignAccess, []}Check-Specific Parameters
There are no specific parameters for this check.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.