OptimumCredo.Check.Refactor.ToggleOnlyHandleEvent (OptimumCredo v0.5.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

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

Explanation

A handler that only toggles a boolean read by one :if can use JS.toggle/1 or JS.show/hide instead of a server round trip. Reported only for recognisable toggle-only handlers in modules whose inline template has a single :if consumer. Suggestion-grade; opt-in, low priority.

Check-Specific Parameters

Use the following parameters to configure this check:

:require_inline_template

Require an inline ~H template proving the single consumer; set to false to report without it.

This parameter defaults to true.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.