This style guide provides guidelines for maintaining consistent, high-quality code and documentation across our project. By following these guidelines, we ensure better readability, maintainability, and collaboration among team members.
- Choose meaningful names for variables, functions, and classes that accurately describe their purpose or functionality.
- Avoid abbreviations or cryptic names that may confuse other developers.
- Use correct and consistent import names for components across the project.
- Example: Use 'SignIn' instead of 'UserButton' for a sign-in component.
- Use consistent indentation and formatting throughout the codebase.
- Follow established coding style guidelines for the programming language being used.
- Use appropriate imports from the correct packages (e.g., '@stackframe/stack').
- Organize components into separate files or modules for better code organization and maintainability.
- Provide clear and concise comments for complex code sections and functions.
- Explain the purpose and functionality of the code, not just restate what the code does.
- Ensure header names and content in documentation are accurate and consistent.
- Use appropriate heading levels to create a clear hierarchy of information.
- Write PR titles and bodies that directly address the documentation changes being made.
- Clearly explain the purpose and impact of the changes.
- Include links to relevant discussions in Discord or other communication channels.
- Indicate where review and agreement on changes have taken place.
- Maintain up-to-date and accurate code snippets in documentation.
- Test code snippets to ensure they work as intended.
- Add visual representations (images) alongside code examples when appropriate.
- Use proper image references in Markdown format.
- Example:
![Sign-in Component](../imgs/sign-in.png)
- Implement appropriate error handling and logging mechanisms throughout the codebase.
- Catch and handle exceptions gracefully to prevent application crashes.
- Log errors with sufficient detail to aid in debugging and troubleshooting.
- Identify and optimize critical sections of code for better performance.
- Use profiling tools to identify bottlenecks and areas for improvement.
- Consider factors such as time complexity, memory usage, and resource utilization.
- Adhere to best practices for secure coding to prevent common vulnerabilities.
- Implement proper input validation and sanitization.
- Use secure authentication and authorization mechanisms.
- Keep sensitive information, such as API keys and passwords, out of the codebase.
- Regularly update dependencies to address known security vulnerabilities.