Closed
Description
Overview
Implement pre-commit hooks to automatically run the project's lint and format commands before each commit. This will help maintain code quality and consistency throughout the codebase.
Implementation Plan
-
Install required dependencies:
pnpm add -D husky lint-staged
-
Add configuration to package.json:
"lint-staged": { "*.{js,jsx,ts,tsx}": [ "pnpm lint", "pnpm format" ] }
-
Initialize husky:
pnpm husky install
-
Add a prepare script to package.json to ensure husky is installed on npm install:
"scripts": { "prepare": "husky install" }
-
Create a pre-commit hook:
pnpm husky add .husky/pre-commit "pnpm lint-staged"
-
Add documentation in CONTRIBUTING.md about the pre-commit hooks
Benefits
- Ensures all committed code meets the project's style guidelines
- Prevents formatting inconsistencies
- Catches linting errors before they're committed
- Reduces the need for style-related code review comments
Additional Notes
- We should consider only running lint/format on staged files to improve performance
- We may want to make the hooks skippable with a flag for emergency situations
Metadata
Metadata
Assignees
Labels
No labels