繁体   English   中英

Elixir 的混合格式忽略行长选项

[英]Elixir's mix format ignores line length option

我的项目根目录中有一个 Elixir 项目.formatter.exs文件,如下所示:

[
  line_length: 120,
  inputs: ["mix.exs", "config/*.exs"],
  subdirectories: ["apps/*"]
]

但据我所知, line_length参数被忽略了。

给定以下代码,最长的行(长度为 102 个字符)总是被分成两行( when子句包装到新行):

defmodule SomeModule do
  def lookup_data(parameter1, parameter2) when is_integer(parameter1) and is_integer(parameter2) do
    :not_implemented
  end
end

相比之下,如果我将模块复制并粘贴到在线 Elixir 格式化程序中并将行长度选项设置为 120,则不会对文本进行任何更改(如预期)。

我一定是搞砸了.formatter.exs不知何故,但对于我的生活,我无法弄清楚如何。

mix format docs 中,它指出,如果您的顶级.formatter.exs列出了子目录(我的有"apps/*" ),则顶级格式化程序中的规则将不会在这些子目录中使用。

解决方案是使用apps/[my_app]/.formatter.exs编辑apps/[my_app]/.formatter.exs (之前由mix new自动生成):

[
  line_length: 120
]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM