`mix format` needs a strict mode

35 views
Skip to first unread message

AaronT

unread,
Feb 24, 2023, 5:15:44 PM2/24/23
to elixir-lang-core
When running `mix format` it seems to bypass cases where the code is syntactically correct but `locals_without_parens` are set or inherited from deps. 

So you items like `field(:name, :string)` is considered correct even if `,formatter.exs` has `import_deps: [:ecto]` which should cause it to format as `field :name, :string`.  This has led to inconsistencies in a sizable codebase which I'd like to have avoided.

I'd like to suggest a strict mode which is triggered with a  `--strict` argument which will strictly enforce the formatting guidelines.  This can then be used locally or in a ci process to ensure that the format is actually enforced.

Austin Ziegler

unread,
Feb 24, 2023, 5:24:00 PM2/24/23
to elixir-l...@googlegroups.com
`mix format` is always strict—even in cases where some of us would want "protected sections" (e.g., a formatted table of numbers). It doesn’t *revert* legal parentheses.

That is, `field(:name, :string)` is always legal even if `locals_without_parens` is set for `field/2`.

-a

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/287adcfa-bdb7-4696-927e-76983d97f7e6n%40googlegroups.com.


--
Reply all
Reply to author
Forward
Message has been deleted
0 new messages