d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
91 lines
2.5 KiB
Markdown
91 lines
2.5 KiB
Markdown
# Coding Style
|
|
|
|
## Immutability (CRITICAL)
|
|
|
|
ALWAYS create new objects, NEVER mutate existing ones:
|
|
|
|
```
|
|
// Pseudocode
|
|
WRONG: modify(original, field, value) → changes original in-place
|
|
CORRECT: update(original, field, value) → returns new copy with change
|
|
```
|
|
|
|
Rationale: Immutable data prevents hidden side effects, makes debugging easier, and enables safe concurrency.
|
|
|
|
## Core Principles
|
|
|
|
### KISS (Keep It Simple)
|
|
|
|
- Prefer the simplest solution that actually works
|
|
- Avoid premature optimization
|
|
- Optimize for clarity over cleverness
|
|
|
|
### DRY (Don't Repeat Yourself)
|
|
|
|
- Extract repeated logic into shared functions or utilities
|
|
- Avoid copy-paste implementation drift
|
|
- Introduce abstractions when repetition is real, not speculative
|
|
|
|
### YAGNI (You Aren't Gonna Need It)
|
|
|
|
- Do not build features or abstractions before they are needed
|
|
- Avoid speculative generality
|
|
- Start simple, then refactor when the pressure is real
|
|
|
|
## File Organization
|
|
|
|
MANY SMALL FILES > FEW LARGE FILES:
|
|
- High cohesion, low coupling
|
|
- 200-400 lines typical, 800 max
|
|
- Extract utilities from large modules
|
|
- Organize by feature/domain, not by type
|
|
|
|
## Error Handling
|
|
|
|
ALWAYS handle errors comprehensively:
|
|
- Handle errors explicitly at every level
|
|
- Provide user-friendly error messages in UI-facing code
|
|
- Log detailed error context on the server side
|
|
- Never silently swallow errors
|
|
|
|
## Input Validation
|
|
|
|
ALWAYS validate at system boundaries:
|
|
- Validate all user input before processing
|
|
- Use schema-based validation where available
|
|
- Fail fast with clear error messages
|
|
- Never trust external data (API responses, user input, file content)
|
|
|
|
## Naming Conventions
|
|
|
|
- Variables and functions: `camelCase` with descriptive names
|
|
- Booleans: prefer `is`, `has`, `should`, or `can` prefixes
|
|
- Interfaces, types, and components: `PascalCase`
|
|
- Constants: `UPPER_SNAKE_CASE`
|
|
- Custom hooks: `camelCase` with a `use` prefix
|
|
|
|
## Code Smells to Avoid
|
|
|
|
### Deep Nesting
|
|
|
|
Prefer early returns over nested conditionals once the logic starts stacking.
|
|
|
|
### Magic Numbers
|
|
|
|
Use named constants for meaningful thresholds, delays, and limits.
|
|
|
|
### Long Functions
|
|
|
|
Split large functions into focused pieces with clear responsibilities.
|
|
|
|
## Code Quality Checklist
|
|
|
|
Before marking work complete:
|
|
- [ ] Code is readable and well-named
|
|
- [ ] Functions are small (<50 lines)
|
|
- [ ] Files are focused (<800 lines)
|
|
- [ ] No deep nesting (>4 levels)
|
|
- [ ] Proper error handling
|
|
- [ ] No hardcoded values (use constants or config)
|
|
- [ ] No mutation (immutable patterns used)
|