Mutare.Phoenix.LiveView.Reply (mutare_phoenix_live_view v0.1.0)

Copy Markdown View Source

:lv_reply — drops the optional trailing element of a LiveView callback's return tuple, reshaping it into a different but still valid return. Fires in modules that implement @behaviour Phoenix.LiveView or @behaviour Phoenix.LiveComponent:

handle_event/3   {:reply, payload, socket}  ->  {:noreply, socket}
handle_call/3    {:reply, reply, socket}    ->  {:noreply, socket}
mount/3          {:ok, socket, opts}         ->  {:ok, socket}

A survivor means no test checks the dropped element — the JS-hook reply payload, or the mount temporary_assigns: / layout: option. A Phoenix.LiveComponent's handle_event/3 returns the same {:reply, payload, socket} shape, so its reply payload is the same untested seam; the {:ok, socket, opts} (mount) reshape simply never matches a component return.

Recognised by tuple shape, independent of which callback it sits in. The 2-tuples {:noreply, socket} / {:ok, socket} have nothing to drop and are left alone. Silence a site with # mutare:ignore[lv_reply].

Under --no-expand-uses the @behaviour that use Phoenix.LiveView / use Phoenix.LiveComponent injects is invisible, so :lv_reply no-ops; a direct @behaviour still works.

Summary

Functions

Offer the reshaped LiveView return for tail, but only inside a module that implements one of [Phoenix.LiveView, Phoenix.LiveComponent] (read from context.behaviours). The behaviour-aware variant of Mutare.Mutator.Structural.return_replacements/1.

Functions

return_replacements(tail, map)

@spec return_replacements(Macro.t(), Mutare.Mutator.Structural.context()) :: [
  Macro.t()
]

Offer the reshaped LiveView return for tail, but only inside a module that implements one of [Phoenix.LiveView, Phoenix.LiveComponent] (read from context.behaviours). The behaviour-aware variant of Mutare.Mutator.Structural.return_replacements/1.