Overview
Mizen follows strict code style guidelines to maintain consistency and quality across the codebase. This document outlines the conventions and tools used in the project.TypeScript Conventions
Type Safety
- Strict Types: Always use explicit TypeScript types
- No Any: Avoid using
anytype - define proper interfaces instead - Interface Definitions: Define interfaces for complex data structures
Unused Variables
The project uses ESLint rules for handling unused variables:- Prefix unused variables with underscore (
_) - Applies to function arguments, variables, and caught errors
React Conventions
Component Structure
- Functional Components Only: Use functional components with hooks
- No Class Components: Class components are not used in this project
- Hooks: Leverage React hooks for state management and side effects
Error Handling
- Error Boundaries: Use Error Boundaries for async operations and error handling in UI
- Wrap components that perform async operations or may throw errors
Next.js Conventions
- App Router: Use Next.js App Router for routing and project structure
- Follow Next.js best practices for file-based routing
- Organize routes according to the App Router structure
Styling Guidelines
CSS Architecture
- CSS Modules + Tailwind: Use combination of CSS Modules and Tailwind CSS
- Global Styles: Reference
src/app/globals.cssfor design tokens and base styles - Design Tokens: Place shared tokens and styles in
globals.css
Component Styling
Dropdown & Popover Components
Usemodal={false} for dropdowns and popovers to prevent:
- Scroll lock issues
- Unexpected layout shifts
Icons
- Solar Icons Only: Use Solar Icons exclusively throughout the project
- Prefer Filled: Use filled variants unless specifically requested otherwise
- Reference: Solar Icons Documentation
Code Quality Tools
ESLint Configuration
The project uses Next.js ESLint configuration with custom rules:Prettier Configuration
Code formatting is handled by Prettier with the following settings:- Use single quotes for strings
- Default Prettier settings for other formatting rules
Running Linters
Code Comments
When to Comment
- Add clear comments that explain what and why
- Focus on the reasoning behind implementation choices
- Document non-obvious logic or workarounds
What Not to Comment
- Avoid comments that simply restate what the code does
- Don’t comment obvious code
- Let the code be self-documenting where possible
Git Workflow
Pre-commit Hooks
The project uses Husky for Git hooks:- Automatic linting before commits
- Ensures code quality standards are met
Commit Guidelines
- Write descriptive commit messages
- Explain both what changed and why
- Reference issue numbers when applicable
Risk Management
For Large or Risky Changes:
- Signal with clear indicators:
- ⚠️ LARGE CHANGE
- 🛑 HIGH RISK
- Explain the impact and reasoning
- Wait for confirmation before applying changes
- Use smaller, incremental changes when possible
Testing
After making changes:- Test locally using
npm run dev - Run production build:
npm run build - Verify no linting errors:
npm run lint - Test affected features thoroughly
- Check responsive design on different screen sizes
Summary Checklist
Before submitting code, ensure:- ✅ TypeScript strict types used (no
any) - ✅ Functional React components with hooks
- ✅ Error boundaries for async operations
- ✅ Solar Icons used exclusively
- ✅ CSS Modules + Tailwind for styling
- ✅ Clear comments explaining “what” and “why”
- ✅ Linting passes (
npm run lint) - ✅ Documentation updated if needed
- ✅ Changes tested in development environment