β¨ Lint & Formatting Hooks
If your repository enforces code style, prettier formatting, or pre-commit linting,
you may need to configure test generation agents to run those tools automatically.
Early CLI agents have built-in defaults for linting and formatting:
LINT_COMMANDβ to auto-fix ESLint issuesPRETTIER_COMMANDβ to apply formatting (e.g., Prettier)
These are the same commands described below. If your repository uses different commands (e.g., via hooks or custom scripts), you should override these defaults accordingly.
π§ When You Need Thisβ
Your CI pipeline may reject commits if generated test files do not pass style checks.
Typical situations include:
- ESLint rules with
--max-warnings=0 - Prettier formatting enforced via Husky or CI
lint-stagedorpre-commithooks- Monorepos with strict
.eslintrcor.prettierrcconfigs
Without linting/formatting, generated tests may fail to commit.
π οΈ How to Configureβ
Set the following environment variables in your CI environment:
export LINT_COMMAND="npx --no eslint $early_filename --fix"
export PRETTIER_COMMAND="npx --no prettier $early_filename --write"
- These values are the defaults used if none are provided.
- If you override them, make sure to retain the placeholder $early_filename β itβs replaced by each generated test file name at runtime.
The commands run:
- After test files are generated
- Before validating them
- Before committing
β οΈ If these commands fail, the generated tests will not be committed.
π§ͺ Example: GitHub Actionsβ
env:
LINT_COMMAND: "npx --no eslint $early_filename --fix"
PRETTIER_COMMAND: "npx --no prettier $early_filename --write"
These ensure compliance with your projectβs lint and formatting standards.
π CLI Agent Compatibilityβ
The following agents support lint and formatting hooks:
| Agent | Supported |
|---|---|
| GitHub PR Agent | β Yes |
| CLI PR Agent | β Yes |
| CLI Commit Agent | β Yes |
| CLI Repo Agent | β Yes |