Coding Standards
The technical rules and conventions for the VeriWorkly codebase.
Coding Standards
To maintain a high-quality, professional codebase, we follow strict standards for TypeScript, React, and CSS. Consistency is key to a maintainable monorepo.
TypeScript Conventions
- Strict Type Safety:
strict: trueis mandatory. Avoid theanytype at all costs. Useunknownor precise interfaces. - Validation: Every external data source (API responses, environment variables, form inputs) must be validated using Zod schemas.
- File Naming: Use
kebab-casefor file names (e.g.,resume-store.ts) andPascalCasefor React components (e.g.,Button.tsx). - Interfaces vs Types: Prefer
interfacefor public APIs andtypefor unions, intersections, or internal logic.
React & Frontend
- Functional Components: Use functional components with hooks. Avoid class-based components.
- Memoization: The resume editor is a complex, high-performance interface. Use
React.memo,useMemo, anduseCallbackto prevent unnecessary re-renders in the sidebar and previewer. - State Management:
- Use Zustand for global application state (Resumes, UI state).
- Use React Hook Form for form state.
- Use Native React State for local, ephemeral UI state.
- Hooks: Abstract complex logic into custom hooks (e.g.,
useExport,useTemplate).
Styling (Tailwind CSS 4)
- Utility-First: Use Tailwind classes for all styling. Avoid custom CSS files unless absolutely necessary (e.g., specific print media queries).
- Design Tokens: All colors, fonts, and spacing should be derived from our shared
@veriworkly/uidesign system. Reference them using Tailwind variables rather than hardcoded hex codes. - Responsive Design: We follow a mobile-first approach. Ensure all UI elements work perfectly on screen sizes from 320px to 4K.
Backend & API
- Service Layer: Keep Express controllers thin. Business logic should reside in dedicated services in
apps/server/src/services/. - Error Handling: Use the centralized error handling middleware. Always return consistent JSON error objects.
- Prisma: Write clean, optimized queries. Use
includeandselectto minimize over-fetching data.
Testing Requirements
- Unit Tests: Write tests for pure utility functions and business logic services using Vitest.
- Integration Tests: Verify that components work together with the state store.
- E2E Tests: Use Playwright to test critical paths like user login, resume creation, and PDF export.
Automated Checks
Before submitting a Pull Request, ensure the following commands pass:
# Run linting checks
npm run lint
# Automatically fix formatting issues
npm run format:write
# Run all test suites
npm test