Skip to content

Commit 68bad05

Browse files
committed
chore: add pre-commit hooks with Husky + lint-staged
- Run Prettier and ESLint on staged files - Run typecheck and full test suite before commit - Update guidelines to require Prettier-formatted code - Add lint-staged config to package.json
1 parent d529bba commit 68bad05

File tree

5 files changed

+592
-5
lines changed

5 files changed

+592
-5
lines changed

.cursor/rules/project-infrastructure.mdc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ Note: `jiti` is required by ESLint 9 for loading TypeScript config files (`eslin
113113

114114
## Prettier Configuration
115115

116+
**All code must be Prettier-formatted.** This is enforced by pre-commit hooks and CI.
117+
116118
```json
117119
{
118120
"semi": false,
@@ -136,6 +138,45 @@ Note: `jiti` is required by ESLint 9 for loading TypeScript config files (`eslin
136138
- **120 character line width**: Modern screens, reduces line breaks in complex types
137139
- **LF line endings**: Unix-style, consistent across platforms
138140

141+
## Pre-commit Hooks
142+
143+
### Husky + lint-staged
144+
145+
The project uses Husky for Git hooks and lint-staged for running checks on staged files.
146+
147+
```bash
148+
# .husky/pre-commit
149+
npx lint-staged
150+
npm run typecheck
151+
npm test
152+
```
153+
154+
### lint-staged Configuration
155+
156+
```json
157+
{
158+
"lint-staged": {
159+
"*.{ts,tsx}": ["prettier --write", "eslint --fix"],
160+
"*.{json,md,yml,yaml}": ["prettier --write"]
161+
}
162+
}
163+
```
164+
165+
### What Runs on Commit
166+
167+
1. **lint-staged**: Format and lint staged files only
168+
2. **typecheck**: Full TypeScript type check
169+
3. **test**: Full test suite (Vitest)
170+
171+
### Required Dev Dependencies
172+
173+
```json
174+
{
175+
"husky": "^9.x",
176+
"lint-staged": "^16.x"
177+
}
178+
```
179+
139180
## Testing
140181

141182
### Test Framework: Vitest

.cursor/rules/typescript-conventions.mdc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ alwaysApply: false
66

77
# TypeScript Conventions
88

9+
## Code Quality
10+
11+
### Prettier Formatting
12+
13+
**All code must be Prettier-formatted before committing.** This is enforced by:
14+
- Pre-commit hooks (Husky + lint-staged)
15+
- CI checks (`npm run format:check`)
16+
17+
Run `npm run format` to format all files, or rely on the pre-commit hook to auto-format staged files.
18+
19+
### ESLint Compliance
20+
21+
All code must pass ESLint with zero errors. Warnings should be addressed when possible.
22+
923
## Imports
1024

1125
### Type-Only Imports

.husky/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
npx lint-staged
2+
npm run typecheck
3+
npm test

0 commit comments

Comments
 (0)