| name | lint-and-fix |
| description | Run ESLint (type-aware fixes and checks) then Trunk for formatting and remaining linters. Use when code quality checks fail, before submitting PRs, or to repair broken linting states. |
Lint and Fix Loop: ESLint + Trunk
Purpose
An autonomous loop for the agent to identify, fix, and verify linting and formatting violations. Run ESLint first (scoped when possible), then Trunk (pnpm format / pnpm lint). This matches the layered harness in root AGENTS.md.
Tool split
| Tool | Role |
|---|
pnpm format:eslint / pnpm lint:eslint | TypeScript-aware rules, import order, complexity, security plugin rules; --fix via format:eslint. Prefer a path after -- for fast feedback (see scope below). |
pnpm format / pnpm lint | Trunk: Prettier, ESLint again, Trivy, OSV-scanner, and other enabled linters. Do not add ESLint stylistic rules that duplicate Prettier. |
pnpm knip | Unused deps, exports, entrypoints — run when workspace-wide dependency or export surface may have changed. |
Trunk in CI also runs ESLint; direct lint:eslint gives faster scoped feedback and --fix before Trunk.
Scope convention
Scope ESLint to the smallest path that covers your edits (repository root as cwd):
- One package:
packages/<name>/src (or packages/<name> if you changed files outside src/)
- Several packages:
packages/ or omit the path
- Root config/tooling only: the file(s) you changed (e.g.
eslint.config.mjs) or omit the path
Examples:
pnpm lint:eslint -- packages/<name>/src
pnpm format:eslint -- eslint.config.mjs
Omit the path only when changes span multiple packages or repo-wide config.
See CONTRIBUTING.md for workspace commands and AGENTS.md for the recommended lint order. Package-specific PR checklists live under packages/*/CONTRIBUTING.md.
Loop logic
- Auto-fix (ESLint):
pnpm format:eslint -- <path> (omit <path> only for full-repo changes).
- Check (ESLint):
pnpm lint:eslint -- <path>.
- Fix: Apply minimum source edits for remaining ESLint errors.
- Repeat steps 2–3 until ESLint is clean (max 5 iterations).
- Format (Trunk):
pnpm format.
- Check (Trunk):
pnpm lint.
- Repeat steps 5–6 if needed.
- Knip (optional):
pnpm knip when dependencies, exports, or entrypoints may have changed.
Termination criteria
- No errors from
pnpm lint:eslint (for the chosen scope) and no errors from pnpm lint.
- Reached max iteration limit (default: 5) for the ESLint sub-loop or the Trunk sub-loop.
Examples
Scenario: Scoped package work
pnpm format:eslint -- packages/<name>/src
pnpm lint:eslint -- packages/<name>/src — fix remaining issues or re-run format:eslint.
pnpm format then pnpm lint when Trunk/Knip alignment is needed.
Scenario: Repo-wide or multi-package changes
pnpm format:eslint (no path) or pnpm format:eslint -- packages/
pnpm lint:eslint with the same scope.
pnpm format then pnpm lint; run pnpm knip if dependencies or exports changed.
Scenario: Format-only drift after ESLint is clean
pnpm lint reports Prettier or other Trunk issues.
- Run
pnpm format.
- Re-run
pnpm lint.
Resources