Formatting Standards for use/import/alias

Is there a standard for the use of “use”/“import”/"“require”/“alias”?

Right now, we use the following as “standard”:

use statements

require statements

import statements

alias statements

also. we have the modules sorted in alphabetical order.

But: is there a standard for this? And if so, how to enforce it?

It’s not really a standard, but you can use this rule in Credo

5 Likes

There is this unofficial style guide which covers what you need: (I use it when in doubt)
GitHub - christopheradams/elixir_style_guide: A community driven style guide for Elixir

And then Lexmag’s style guide which was the foundation for mix format IIRC.
GitHub - lexmag/elixir-style-guide: An opinionated Elixir style guide

3 Likes

Thank you

1 Like