π Quick Reference - Development Tools
Command
What It Does
When to Use
npm test
Run tests in watch mode
During development
npm run validate
Run ALL checks at once
Before pushing
npm run lint:fix
Auto-fix linting issues
When you have lint errors
npm run format
Format all code
To clean up formatting
npm run type-check
Check TypeScript types
To find type errors
1. Write code
β
2. npm test (write/run tests)
β
3. git add .
β
4. git commit -m "message"
β (hooks run automatically)
5. git push
β (CI/CD runs on GitHub)
6. β
Done!
On git commit (automatic):
β
ESLint fix on changed files
β
Prettier format on changed files
On git push (GitHub Actions):
β
Type checking
β
Linting (strict)
β
Format checking
β
All tests
β
Build verification
β
Security audit
π¦ Using Zod Validation
import { UserSchema , validateSchema } from './utils/schemas' ;
// Validate API response
const result = validateSchema ( UserSchema , apiData ) ;
if ( result . success ) {
// Type-safe data
console . log ( result . data . email ) ;
} else {
// Handle errors
console . error ( result . error ) ;
}
import { describe , it , expect } from 'vitest' ;
describe ( 'My Feature' , ( ) => {
it ( 'should work correctly' , ( ) => {
expect ( 1 + 1 ) . toBe ( 2 ) ;
} ) ;
} ) ;
Problem
Solution
Lint errors blocking commit
Run npm run lint:fix
Type errors
Run npm run type-check to see all
Tests failing
Run npm test and fix the tests
Format issues
Run npm run format
CI/CD failing
Run npm run validate locally
.eslintrc.cjs - ESLint rules
.prettierrc - Prettier config
utils/schemas.ts - Zod schemas
tests/ - Test files
.github/workflows/ci.yml - CI/CD pipeline
Keep this file handy for quick reference! π