Ash.ResourceFormatter (ash v1.51.2) View Source

Formats Ash resources. WARNING: This is untested, use at your own risk! do not run without commiting your code first!

Currently, it is very simple, and will only reorder the outermost sections according to some rules.


Include the plugin into your .formatter.exs like so plugins: [Ash.ResourceFormatter].

If no configuration is provided, it will sort all top level DSL sections alphabetically.

Section Order

To provide a custom section order (for both ash and any extensions), add configuration to your app, for example:

config :ash, :formatter,
  section_order: [

Any sections found in your resource that aren't in that list will be left in the order that they were in, the sections in the list will be sorted "around" those sections. E.g the following list: [:code_interface, :attributes] can be interpreted as "ensure that code_interface comes before attributes, and don't change the rest".

Using something other than Ash.Resource

The resource formatter triggers when it sees a use Ash.Resource in a module. In some cases, you may be "use"ing a different module, e.g use MyApp.Resource. To support this, you can configure the using_modules, like so:

config :ash, :formatter,
  using_modules: [Ash.Resource, MyApp.Resource]

Link to this section Summary

Link to this section Functions

Callback implementation for Mix.Tasks.Format.features/1.

Callback implementation for Mix.Tasks.Format.format/2.