I have an Elixir project .formatter.exs
file in my project root that looks like this:
[
line_length: 120,
inputs: ["mix.exs", "config/*.exs"],
subdirectories: ["apps/*"]
]
But as best I can tell, the line_length
parameter is being ignored.
Given the following code, the longest line (whose length is 102 characters) is always being split into two lines (with the when
clause wrapped to the new line):
defmodule SomeModule do
def lookup_data(parameter1, parameter2) when is_integer(parameter1) and is_integer(parameter2) do
:not_implemented
end
end
In contrast, if I copy & paste the module into the online Elixir formatter and set the line length option to 120, I get no changes to the text (as expected).
I must have screwed up the .formatter.exs
somehow, but for the life of me I can't figure out how.
In the mix format docs, it notes that if your top-level .formatter.exs
lists subdirectories (mine has "apps/*"
), the rules from the top-level formatter won't be used in those subdirectories.
The solution was to edit apps/[my_app]/.formatter.exs
(which had been auto-generated by mix new
previously) with the line length parameter:
[
line_length: 120
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With