diff --git a/AGENTS.md b/AGENTS.md index 5c3db0a..5346bb8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -64,12 +64,12 @@ REST API at `/api/events` (show, create, delete) with JSON rendering. Uses `Fall - Out of the box, `core_components.ex` imports an `<.icon name="hero-x-mark" class="w-5 h-5"/>` component for for hero icons. **Always** use the `<.icon>` component for icons, **never** use `Heroicons` modules or similar - **Always** use the imported `<.input>` component for form inputs from `core_components.ex` when available. `<.input>` is imported and using it will save steps and prevent errors - If you override the default input classes (`<.input class="myclass px-2 py-1 rounded-lg">)`) class with your own values, no default classes are inherited, so your -custom classes must fully style the input - + custom classes must fully style the input + ## Elixir guidelines - Elixir lists **do not support index based access via the access syntax** @@ -87,7 +87,7 @@ custom classes must fully style the input Enum.at(mylist, i) - Elixir variables are immutable, but can be rebound, so for block expressions like `if`, `case`, `cond`, etc - you *must* bind the result of the expression to a variable if you want to use it and you CANNOT rebind the result inside the expression, ie: + you _must_ bind the result of the expression to a variable if you want to use it and you CANNOT rebind the result inside the expression, ie: # INVALID: we are rebinding inside the `if` and the result never gets assigned if connected?(socket) do @@ -120,13 +120,14 @@ custom classes must fully style the input - **Avoid** `Process.sleep/1` and `Process.alive?/1` in tests - Instead of sleeping to wait for a process to finish, **always** use `Process.monitor/1` and assert on the DOWN message: - ref = Process.monitor(pid) - assert_receive {:DOWN, ^ref, :process, ^pid, :normal} + ref = Process.monitor(pid) + assert_receive {:DOWN, ^ref, :process, ^pid, :normal} - - Instead of sleeping to synchronize before the next call, **always** use `_ = :sys.get_state/1` to ensure the process has handled prior messages - + - Instead of sleeping to synchronize before the next call, **always** use `_ = :sys.get_state/1` to ensure the process has handled prior messages + + ## Phoenix guidelines - Remember Phoenix router `scope` blocks include an optional alias which is prefixed for all routes within the scope. **Always** be mindful of this when creating routes within a scope to avoid duplicate module prefixes. @@ -145,6 +146,7 @@ custom classes must fully style the input + ## Ecto Guidelines - **Always** preload Ecto associations in queries when they'll be accessed in templates, ie a message that needs to reference the `message.user.email` @@ -157,6 +159,7 @@ custom classes must fully style the input + ## Phoenix HTML guidelines - Phoenix templates **always** use `~H` or .html.heex files (known as HEEx), **never** use `~E` @@ -186,7 +189,7 @@ custom classes must fully style the input ... <% end %> -- HEEx require special tag annotation if you want to insert literal curly's like `{` or `}`. If you want to show a textual code snippet on the page in a `
` or `` block you *must* annotate the parent tag with `phx-no-curly-interpolation`:
+- HEEx require special tag annotation if you want to insert literal curly's like `{` or `}`. If you want to show a textual code snippet on the page in a `` or `` block you _must_ annotate the parent tag with `phx-no-curly-interpolation`:
let obj = {key: "val"}
@@ -219,20 +222,21 @@ custom classes must fully style the input
**Always** do this:
-
- {@my_assign}
- <%= if @some_block_condition do %>
- {@another_assign}
- <% end %>
-
+
+ {@my_assign}
+ <%= if @some_block_condition do %>
+ {@another_assign}
+ <% end %>
+
and **Never** do this – the program will terminate with a syntax error:
- <%!-- THIS IS INVALID NEVER EVER DO THIS --%>
-
- {if @invalid_block_construct do}
- {end}
-
-
+ <%!-- THIS IS INVALID NEVER EVER DO THIS --%>
+
+ {if @invalid_block_construct do}
+ {end}
+
+
+
-
\ No newline at end of file
+