pm4ai

TypeScript

TypeScript code style conventions

Code Style

  • Only arrow functions — no function declarations
  • All exports at end of file
  • .tsx with single component → export default; utilities/backend → named exports
  • for loops instead of reduce() or forEach()
  • Exhaustive switch with default: 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 ~/components when reused
  • Explicit imports from exact file paths — no barrel index.ts in 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
  • interface over type when possible
  • Object/interface properties sorted alphabetically
  • No import as aliases — rename variables to avoid conflicts
  • No trailing commas in single-line, trailing commas in multi-line
  • import type for type-only imports

On this page