Crowdhailer

Crowdhailer

Creator of Raxx

Will it be possible to use the formatted to fail a build?

I’m looking for something like mix formatted that would return a failure if running mix format would change any files.

2
Post #22
NobbZ

NobbZ

Straight from the docs:

--check-formatted - check that the file is already formatted. This is useful in pre-commit hooks and CI scripts if you want to reject contributions with unformatted code. However, keep in mind, that the formatting output may differ between Elixir versions as improvements and fixes are applied to the formatter.

and

If any of the --check-* flags are given and a check fails, the formatted contents won’t be written to disk nor printed to stdout.

6
Post #23
rmoorman

rmoorman

Here is a github issue where @pragdave points out a few pros for having trailing commas in (keyword) lists and (I suppose) other data structures too.
I also find it quite annoying to have a diff with several lines changed when I only added one line within a map for example or that I have to manually correct commas when I reorder a list and it would be great if I could just use a trailing comma without the formatter stripping it away.

I read through some posts here on the forum and a few related discussions on github and it seems that the plan is to first make it work and then add the flexibility (for cases such as trailing commas) later on. Would that be a correct interpretation :slight_smile: ?

Thank you very much in advance!

0
Post #24
josevalim

josevalim OP

Creator of Elixir

Yup!

There has also been a discussion about trailing commas here in the forum. If someone find it, please link it here, for those who are curious. :slight_smile:

0
Post #25
rmoorman

rmoorman

Thank you for your quick reply! This clears things up for me.

Here is a topic I came across (besides this very topic) on the forum about it. It contains a few indirect and a direct remark about trailing commas. Is this by any chance the one you meant?

1
Post #27
josevalim

josevalim OP

Creator of Elixir

Both are excellent links, thanks. The one shared by @kokolegorille explains how trailing commas are tricky for functions calls in Elixir. The one by @rmoorman is the general formatter rationale/feedback thread.

1
Post #28
— All posts loaded —