bradley
Would auto formatting/sorting phoenix liveview/live component callbacks make sense?
I’ve been recently been doing the “vibe coding” thing a lot using cursor and I’m finding that very frequently the models don’t group liveview callbacks appropriately, which results in compiler warning that kills the “vibe”.
For example, it’ll do something like:
def handle_event(...
def handle_info(...
def handle_event(...
Which will result in a compiler warning.
I just wanted to check in with folks, would it be crazy to consider auto sorting liveview callbacks?
I have a really hacky AI written fork of styler here that seems to work okay on my current codebase. If you’re curious about the very few cases that I’ve considered already, please see the tests for liveview here and the tests for liveview components here.
The TLDR is that it basically standardizes the order of callbacks, similar to credo’s StrictModuleLayout. The current liveview order of preference is:
- mount/3
- handle_params/3
- handle_event/3
- handle_info/2
- handle_async/2
- handle_call/3
- handle_cast/2
- update/2
- terminate/2
- render/1
And the live component order is:
- mount/1
- update/2
- update_many/1
- handle_event/3
- handle_async/2
- render/1
Does anyone else have interest in this kind of thing?
Edited
I do use rulesets and they don’t work 100% of the time for me which is why I’ve considered this solution for myself.
First Post!
munksgaard
Could it be a plugin to mix format? I would appreciate something that enforced a specific order in my live_view modules.
Popular in Questions
Other popular topics
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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








