Files
seal-use/.agents/rules/typescript-style.md
T

2.0 KiB

description, globs, trigger
description globs trigger
TypeScript and ESM coding conventions for seal-use codebase src/**/*.ts manual

TypeScript & ESM Conventions

When modifying or adding TypeScript files in src/:

  1. Module System & Import Extensions:

    • Use ES modules exclusively.
    • Local file imports MUST include explicit .js extensions (e.g. import { foo } from "./bar.js").
  2. Validation & Typing:

    • Validate external inputs, environment variables, and API responses with Zod or narrow TypeScript types.
    • Avoid any. Prefer precise domain types.
  3. Code Style:

    • 2-space indentation.
    • Double quotes (").
    • Omitted trailing semicolons where possible.
    • camelCase for functions/variables, PascalCase for classes/types/interfaces.
    • Kebab-case filenames (e.g. token-store.ts).
  4. Architecture:

    • Prefer small, cohesive domain functions over large generic utility files.
    • Place Seal business implementations and their colocated tests in the matching feature directory under src/domains/seal/, for example rules/recode.ts and rules/recode.test.ts. The domain root is reserved for api.ts, api.test.ts, types.ts, and capabilities.ts; do not add business files or old-path forwarding stubs there. See AGENTS.md for the feature layout.
  5. Frozen Utility Modules:

    • src/domains/seal/capabilities/helpers.ts is FROZEN: no new exports. It is the historical catch-all (~85 exports, re-exported into every capability's namespace via export *), and helpers.freeze.test.ts fails CI when it grows past its line/export ceiling.
    • Put new logic in a focused module beside the domain that owns it. Moving an existing export OUT of helpers.ts is encouraged — then lower the ceiling constants in the ratchet test.
    • Apply the same instinct to any other module you are tempted to treat as a scrap drawer: if the file's name is helpers/utils/common, it is already a sign the logic belongs somewhere more specific.