Open
Description
🧹 Setup Husky + Lint-staged for Git pre-commit code quality enforcement
📄 Description
We need to enforce code formatting and linting at the time of Git commits to maintain clean, consistent, and error-free code. This task will integrate Husky for Git hooks and Lint-staged for running linters and formatters only on staged files.
✅ Tasks
- Install
husky
and initialize Git hooks - Add
prepare
script inpackage.json
- Set up Husky
pre-commit
hook to runlint-staged
- Install and configure
lint-staged
inpackage.json
- Add lint and format rules for the following file types:
-
*.ts
,*.tsx
: Runeslint --fix
andprettier --write
-
*.json
,*.md
: Runprettier --write
-
- Create a test commit with intentional format issues to verify enforcement
- Update project README with basic usage and troubleshooting tips
📦 Commands to Run
# Step 1: Install Husky
npm install husky --save-dev
npx husky install
npm pkg set scripts.prepare="husky install"
# Step 2: Add pre-commit hook
npx husky add .husky/pre-commit "npx lint-staged"
# Step 3: Install lint-staged
npm install lint-staged --save-dev
Metadata
Metadata
Assignees
Labels
No labels