Skip to content

Commit 9451ff2

Browse files
mkreymanclaude
andcommitted
docs: Add pre-commit hooks setup documentation
Comprehensive guide for the new quality assurance pre-commit hooks: - Explains all 5 quality checks (build, type-check, lint, format, test) - Setup instructions for new contributors - Troubleshooting guide for common failures - Benefits and configuration file references 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent e003f65 commit 9451ff2

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

PRE_COMMIT_SETUP.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Pre-Commit Quality Hooks
2+
3+
This repository uses comprehensive pre-commit hooks to ensure code quality and prevent broken commits.
4+
5+
## What Gets Checked
6+
7+
Every commit automatically runs:
8+
9+
1. **🏗️ Build Compilation** - `npm run build`
10+
11+
- Ensures TypeScript compiles without errors
12+
- Verifies all imports and exports are valid
13+
14+
2. **🔍 Type Checking** - `npm run type-check`
15+
16+
- Runs TypeScript compiler in no-emit mode
17+
- Catches type errors before they reach the repository
18+
19+
3. **📝 Code Linting** - `npm run lint`
20+
21+
- ESLint checks for code style violations
22+
- Enforces consistent coding standards
23+
24+
4. **✨ Code Formatting** - `prettier --write` (via lint-staged)
25+
26+
- Automatically formats staged files
27+
- Ensures consistent code style across the project
28+
29+
5. **🧪 Test Suite** - `npm test`
30+
- Runs all 1087 tests to ensure functionality
31+
- Prevents broken code from entering the repository
32+
33+
## Setup
34+
35+
Pre-commit hooks are automatically installed when you run:
36+
37+
```bash
38+
npm install
39+
```
40+
41+
The hooks are managed by [Husky](https://typicode.github.io/husky/) and [lint-staged](https://github.com/okonet/lint-staged).
42+
43+
## Manual Quality Check
44+
45+
You can run all quality checks manually:
46+
47+
```bash
48+
npm run check-all
49+
```
50+
51+
This runs the same checks as the pre-commit hook without committing.
52+
53+
## If Hooks Fail
54+
55+
When pre-commit hooks fail:
56+
57+
1. **Fix the issues** reported by the tools
58+
2. **Stage your fixes** with `git add`
59+
3. **Retry the commit**
60+
61+
Common failures:
62+
63+
- **Build errors**: Fix TypeScript compilation issues
64+
- **Test failures**: Fix broken tests before committing
65+
- **Lint errors**: Run `npm run lint:fix` to auto-fix style issues
66+
- **Type errors**: Fix TypeScript type issues
67+
68+
## Benefits
69+
70+
**Prevents broken builds** from reaching the repository
71+
**Ensures all tests pass** before any commit
72+
**Maintains consistent code style** across the team
73+
**Catches errors early** in the development process
74+
**Improves code quality** and reduces bugs
75+
76+
## Configuration Files
77+
78+
- `.husky/pre-commit` - Main pre-commit hook script
79+
- `.lintstagedrc.json` - Lint-staged configuration for staged files
80+
- `package.json` - Scripts and dependencies
81+
82+
This ensures that **every commit maintains production-quality standards** and prevents the QA failures that previously allowed broken code to be committed.

0 commit comments

Comments
 (0)