--- description: "TypeScript and ESM coding conventions for hose-use codebase" globs: "src/**/*.ts" trigger: "manual" --- # TypeScript & ESM Conventions When modifying or adding TypeScript files in `src/`: 1. **Module System & Import Extensions**: - Use ES modules exclusively (`"type": "module"` in `package.json`). - Local file imports MUST include explicit `.js` extensions (e.g. `import { getGlobalDb } from "../db/connection.js"`). - Do NOT omit the `.js` extension, or runtime Node/Bun ESM resolution will fail. 2. **Validation & Typing**: - Validate external inputs, environment variables, and external HTTP/JSON responses using Zod schemas or strictly typed models. - Avoid `any`. Prefer precise domain types defined in `src/domains/*/types.ts` or `src/types.ts`. - Never suppress type errors with `// @ts-ignore`; resolve type discrepancies cleanly. 3. **Code Style & Formatting**: - 2-space indentation. - Double quotes (`"`). - `camelCase` for functions and variables, `PascalCase` for classes, types, and interfaces. - Kebab-case filenames (e.g. `query-options.ts`, `task-service.ts`). 4. **Architecture & Separation of Concerns**: - `src/core/`: Database (SQLite), HTTP client factory, encryption, global configuration, logger. - `src/domains/`: Domain services, models, and business logic (e.g. `bill`, `corps`, `task`, `workflow`, `key-center`). - `src/cli/`: Command-line definitions, option parsing, user feedback, table rendering, exit handling. - Keep domain services independent of CLI formatting.