TypeScript Best Practices
Type Safety
Orquestra uses TypeScript in strict mode for maximum type safety. Always provide explicit types:any - use unknown for truly unknown types:
Shared Types
Define shared types inpackages/shared/src/types.ts for cross-package usage:
Function Return Types
Always specify return types for functions:Null Safety
Handle null/undefined explicitly:TypeScript Configuration
Key settings fromtsconfig.json:
ESLint Configuration
Rules
Orquestra uses ESLint with TypeScript support. Key rules from.eslintrc.json:
Running ESLint
Common Patterns
Unused variables:Prettier Formatting
Configuration
Orquestra uses Prettier for consistent code formatting. Settings from.prettierrc:
Formatting Rules
Use single quotes:Running Prettier
Commit Message Format
Orquestra follows the Conventional Commits specification for clear, structured commit history.Format
Types
- feat: New feature
- fix: Bug fix
- docs: Documentation changes
- style: Code style changes (formatting, no logic change)
- refactor: Code refactoring (no functional change)
- perf: Performance improvements
- test: Adding or updating tests
- chore: Maintenance tasks (dependencies, build, etc.)
- ci: CI/CD changes
Examples
Simple feature:Best Practices
Do:- Use imperative mood (“add” not “added” or “adds”)
- Keep subject line under 72 characters
- Capitalize the subject line
- Don’t end subject with a period
- Separate subject from body with blank line
- Wrap body at 72 characters
- Use body to explain what and why, not how
- Reference issues and PRs in footer
- Make vague commits like “fix stuff” or “update”
- Mix multiple unrelated changes in one commit
- Commit commented-out code
- Include sensitive information
Commit Examples
Good commits:Code Documentation
JSDoc Comments
Document public APIs and complex functions:Inline Comments
Explain why, not what:Complex Logic
Break down complex operations:Pre-commit Checklist
Before committing, ensure:- Code follows TypeScript best practices
- All ESLint warnings are resolved
- Code is formatted with Prettier
- Type checking passes:
bun run type-check - Tests pass:
bun test - Commit message follows Conventional Commits
- No console.log or debugger statements
- No commented-out code
- Documentation updated if needed
Editor Setup
VS Code
Recommended extensions:- ESLint
- Prettier
- TypeScript and JavaScript Language Features
.vscode/settings.json:
WebStorm / IntelliJ IDEA
- Enable Prettier:
Settings → Languages & Frameworks → JavaScript → Prettier - Enable ESLint:
Settings → Languages & Frameworks → JavaScript → Code Quality Tools → ESLint - Format on save:
Settings → Tools → Actions on Save
Following these code style standards ensures a consistent, maintainable, and high-quality codebase.