Soundcheck.Check.Warning.UnhandledServerPushEvent (soundcheck v0.1.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of normal and works with any version of Elixir.

Explanation

Flags push_event/3 calls whose event no JavaScript listens for: no hook calls this.handleEvent("event", ...) and no window.addEventListener("phx:event", ...) exists. The push reaches the browser and does nothing.

Before:

{:noreply, push_event(socket, "highlite", %{id: id})}

// app.js
this.handleEvent("highlight", ({id}) => ...)

After:

{:noreply, push_event(socket, "highlight", %{id: id})}

The check reads the JavaScript under the js_paths plugin param (default assets/js), colocated hooks included. When the hook registry includes code soundcheck cannot follow, or the project has no LiveSocket, findings are unverifiable and appear only in strict mode.

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

Report unverifiable findings too.

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.