Coding Standards Ecc
Universal coding conventions for naming, readability, immutability, and code quality. Applies to TypeScript, JavaScript, React, and Node.js. Auto-invoked by the code-quality-reviewer during Stage 2 review. Source: everything-claude-code.
Coding Standards
Baseline cross-project coding conventions. This is the shared quality floor for all code produced by Bayes Ship implementers.
Naming
- Variables and functions: camelCase, descriptive.
marketSearchQuerynotq. - Functions: verb-noun pattern.
fetchMarketData()notmarket(). - Booleans:
is/has/shouldprefix.isAuthenticatednotflag. - Constants: UPPER_SNAKE_CASE.
MAX_RETRY_COUNT. - Types/interfaces: PascalCase.
InvoiceLineItem.
Immutability
Always use spread operator for updates. Never mutate directly.
// GOOD
const updated = { ...user, name: 'New Name' }
const newItems = [...items, newItem]
// BAD — never do this
user.name = 'New Name'
items.push(newItem)
Functions
- Single responsibility. One function does one thing.
- Maximum 20 lines. If longer, extract helpers.
- Pure functions preferred (no side effects).
- Always type parameters and return values in TypeScript.
Error handling
- Use typed errors, not string messages.
- Catch at the boundary (controller/route), not deep in business logic.
- Always log the original error before wrapping.
Imports
- Group: external libs → internal modules → types → styles.
- No circular imports. If two modules import each other, extract shared code.
- Prefer named exports over default exports (better refactoring).
Tests
- Test behavior, not implementation.
- Arrange-Act-Assert pattern.
- Descriptive test names:
"returns empty array when no invoices match filter"not"test filter".
Code review checklist (for Stage 2 reviewer)
- Naming follows conventions above?
- No direct mutation of objects or arrays?
- Functions under 20 lines?
- Error handling at boundaries?
- TypeScript types on all parameters and returns?
- Tests test behavior, not implementation details?