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 hooks registered with LiveSocket that no template references
with phx-hook: dead JavaScript left behind after a template change.
Before:
Hooks.Legacy = {mounted() { ... }} // no phx-hook="Legacy" anywhereAfter: delete the hook, or reference it from a template.
The check reports nothing when any template uses a dynamic
phx-hook={...}, which could name any hook. Colocated hooks are never
reported: they live in the template that uses them.
The finding's only location is in JavaScript. Credo reports it against
the JavaScript file, without a line number; the message starts with
file:line:column. # credo:disable comments cannot reach a JavaScript
file, so silence a finding with // soundcheck:disable-next-line SC1002.
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.