0

In my Phoenix app I have the following code:

  attrs           = %{"name" => "mat", "color" => "blue"}
  conn            = post(conn, Routes.session_path(conn, :create), player: attrs)
  expected_player = %Player{name: "mat", color: "blue"}

the problem is that when I run mix.format task it updates it to something like this:

  attrs = %{"name" => "mat", "color" => "blue"}
  conn = post(conn, Routes.session_path(conn, :create), player: attrs)
  expected_player = %Player{name: "mat", color: "blue"}

Which for me is less readable. Is there any way of configure mix formatter to not remove my indentation?

Mateusz Urbański
  • 7,352
  • 15
  • 68
  • 133
  • 1
    [This does not appear to be possible](https://elixirforum.com/t/how-to-customize-the-formatter/14491/3) because the formatter configuration options are limited. – Darragh Enright Dec 29 '18 at 00:15
  • 1
    More information [here](https://medium.com/blackode/code-formatter-the-big-feature-in-elixir-v1-6-0-f6572061a4ba) and at this [SO answer](https://stackoverflow.com/questions/50958098/elixirs-mix-format-configuration-options) – Darragh Enright Dec 29 '18 at 00:16
  • 2
    You can exclude the entire file from the list of automatically formatted, but please note that the former way (equal signs in the same column) is a code smell since it has a drawback: when the new one [long] value is added, equal signs should be all adjusted leading to the `diff` including several lines that were not in fact changed. No one OSS project would accept this style of formatting, so you’d better get accustomed to the proper style suggested by `formatter`. – Aleksei Matiushkin Dec 29 '18 at 08:04

0 Answers0