Browse Source

AGENTS.md auto-formatting

master
buttercat1791 2 months ago
parent
commit
c14663dfb1
  1. 46
      AGENTS.md

46
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 - 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 - **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 - 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
<!-- usage-rules-start --> <!-- usage-rules-start -->
<!-- phoenix:elixir-start --> <!-- phoenix:elixir-start -->
## Elixir guidelines ## Elixir guidelines
- Elixir lists **do not support index based access via the access syntax** - 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) Enum.at(mylist, i)
- Elixir variables are immutable, but can be rebound, so for block expressions like `if`, `case`, `cond`, etc - 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 # INVALID: we are rebinding inside the `if` and the result never gets assigned
if connected?(socket) do 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 - **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: - 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) ref = Process.monitor(pid)
assert_receive {:DOWN, ^ref, :process, ^pid, :normal} 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:elixir-end --> <!-- phoenix:elixir-end -->
<!-- phoenix:phoenix-start --> <!-- phoenix:phoenix-start -->
## Phoenix guidelines ## 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. - 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
<!-- phoenix:phoenix-end --> <!-- phoenix:phoenix-end -->
<!-- phoenix:ecto-start --> <!-- phoenix:ecto-start -->
## Ecto Guidelines ## 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` - **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:ecto-end --> <!-- phoenix:ecto-end -->
<!-- phoenix:html-start --> <!-- phoenix:html-start -->
## Phoenix HTML guidelines ## Phoenix HTML guidelines
- Phoenix templates **always** use `~H` or .html.heex files (known as HEEx), **never** use `~E` - 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 %> <% 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 `<pre>` or `<code>` 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 `<pre>` or `<code>` block you _must_ annotate the parent tag with `phx-no-curly-interpolation`:
<code phx-no-curly-interpolation> <code phx-no-curly-interpolation>
let obj = {key: "val"} let obj = {key: "val"}
@ -219,20 +222,21 @@ custom classes must fully style the input
**Always** do this: **Always** do this:
<div id={@id}> <div id={@id}>
{@my_assign} {@my_assign}
<%= if @some_block_condition do %> <%= if @some_block_condition do %>
{@another_assign} {@another_assign}
<% end %> <% end %>
</div> </div>
and **Never** do this – the program will terminate with a syntax error: and **Never** do this – the program will terminate with a syntax error:
<%!-- THIS IS INVALID NEVER EVER DO THIS --%> <%!-- THIS IS INVALID NEVER EVER DO THIS --%>
<div id="<%= @invalid_interpolation %>"> <div id="<%= @invalid_interpolation %>">
{if @invalid_block_construct do} {if @invalid_block_construct do}
{end} {end}
</div> </div>
<!-- phoenix:html-end -->
<!-- phoenix:html-end -->
<!-- usage-rules-end --> <!-- usage-rules-end -->

Loading…
Cancel
Save