jsmestad / heex_formatter

Formatter for Phoenix Live View templates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HeexFormatter

ElixirCI

A code formatter for Heex templates.

⚠️ This project is still in alpha stage. There are several cases yet to be handled.

Installation

add :heex_formatter as dependency

defp deps do
  [
    # ...
    {:heex_formatter, github: "feliperenan/heex_formatter"}
  ]
end

Add it as plugin to your project .formatter file.

[
  plugins: [HeexFormatter],
  import_deps: [:ecto, :phoenix],
  inputs: ["*.{heex,ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{heex,ex,exs}"],
  subdirectories: ["priv/*/migrations"]
]

Now run

mix compile

options

line_length

The formatter defaults to a maximum line_length of 98 characters, which can be overwritten with the line_length option in the .formatter file.

Set heex_line_length to only set the line:lenght for the heex formatter.

[
  # ...omitted
  heex_line_length: 300
]

Inspired by Surface Formatter.

About

Formatter for Phoenix Live View templates.


Languages

Language:Elixir 100.0%