mix-elixir-tooling
Mix Elixir Tooling
Resumo (pt-BR): Após editar arquivos Elixir, rodar format, credo e compile com warnings-as-errors. Usar mix precommit quando o projeto definir esse alias.
When working on Elixir files, use the Mix toolchain to keep code consistent and error-free.
When to Use
- After editing any
.exor.exsfile - Before committing Elixir changes
- When the user asks to "format", "lint", "check code quality", or "fix compile warnings" in an Elixir project
Tools (in order)
1. mix format
Formats all Elixir source files according to the project's .formatter.exs.
mix format
Run after editing code to keep style consistent. The project may format specific paths; use mix format path/to/file.ex for a single file.
2. mix credo
Runs Credo for code quality and consistency (if the project has Credo in deps).
mix credo
# Or for a single file:
mix credo path/to/file.ex
Run after edits to catch style issues, duplication, and suggested refactors. If Credo is not in mix.exs, skip this step.
3. mix compile --warnings-as-errors
Ensures the project compiles and treats warnings as errors.
mix compile --warnings-as-errors
Run to catch compile-time warnings before they accumulate. Fix any reported warnings.
Project alias: mix precommit
If the project defines a precommit alias in mix.exs (e.g. format + credo + compile), prefer:
mix precommit
Use this when the project documents it (e.g. in AGENTS.md or README) so one command runs the full checks.
Process
- After making changes to Elixir files, run
mix format(ormix precommitif available). - If Credo is in the project, run
mix credoand address reported issues. - Run
mix compile --warnings-as-errorsand fix any warnings. - If the project uses
mix precommit, running it once may cover all of the above.
Notes
- Don't assume Credo is present; check
mix.exsor runmix help credo. - Format and compile are standard; Credo is optional and project-specific.
- Always fix compile warnings; do not leave them for later.