项目作者: Roberto-XY

项目描述 :
Elixir alias & import expression sorter
高级语言: Elixir
项目地址: git://github.com/Roberto-XY/eunomo.git
创建时间: 2020-04-13T16:10:56Z
项目社区:https://github.com/Roberto-XY/eunomo

开源协议:Apache License 2.0

下载


Eunomo

The default Elixir formatter has the philosophy of not modifying non metadata parts of the AST.
Eunomo does not adhere to this philosophy and is meant to be used as an extension to the default
formatter. As of now, the single use case is to sort import, alias and require definitions
alphabetically.

See https://hexdocs.pm/eunomo for further documentation &
https://github.com/Roberto-XY/eunomo for the source code.

Installation

The package can be installed by adding eunomo to your list of dependencies in mix.exs:

  1. def deps do
  2. [
  3. {:eunomo, "~> 3.0.0", only: :dev}
  4. ]
  5. end

Usage

Elixir >= 1.13.0 & version 3.0.0

Uses Elixir formatter plugin
system
.

  1. # .formatter.exs
  2. [
  3. # Usage of new formatter plugin system in Elixir `>= 1.13.0`.
  4. plugins: [Eunomo],
  5. eunomo_opts: [
  6. sort_alias: true,
  7. sort_import: true,
  8. sort_require: true
  9. ],
  10. inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
  11. ]

Running mix format is going to take over as usal from here. All mix format options also apply to
Eunomo plugins.

Elixir < 1.13.0 & version 0.1.3

Before Elixir version 1.13.0, there was no way to hook plugins into the default formatter. Hence
two Mix tasks were provided: mix eunomo.gen.config & mix eunomo. This approach does not
play nicely with umbrella applications.