This document outlines the coding standards for AudioBlock Backend. Following these standards helps maintain a consistent, readable, and maintainable codebase.
We use ESLint and Prettier to enforce code quality and formatting.
- Formatting: Prettier will automatically format code (e.g. 2 spaces, semi-colons, single quotes).
- Linting: ESLint is configured with strict TypeScript rules.
- No explicit
anytypes where possible. - No unused variables.
- Prefer
constoverlet. - Consistent returns in functions.
- No explicit
We enforce thresholds to prevent functions and files from becoming unmanageable:
- Max Cyclomatic Complexity: 15 per function.
- Max Lines per Function: 50 lines.
- Max Lines per File: 300 lines.
- Max Parameters: 5 per function.
If a function or file exceeds these limits, it should be refactored into smaller, testable units.
- Naming Conventions:
- Use
camelCasefor variables and function names. - Use
PascalCasefor classes, interfaces, and types. - Use
UPPER_SNAKE_CASEfor global constants.
- Use
- Type Safety: Ensure strong typing; avoid implicit
any. - Comments: Comment only to explain why something is done, not what it is doing (unless the logic is highly complex).