Skip to content

Latest commit

 

History

History
67 lines (53 loc) · 2.61 KB

style.md

File metadata and controls

67 lines (53 loc) · 2.61 KB

Code Style Guidelines

1. Naming Conventions

  • Use PascalCase for component names
  • Use camelCase for function, variable, and parameter names
  • Use descriptive and semantic naming for all identifiers

2. Code Structure

  • Organize code using a Next.js framework structure with app/ directory for pages/components
  • Maintain separate directories for components, lib, public assets, etc.
  • Keep configuration files (e.g., tailwind.config.ts, next.config.js) at the root level
  • Use TypeScript throughout the codebase with type definitions in separate .d.ts files
  • Implement functional components with hooks in React
  • Use .tsx extension for component files
  • Split components into smaller, reusable pieces
  • Extract utility functions to separate files

3. Documentation

  • Include inline comments to explain complex logic or configurations
  • Maintain a comprehensive README file with project information and setup instructions
  • Keep documentation up-to-date, including installation instructions and repository URLs

4. Error Handling

  • Implement consistent error handling and logging throughout the application
  • Validate user inputs and API responses to prevent unexpected errors

5. Performance

  • Utilize Next.js built-in optimizations
  • Implement code splitting and lazy loading where appropriate
  • Optimize API integrations and data fetching

6. Security

  • Use environment variables for sensitive information like API keys
  • Implement proper input validation and sanitization
  • Follow security best practices for authentication and authorization

7. Styling

  • Use Tailwind CSS for styling with a custom configuration
  • Maintain global styles in a separate globals.css file

8. State Management

  • Use React context for global state management
  • Utilize useState hook for local component state

9. Version Control

  • Follow semantic commit message conventions
  • Maintain a .gitignore file to exclude unnecessary files from version control

10. Build and Dependency Management

  • Use npm or yarn for package management
  • Keep dependencies up-to-date and resolve conflicts promptly

11. Testing

  • Implement unit tests for critical components and functions
  • Aim for good test coverage across the application

12. Accessibility

  • Use semantic HTML elements
  • Implement ARIA attributes where necessary to enhance accessibility

13. Environment Configuration

  • Maintain separate configurations for development and production environments
  • Use a .env.example file to document required environment variables

14. Docker (if applicable)

  • Follow Docker best practices for containerization
  • Optimize Docker images for size and security