简体   繁体   English

在Elixir中,是否可以修改混合格式以使最终关键字列表周围的方括号为强制性?

[英]In Elixir, Is it possible to modify mix format to make square brackets around final keyword lists mandatory?

Hold a strong belief that explicit is better than implicit, I really dislike that mix format removes the optional square brackets from the final parameter of a function when that function is a keyword list. 坚信显式比隐式更好,我真的不喜欢混合格式在该函数是关键字列表时从该函数的最终参数中删除可选的方括号。

Is there any way to modify mix format's configuration/rules so at the very least it will leave those square brackets alone and -- in an ideal world -- add them where they are missing? 有什么方法可以修改混合格式的配置/规则,以便至少将那些方括号放在一边,并且-在理想情况下-将其添加到缺少的地方?

Also, where can I find any information about how to configure the formatting rules which the tool enforces? 另外,在哪里可以找到有关如何配置该工具强制执行的格式设置规则的任何信息?

The short answer is no. 最简洁的答案是不。

Here's the long answer: 这是很长的答案:

Elixir formatting is extremely opinionated and it's for a pretty good reason. Elixir格式具有很高的权威性,这是有充分理由的。 the format mix task was introduced to enforce conformity among all Elixir projects. 引入了format混合任务以在所有Elixir项目之间实施一致性。 It means that any project across the ecosystem that is formatted properly will look and read the same as any other project. 这意味着整个生态系统中任何格式正确的项目都将在外观和读取方面与其他任何项目相同。 It reduces code churn and merge conflicts. 它减少了代码搅动和合并冲突。 More importantly, it immediately stops disputes among team members about "the way I prefer to format muh code". 更重要的是,它立即阻止了团队成员之间关于“我更喜欢格式化muh代码的方式”的争议。

It's pretty ingenious if you think about it. 如果您考虑一下,这将非常巧妙。 If you were able to configure it in any way we'd end up with something like a JavaScript formatter where it's basically the wild west where anything goes and even the simplest formatter libraries are extremely configurable. 如果您能够以任何方式对其进行配置,那么最终将得到JavaScript格式化程序之类的东西,它基本上就是狂野的西部,甚至任何最简单的格式化程序库都可以高度配置。

Some things about the formatter were annoying to me at first, too. 起初,关于格式化程序的一些事情也让我很烦。 However, you'll get over it and you'll be much happier using it than not. 但是,您将克服它,并且使用它会更加快乐。

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

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