This document outlines the development workflow, pre-commit checks, and best practices for maintaining code quality.
We use a comprehensive pre-commit system to ensure code quality before any code is committed or pushed.
When you commit code, the following checks run automatically:
-
Lint-staged: Runs on staged files only
- ESLint with auto-fix
- Prettier formatting
- Auto-adds fixed files
-
TypeScript Type Checking: Ensures no type errors
-
ESLint: Checks all files for linting issues
-
Prettier Check: Ensures consistent formatting
-
Build Check: Ensures the project builds successfully
When you push code, additional checks run:
- Security Audit: Checks for known vulnerabilities
- Final Build Check: Ensures everything builds correctly
- Uncommitted Changes Warning: Alerts about uncommitted changes
We use Conventional Commits format:
<type>(<scope>): <description>
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasksperf: Performance improvementsci: CI/CD changesbuild: Build system changesrevert: Reverting previous commits
feat: add wallet connection feature
fix(wallet): resolve persistence issue
docs: update README with setup instructions
style: format code with prettier
refactor(components): improve wallet button
chore: update dependenciesnpm run dev # Start development server
npm run build # Build for production
npm run start # Start production servernpm run lint # Run ESLint
npm run lint:fix # Run ESLint with auto-fix
npm run type-check # Run TypeScript type checking
npm run format # Format code with Prettier
npm run format:check # Check formatting without changing filesnpm run prepare # Install Husky hooks- Next.js recommended rules
- TypeScript support
- Prettier integration
- Custom rules for code quality
- Single quotes
- 80 character line width
- 2 space indentation
- Trailing commas
- JSX single quotes
- Strict type checking
- Next.js optimizations
- Path mapping for imports
If the pre-commit hook fails:
- TypeScript Errors: Fix type errors in your code
- ESLint Errors: Run
npm run lint:fixto auto-fix issues - Formatting Issues: Run
npm run formatto fix formatting - Build Errors: Fix any build errors in your code
git commit --no-verify -m "emergency: bypass hooks"
git push --no-verifyYou can run checks manually:
# Check everything before committing
npm run type-check
npm run lint
npm run format:check
npm run buildBefore committing code, ensure:
- Code follows TypeScript best practices
- No ESLint errors or warnings
- Code is properly formatted
- Project builds successfully
- Commit message follows conventional format
- No console.log statements in production code
- No
anytypes (use proper TypeScript types) - React hooks dependencies are correct
- Use strict typing, avoid
any - Define proper interfaces for props and state
- Use type guards when necessary
- Leverage TypeScript's built-in utility types
- Use functional components with hooks
- Follow React hooks rules
- Use proper dependency arrays in useEffect
- Avoid prop drilling, use context when needed
- Use meaningful variable and function names
- Keep functions small and focused
- Add JSDoc comments for complex functions
- Use consistent import/export patterns
- Use React.memo for expensive components
- Optimize re-renders with useMemo and useCallback
- Lazy load components when appropriate
- Use proper key props in lists
- Check the error messages in the terminal
- Run individual checks to isolate the issue
- Check the configuration files for syntax errors
- Ensure all dependencies are installed
- Check
tsconfig.jsonfor proper configuration - Ensure all imports are correct
- Check for missing type definitions
- Use TypeScript's strict mode features
- Check
.eslint.config.mjsfor configuration - Ensure all plugins are installed
- Check for conflicting rules
- Use
--fixflag to auto-fix issues