Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parenthesized by mix format

Elixir 1.7.3 (compiled with Erlang/OTP 19) on macOS 10.13.6 installed via asdf.

I run mix format lib/hello_web/router.ex to the following code:

pipeline :browser do
  plug :accepts, ["html"]
  plug :fetch_session
  plug :fetch_flash
  plug :protect_from_forgery
  plug :put_secure_browser_headers
end

Here is the result:

pipeline :browser do
  plug(:accepts, ["html"])
  plug(:fetch_session)
  plug(:fetch_flash)
  plug(:protect_from_forgery)
  plug(:put_secure_browser_headers)
end

Why is mix format adding the () part? Did I misconfigured something? If yes: How can I fix it?

like image 406
wintermeyer Avatar asked Apr 17 '26 00:04

wintermeyer


1 Answers

The formatter config for Phoenix's DSLs was added on March 9, 2018 and there has not been any Phoenix release since then from that branch. If you want to use it with the current Phoenix version, you'll need to copy the relevant rules to your project's .formatter.exs. To remove parentheses from the call to plug/1 and plug/2, just add this:

[
  ...
  locals_without_parens: [plug: 1, plug: 2],
  ...
]
like image 117
Dogbert Avatar answered Apr 21 '26 14:04

Dogbert