This project includes comprehensive development tooling to ensure code quality, catch bugs early, and maintain consistent code style.
Purpose: Catch code issues and enforce coding standards
- Configuration:
.eslintrc.cjs - Plugins: TypeScript, React, React Hooks, Prettier
- Run manually:
npm run lint - Auto-fix issues:
npm run lint:fix
Purpose: Catch type errors before runtime
- Run:
npm run type-check - Configuration:
tsconfig.json - Runs on: Pre-commit, CI/CD pipeline
Purpose: Automatic code formatting
- Configuration:
.prettierrc - Format all files:
npm run format - Check formatting:
npm run format:check - Runs on: Pre-commit, CI/CD pipeline
Purpose: Validate data at runtime to catch schema mismatches
- Schema definitions:
utils/schemas.ts - Usage example:
import { UserSchema, validateSchema } from './utils/schemas';
const result = validateSchema(UserSchema, userData);
if (result.success) {
// Use validated data
console.log(result.data);
} else {
// Handle validation errors
console.error(result.error);
}Purpose: Unit and integration testing
- Configuration:
vitest.config.ts - Test files:
tests/*.test.ts(x) - Run tests:
npm test - Run tests once:
npm run test:run - Test UI:
npm run test:ui
Purpose: Pre-commit hooks to ensure quality before committing
- Configuration:
.husky/pre-commitandlint-stagedinpackage.json - Automatically runs on
git commit:- ESLint fix on
.ts,.tsx,.js,.jsxfiles - Prettier format on all staged files
- ESLint fix on
Purpose: Automated testing and deployment pipeline
- Configuration:
.github/workflows/ci.yml - Runs on: Push and Pull Requests
- Checks:
- Type checking
- Linting
- Formatting
- Tests
- Build
- Security audit
| Script | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run type-check |
Run TypeScript type checking |
npm run lint |
Run ESLint (fail on warnings) |
npm run lint:fix |
Fix ESLint issues automatically |
npm run format |
Format all files with Prettier |
npm run format:check |
Check if files are formatted |
npm test |
Run tests in watch mode |
npm run test:run |
Run tests once |
npm run test:ui |
Open Vitest UI |
npm run validate |
Run all checks (type-check + lint + format + test) |
- Write your code
- Run tests:
npm test - Commit your changes - hooks will auto-format and lint
- If hooks fail, fix the issues and commit again
To run all quality checks at once:
npm run validateThis runs:
- Type checking
- Linting
- Format checking
- All tests
When you push code or create a PR:
- ✅ Type checking runs
- ✅ Linting runs
- ✅ Format checking runs
- ✅ All tests run
- ✅ Build verification
- ✅ Security audit
If any check fails, the pipeline fails and you'll be notified.
import { describe, it, expect } from 'vitest';
import { validateSchema, UserSchema } from '../utils/schemas';
describe('User validation', () => {
it('should validate correct user', () => {
const result = validateSchema(UserSchema, {
_id: '123',
email: 'test@example.com',
plan: 'free',
isPro: false,
});
expect(result.success).toBe(true);
});
});import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import MyComponent from '../components/MyComponent';
describe('MyComponent', () => {
it('should render correctly', () => {
render(<MyComponent />);
expect(screen.getByText('Hello')).toBeInTheDocument();
});
});- Check
.eslintrc.cjsfor rules - Run
npm run lint:fixto auto-fix - Disable specific rules with
// eslint-disable-next-line rule-name
- Run
npm run type-checkto see all errors - Check
tsconfig.jsonfor compiler options - Use
@ts-expect-errorfor known issues (with comment)
- Prettier overrides ESLint formatting rules
- Run
npm run formatto fix - Configure
.prettierrcif needed
- Run
npm testfor watch mode - Check
tests/setup.tsfor global test config - Use
npm run test:uifor visual debugging
| File | Purpose |
|---|---|
.eslintrc.cjs |
ESLint configuration |
.prettierrc |
Prettier formatting rules |
.prettierignore |
Files to ignore for formatting |
vitest.config.ts |
Vitest test configuration |
tsconfig.json |
TypeScript compiler options |
.husky/pre-commit |
Pre-commit hook script |
.github/workflows/ci.yml |
GitHub Actions CI/CD pipeline |
utils/schemas.ts |
Zod schema definitions |
- Always validate external data with Zod schemas
- Write tests for critical functionality
- Run
npm run validatebefore pushing - Fix linting errors immediately - don't accumulate tech debt
- Keep tests simple and focused
- Use type-safe code - avoid
anywhen possible - Format code before committing (done automatically)
- Add more Zod schemas for API responses
- Increase test coverage
- Add E2E tests with Playwright/Cypress
- Configure deployment in CI/CD pipeline
- Add code coverage reporting
- Set up visual regression testing
Note: All these tools run automatically on commit and push, ensuring code quality at every stage!