Skip to content

Latest commit

 

History

History
46 lines (39 loc) Β· 2.05 KB

File metadata and controls

46 lines (39 loc) Β· 2.05 KB

Code Style Guidelines

1. Naming Conventions

  • Use PascalCase for component names
  • Use camelCase for variables and functions
  • Use consistent naming conventions across the project

2. Code Structure

  • Use TypeScript for type safety and improved developer experience
  • Use JSX syntax for React components
  • Prefer functional components with hooks over class components
  • Implement a modular file structure, grouping related components and exports in specific folders
  • Use arrow functions for component definitions
  • Organize imports at the top of files
  • Use optional chaining (?.) for potentially undefined properties
  • Prefer const over let for variable declarations
  • Use default parameter values and optional parameters where appropriate
  • Use interface or type aliases for complex object structures
  • Use explicit return types for functions and components

3. Documentation

  • Use JSDoc-style comments for function and component documentation
  • Provide detailed component descriptions, including parameter descriptions and example usage
  • Use markdown formatting for documentation, including proper syntax for code blocks
  • Use descriptive and concise titles for documentation sections
  • Use consistent formatting for component documentation

4. Error Handling

  • Implement proper error handling and type checking
  • Use async/await for asynchronous operations

5. Performance

  • Optimize component rendering using React performance optimization techniques
  • Follow a modular approach by breaking down functionality into smaller, reusable components

6. Security

  • Use crypto.timingSafeEqual for secure string comparison
  • Avoid using dangerouslySetInnerHTML to prevent XSS vulnerabilities
  • Avoid using eval for security reasons
  • Use hardcoded string literals when calling require to prevent potential vulnerabilities
  • Use safe alternatives to manipulate DOM elements instead of innerHTML

7. Best Practices

  • Use proper indentation and spacing for improved readability
  • Provide descriptive comments for functions and components
  • Utilize TypeScript's type annotations