Closed bitboxer closed 6 years ago
Ignoring the default .formatter.exs
is by design, as a piped in stream of characters is considered to be unrelated to the current (or any) project.
In my opinion it should respect an explicitely passed in config file via --dot-formatter
though.
This is fixed on v1.6.4. --
José Valimwww.plataformatec.com.br http://www.plataformatec.com.br/Founder and Director of R&D
Thanks for the quick reply 👍
Just found time to test this in my local elixir 1.6.4
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [kernel-poll:false]
Elixir 1.6.4 (compiled with OTP 19)
Sadly I can't confirm that this works.
I did this:
cat /path/to/file.exs | mix format --dot-formatter=/path/to/.formatter.exs -
And it did non respect the config I gave to it. Using
mix format --dot-formatter=/path/to/.formatter.exs /path/to/file.exs
it worked.
@bitboxer it worked just fine here. Here is what I did:
$ cat foo.ex | mix format --dot-formatter=path/to/elixir/repo/.formatter.exs -
assert_same bar
Notice that it did not add parens around assert_same since it is listed in .formatter.exs.
Maybe the issue is that my .formatter.exs
looks like this:
[
inputs: ["mix.exs", "config/*.exs"],
subdirectories: ["apps/*"]
]
and in the subdirectories I have some additional formatter files. Will try it out with moving the stuff into the main config file tonight.
The input file -
will never traverse the subdirectories since it doesn't have any path in it. It always consider the root one. And since you don't have anything at the root then it will only o the default formatting.
Other languages have a parameter for the formatter to set the root path if you pipe a file into the formatter. But it's understandable if you think this might be too much overhead for elixir. I can work around that with saving the file in a specific directory and deleting it afterwards.
Environment
Current behavior
When piping code into the formatter like this:
it does not respect the local
.formatter.exs
. It also ignores the--dot-formatter
setting.Am I doing something wrong? Is this a bug?
Expected behavior
It should format the code using the local
.formatter.exs
or at least the one I specify in the params.