TypeScript
TypeScript code style conventions
Code Style
- Only arrow functions — no
functiondeclarations - All exports at end of file
.tsxwith single component →export default; utilities/backend → named exportsforloops instead ofreduce()orforEach()- Exhaustive
switchwithdefault: never catch (error)enforced by oxlint — name state vars descriptively to avoid shadow (chatError,formError)- Short map callback names:
t,m,i - Max 3 positional args — use destructured object for 4+
- Co-locate components with their page; only move to
~/componentswhen reused - Explicit imports from exact file paths — no barrel
index.tsin app code (library packages use barrels for their public API) - Prefer existing libraries over new dependencies
Formatting
- Single quotes, no semicolons
- No empty lines between statements
node:prefix for Node.js builtins (import { join } from 'node:path')- Imports sorted alphabetically by source
interfaceovertypewhen possible- Object/interface properties sorted alphabetically
- No
import asaliases — rename variables to avoid conflicts - No trailing commas in single-line, trailing commas in multi-line
import typefor type-only imports