Why `assert` is not formatted with bracket and how can I make my function like that?

When I run formatter, assert of ExUnit is formatted without bracket.

assert 2 == 2

I created assert_changeset_error, but it is formatted with bracket

assert_changeset_error(:users, fn -> User.create(attrs) end)

It is possible to make my function formatted without bracket?

Sure, you will need to tell your formatter.exs file to allow this function without parens.
You likely have this file already, but it would look like this:

[
  import_deps: [:phoenix],
  inputs: [
    "{config,lib,test,priv}/**/*.{ex,exs}",
    "{mix,.formatter}.exs"
  ],
  locals_without_parens: [
    assert_changeset_error: 2,
   ...
5 Likes