TypeScript Requirements
All new code must be written in TypeScript with proper types.TypeScript Configuration
Hiro CRM uses strict TypeScript settings:Type Safety Guidelines
Always define types for props and state
Always define types for props and state
Use existing types from types/
Use existing types from types/
Import types from the shared type definitions:
Avoid 'any' type
Avoid 'any' type
Use
unknown for truly dynamic data, then narrow the type:Type Supabase queries
Type Supabase queries
Use the generated Supabase types:
React Component Standards
Component Structure
Use functional components with hooks:Component Guidelines
- Functional components only — No class components
- Hooks for state — Use
useState,useEffect, custom hooks - Small, focused components — Each component should have a single responsibility
- Export named components — Avoid default exports for components
- Co-locate related code — Keep components, styles, and tests together
Styling Standards
Tailwind CSS
Use Tailwind CSS utility classes for all styling:Responsive Design
Use Tailwind’s responsive prefixes:Dark Mode
Support dark mode withdark: prefix:
Database & Data Fetching
Supabase Queries
All database queries must:- Use the Supabase client from
@/lib/supabase/clientor@/lib/supabase/server - Respect Row Level Security (RLS) policies
- Handle errors gracefully
Server Actions
Use Next.js Server Actions for data mutations:ESLint Configuration
Our ESLint setup extends Next.js defaults:Running the Linter
Commit Message Format
We follow Conventional Commits for clear, semantic commit history.Format
Types
| Type | Description | Example |
|---|---|---|
feat | New feature | feat: add loyalty tier upgrade notifications |
fix | Bug fix | fix: resolve reservation sync error |
docs | Documentation changes | docs: update API integration guide |
refactor | Code refactoring | refactor: simplify customer query logic |
test | Test additions/changes | test: add unit tests for RFM calculation |
chore | Maintenance tasks | chore: update dependencies |
style | Code style changes | style: format with Prettier |
perf | Performance improvements | perf: optimize campaign query |
Examples
Commit Best Practices
- Use imperative mood — “add feature” not “added feature”
- Be specific — Describe what changed and why
- Keep it concise — First line under 72 characters
- Reference issues — Include issue numbers:
fix: resolve #123
Code Review Guidelines
When reviewing pull requests:- Type safety — Ensure proper TypeScript usage
- Test coverage — New features should have tests
- Documentation — Update docs for new features
- Performance — Watch for unnecessary re-renders, N+1 queries
- Accessibility — Check for keyboard navigation, ARIA labels
- Security — Verify RLS policies, input validation
File Naming Conventions
- Components — PascalCase:
CustomerCard.tsx - Utilities — camelCase:
formatCurrency.ts - Hooks — camelCase with
useprefix:useCustomers.ts - Types — PascalCase:
Customer.ts - Server Actions — camelCase:
updateCustomer.ts
Next Steps
Testing Guide
Learn how to write and run tests
Development Setup
Set up your development environment
