This repository was archived by the owner on Jun 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathelixir_readability.mdc
More file actions
20 lines (20 loc) · 1.53 KB
/
elixir_readability.mdc
File metadata and controls
20 lines (20 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---
description:
globs: **/*.{ex,exs}
alwaysApply: false
---
- Environment variable, map keys, struct keys and assigns should be sorted in ascending order.
- Group multiple `alias`, `import`, `require`, or `use` statements together consistently.
- Aliases, imports, requires and uses should be alphabetically sorted in ascending order inside their group to ensure consistency and readability.
- There should be an empty line between @moduledoc, alias, require, import, @type, and module attribute blocks.
- Schema modules don't need moduledoc, so put `@moduledoc false`. Most of the time, only context modules need moduledoc.
- When creating a function component, the attributes block (containing lines like `attr :name`) should be ordered alphabetically.
- Unused variables should follow a consistent naming convention, typically prefixed with an underscore (`_var`) to signify their intent.
- Ensure that each pipe (`|>`) is used on its own line for better readability. Every pipe chain should start with a raw value/variable.
- Avoid piping a single function call into a block, as it can obscure the purpose of the pipe.
- Avoid using a single pipe (`|>`) for a simple operation when it could be written more clearly without piping.
- Avoid negating `is_nil/1`. Use the positive form of the condition for clarity.
- Fix formatting issues by running `mix format`.
- Fields inside schemas need to be ordered alphabetically.
- Use only proper Elixir: don't call functions that don't exist that might be available in other languages.
- Sort keys in a map alphabetically.