Tools
- Husky connects the workflow to Git’s pre-commit hook
- ESLint identifies code-quality problems and potential bugs.
- Prettier applies consistent formatting and import ordering.
Pre-commit workflow
Installing the project dependencies runs theprepare script, which configures
Husky. When you commit a change, the pre-commit hook runs:
lint-staged selects commands based on each staged file’s extension.
ESLint and Prettier update the staged files when they can fix an issue
automatically.
lint-staged includes those updates in the commit. If a command
fails, Git stops the commit so you can correct the remaining problem.
The pre-commit workflow checks staged files only. It does not run the
TypeScript compiler, tests, or a complete repository lint.
Run checks manually
Lint the complete codebase:Configuration files
.husky/pre-commitstarts the pre-commit workflow.package.jsonmaps staged file types to linting and formatting commands.eslint.config.mjsconfigures ESLint, TypeScript, and Next.js rules..prettierrcconfigures formatting and import ordering.
Pre-commit checks provide fast local feedback. Run the complete lint,
type-check, test, and build checks in CI before merging a change.