Elixir Alias Autosorter – VS Code extension that automatically sorts aliases in Elixir modules on save

Hi everyone! :waving_hand:

I became tired of manually sorting aliases every time Credo warns they are not in the alphabetical order, and so I created a VS Code extension that sorts the aliases automatically on save (or on demand).

The extension is really trivial, it works just with the text representation (no parsing and traversing ASTs) and it’s fast enough to be run on every save, at least on my machine.

I’ve been using the extension for weeks and it’s been great, so now I would like to share it with you. Any feedback is welcomed. :slightly_smiling_face:

Features

  • Sorts aliases on every save (can be turned off)
  • Sorts aliases on demand using the Sort Elixir Aliases in File command
  • Aliases are sorted only among its group (delimited by newlines or non-aliases)
  • Multi-aliases (such as alias Phoenix.{Controller, PubSub}) are sorted as well
  • Built to comply with Credo.Check.Readability.AliasOrder
8 Likes