How It Works
When you commit changes, Husky triggers a pre-commit hook that runs lint-staged. The configuration runs linters on the entire project to ensure project-wide code quality.The pre-commit hook is automatically installed when you run
pnpm install
via the prepare
script.Project-wide Validation: Ship intentionally runs linters on ALL project files (using
.
), not just staged files. This defensive approach ensures that if someone bypassed hooks with --no-verify
, the next commit will auto-fix those issues and prevent blocking other team members.Configuration
API
.ts
file is staged, runs on entire project:
- ESLint - Auto-fixes all
.ts
files (note the.
) - TypeScript - Type checks all files
- Prettier - Formats all files (note the
.
)
Web
Packages
All shared packages (schemas
, mailer
, app-types
, etc.) have similar lint-staged configurations tailored to their file types.
Customization
Modify Linters
Editlint-staged
in your package.json
:
Run on Staged Files Only (Alternative)
If you prefer to only lint staged files instead of the entire project:Linting only staged files means errors in other parts of the codebase (e.g., from
--no-verify
commits) won’t be caught or fixed until those files are modified.Skip Hooks Temporarily
Only skip hooks when absolutely necessary, as they help maintain code quality.
Troubleshooting
Hook Not Running
If pre-commit hooks don’t run:- Ensure Husky is installed:
-
Check if
.husky/pre-commit
exists in your project root - Verify Git hooks path:
Linter Errors Blocking Commits
If linters fail:- Review the error output
- Fix the issues manually or let auto-fix handle them
- Stage the fixed files:
git add .
- Commit again
Best Practices
- Never use
--no-verify
- It bypasses quality checks and can break the build for teammates - Fix issues early - Don’t accumulate linting errors across the codebase
- Keep configs in sync - Ensure lint-staged matches your editor settings