# `Soundcheck.Check.Design.UnusedHook`
[🔗](https://github.com/leonqadirie/soundcheck/blob/v0.1.0/lib/soundcheck/check/design/unused_hook.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) 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" anywhere

After: 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](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
