# `Bylaw.Credo.Check.PhoenixLiveView.RequireFunctionComponentAttrs`
[🔗](https://github.com/ryanzidago/bylaw/blob/v0.4.0/lib/bylaw/credo/check/phoenix_live_view/require_function_component_attrs.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

Requires caller-facing assigns in HEEx function components to have `attr` or
`slot` declarations.

Declarations make a component's public inputs explicit, enable compile-time
validation and useful warnings, and give callers documentation at the point
where the component is defined. Without them, misspelled or missing assigns
fail later in rendering and the component's contract stays implicit.

## Examples

Avoid:

    defp summary_card(assigns) do
      ~H"""
      <h2>{@title}</h2>
      """
    end

Prefer:

    attr :title, :string, required: true

    defp summary_card(assigns) do
      ~H"""
      <h2>{@title}</h2>
      """
    end

`render/1` is excluded because a LiveView's page assigns belong to its
lifecycle rather than a function-component contract. Assigns established
internally with `assign/2,3` are also excluded. `assign_new/3` does not
replace a declaration for a caller-facing input.

## Notes

This check treats public and private arity-one functions with a terminal
`~H` return as function components. It uses static AST and HEEx token
analysis and requires `phoenix_live_view` to be available.

## Options

This check has no check-specific options. Configure it with an empty option
list.

## Usage

Add this check to Credo's `checks:` list in `.credo.exs`:

```elixir
{Bylaw.Credo.Check.PhoenixLiveView.RequireFunctionComponentAttrs, []}
```

## Check-Specific Parameters

*There are no specific parameters for this check.*

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