# `Soundcheck.Check.Warning.UnhandledHookEvent`
[🔗](https://github.com/leonqadirie/soundcheck/blob/v0.1.0/lib/soundcheck/check/warning/unhandled_hook_event.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 events a JavaScript hook pushes that the receiving LiveView or
LiveComponent does not handle. LiveView crashes the process when such
an event arrives.

Before:

    // assets/js/app.js
    Hooks.Chart = {mounted() { this.pushEvent("zoom", {}) }}

    <div id="chart" phx-hook="Chart">   <!-- in StatsLive, no "zoom" clause -->

After:

    def handle_event("zoom", params, socket), do: ...

`this.pushEvent` goes to the LiveView that renders the hook's element,
also from inside a LiveComponent. `this.pushEventTo(this.el, ...)`
goes to the LiveComponent or LiveView whose own render contains the
element. The finding anchors at the `phx-hook` attribute, because
Credo reports only in Elixir files.

Pushes with dynamic event names or targets, selector targets, and
hooks soundcheck cannot resolve to an object literal are skipped or
unverifiable.

Confidence: medium. Tier: semantic (run `mix compile` before `mix credo`).

## 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`

  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*
