簡體   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