Closed lasseebert closed 6 years ago
The formatter mix task ignores .formatter.exs, even when parsed in as --dot-formatter when the input is from stdin (-).
.formatter.exs
--dot-formatter
-
Example:
# formatter_test.ex defmodule FormatterTest do 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 end
#.formatter.exs [ inputs: ["mix.exs", "apps/*/mix.exs", "apps/*/{config,lib,test}/**/*.{ex,exs}"], line_length: 119 ]
When I run the mix format task with stdin:
$ cat formatter_test.ex | mix format - --dot-formatter .formatter.exs defmodule FormatterTest do 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 end
it breaks the lines at column 99 and not column 119 as specified in the .formatter.exs.
If I format with mix format formatter_test.ex it changes the file as expected to:
mix format formatter_test.ex
defmodule FormatterTest do 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 end
cat file.ex | mix format - --dot-formatter .formatter.exs should format in the same way as mix format file.ex --dot-formatter .formatter.exs
cat file.ex | mix format - --dot-formatter .formatter.exs
mix format file.ex --dot-formatter .formatter.exs
I have tested also in 1.6.1, where it works as expected. I suspect that the change was introduced in this commit: https://github.com/elixir-lang/elixir/commit/d896f541f1ffff6677b56e5f0c0ad04b8ce447ed
Is the change from 1.6.1 to 1.6.2 on purpose?
It has been fixed in master and v1.6. We plan to release v1.6.3 soon with a fix for this. Thanks!
Ah, didn't think to try on master.
Thanks for the quick reply! :)
Environment
Current behavior
The formatter mix task ignores
.formatter.exs
, even when parsed in as--dot-formatter
when the input is from stdin (-
).Example:
When I run the mix format task with stdin:
it breaks the lines at column 99 and not column 119 as specified in the .formatter.exs.
If I format with
mix format formatter_test.ex
it changes the file as expected to:Expected behavior
cat file.ex | mix format - --dot-formatter .formatter.exs
should format in the same way asmix format file.ex --dot-formatter .formatter.exs
I have tested also in 1.6.1, where it works as expected. I suspect that the change was introduced in this commit: https://github.com/elixir-lang/elixir/commit/d896f541f1ffff6677b56e5f0c0ad04b8ce447ed
Is the change from 1.6.1 to 1.6.2 on purpose?