Coding Conventions
Coding Conventions for GritivaCore#
This document outlines the critical coding conventions for the GritivaCore codebase. It is designed to ensure consistency, readability, and maintainability across our projects. Following these conventions will help developers avoid common pitfalls and improve collaboration.
Adhering to coding conventions is essential for maintaining a high-quality codebase. It enhances code readability, facilitates easier onboarding of new developers, and reduces the likelihood of bugs. By following established conventions, we can ensure that our code is understandable and maintainable.
General Guidelines#
Formatting#
- Use consistent indentation and spacing.
- Follow language-specific formatting tools (e.g.,
rufffor Python,prettierfor TypeScript).
Naming#
- Use
snake_casefor Python variables and functions. - Use
camelCasefor TypeScript variables and functions. - Use
PascalCasefor React components and Pydantic models.
Comments#
- Comments should explain why something is done, not what is done. The code itself should be clear enough to convey what it does.
Language-Specific Conventions#
JavaScript#
- Use TypeScript with strict settings.
- Follow ESLint rules and use
next/fontinstead of CSS@font-face. - Prefer functional components with hooks over class components.
Python#
- Use Python 3.12 with
rufffor formatting and linting, andmypyfor type checking. - Ensure all I/O operations are asynchronous; avoid synchronous I/O on the event loop.
- Use
asyncio.to_threadfor blocking calls. - Type hints are mandatory for public APIs and recommended for private helpers.
Java#
- Follow standard Java conventions and utilize tools for linting and formatting.
Common Pitfalls#
- Avoid swallowing exceptions silently; always log at WARNING level or higher if recovery is non-obvious.
- Ensure every
async deffunction returns within 5 seconds in steady state; document timeouts if they cannot.
By following these coding conventions, we can maintain a high standard of code quality within the GritivaCore codebase. Consistency in coding practices will lead to better collaboration and fewer bugs.
Critical Notes
Critical NotesEnsure to follow the specific guidelines for Python, TypeScript, and Go as outlined in the document. These conventions are tailored for the GritivaCore codebase and are not generic style guides.