sevenseacat
Autoformatting of Ash-related code
I always have issues with getting formatting for Ash-related code to work - I’ve seen it working before, I’ve gotten it working before, but always struggle getting it working on a new project.
I have a brand new Phoenix 1.7.10 app set up, with the latest versions of Ash, AshPostgres and AshPhoenix. I’ve added the deps and the plugin to my .formatter.exs -
[
import_deps: [:ecto, :ecto_sql, :phoenix, :ash, :ash_postgres, :ash_phoenix],
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter, Spark.Formatter],
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
]
But when I do things like add parentheses to functions that shouldn’t have any, or rearrange the top-level blocks in a resource, they don’t get formatted the way they should when I run mix format.
Formatting is still working, because if I add things like heaps of extra blank lines they get stripped, it’s just the Ash-specific stuff that doesn’t seem to be working.![]()
Marked As Solved
zachdaniel
I believe you have to add at minimum an empty config for the things you want to get formatted, and also use the remove_parens?: true option.
i.e
config :spark, :formatter,
remove_parens?: true,
"Ash.Resource": [
section_order: [....]
]
Also Liked
sevenseacat
Oh that works perfectly! (And yes I can see that in the other apps that the formatting works in)
That’s not mentioned in any of the Getting Started guides that talk about setting up the formatter - I’ll see where it will fit and add it.
Last Post!
sevenseacat
Oh that works perfectly! (And yes I can see that in the other apps that the formatting works in)
That’s not mentioned in any of the Getting Started guides that talk about setting up the formatter - I’ll see where it will fit and add it.
Popular in Questions
Other popular topics
Latest Ash Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









