Skip to main content

✨ 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 issues
  • PRETTIER_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-staged or pre-commit hooks
  • Monorepos with strict .eslintrc or .prettierrc configs

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:

  1. After test files are generated
  2. Before validating them
  3. 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:

AgentSupported
GitHub PR Agentβœ… Yes
CLI PR Agentβœ… Yes
CLI Commit Agentβœ… Yes
CLI Repo Agentβœ… Yes