# `Soundcheck.Check.Warning.UndefinedHook`
[🔗](https://github.com/leonqadirie/soundcheck/blob/v0.1.0/lib/soundcheck/check/warning/undefined_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 `high` and works with any version of Elixir.

## Explanation

Flags `phx-hook="Name"` references to hooks that the project's
`LiveSocket` does not register. LiveView logs an error in the browser
and the hook never mounts.

Before:

    <div id="feed" phx-hook="InfiniteScrol">

    const Hooks = {InfiniteScroll: {...}}

After:

    <div id="feed" phx-hook="InfiniteScroll">

The check reads the JavaScript under the `js_paths` plugin param
(default `assets/js`): hooks registered through
`new LiveSocket(url, Socket, {hooks: ...})`, objects bound to variables
and extended by assignment or `Object.assign`, relative imports, and
colocated hooks (`<script :type={ColocatedHook} name=".Name">`, which
`phx-hook=".Name"` refers to) when `app.js` imports
`phoenix-colocated/<app>`.

When the registry includes something soundcheck cannot follow (an npm
package, a computed key), findings are unverifiable and appear only in
strict mode. List hooks registered that way in `external_hooks` to
make the registry closed again.

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"]`.

### `:external_hooks`

  Hook names registered by code soundcheck cannot follow.

*This parameter defaults to* `[]`.

### `:strict`

  Report unverifiable findings too.

*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*
