|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | +- `src/` houses all TypeScript source; entry point is `src/index.ts`, with domain logic in `weatherService.ts` and provider implementations under `src/providers/`. |
| 5 | +- Each provider keeps its own helpers (`openweather/`, `nws/`) and colocated tests (`*.test.ts`). Shared contracts live in `interfaces.ts` and `providers/IWeatherProvider.ts`. |
| 6 | +- Utilities (caching, error taxonomy, normalization) sit in `src/utils/` and `src/errors.ts`. Build artifacts publish to `dist/` (CJS and ESM). Architectural notes and RFCs reside in `docs/rfcs/`. |
| 7 | + |
| 8 | +## Build, Test, and Development Commands |
| 9 | +- `yarn build` compiles both CJS and ESM bundles to `dist/`, cleaning the directory via the `prebuild` hook. |
| 10 | +- `yarn build:cjs` / `yarn build:esm` generate a single module target when you need faster iteration. |
| 11 | +- `yarn dev` watches the compiler (`tsc-watch`) and re-runs `node dist/index.js` after successful builds for local experimentation. |
| 12 | +- `yarn test` runs the Jest suite once; `yarn test:watch` keeps Jest hot during development; `yarn coverage` enforces coverage expectations and refreshes the `coverage/` report. |
| 13 | + |
| 14 | +## Coding Style & Naming Conventions |
| 15 | +- Write modern, strict TypeScript (see `tsconfig.json`: `strict: true`, ES6 modules). Prefer named exports, keeping default exports limited to top-level entry points (`WeatherPlus`). |
| 16 | +- Use two-space indentation, camelCase for functions/variables, PascalCase for classes/types, and SCREAMING_CASE for constants. Match existing file casing (e.g., `providerRegistry.ts`, `weatherService.ts`) to stay consistent. |
| 17 | +- Keep provider adapters cohesive: map external API responses to internal interfaces inside the provider module, and surface errors via the shared `errors` utilities. |
| 18 | + |
| 19 | +## Testing Guidelines |
| 20 | +- Jest powers unit and integration tests; colocate new specs as `*.test.ts` alongside the module under test. |
| 21 | +- Aim to maintain or raise branch coverage (track with `yarn coverage`). Focus on edge cases around provider fallbacks, caching, and normalization. |
| 22 | +- Snapshot tests live under `__snapshots__/`; regenerate only when intentional API responses change and review diffs carefully. |
| 23 | + |
| 24 | +## Commit & Pull Request Guidelines |
| 25 | +- Follow the prevailing Conventional Commit style (`feat(scope): ...`, `test: ...`, `chore: ...`). Reference related RFC IDs or providers in the scope when relevant. |
| 26 | +- Before opening a PR, ensure `yarn test` and `yarn build` pass, link any issue or RFC context, and include screenshots or sample payloads when behavior changes. |
| 27 | +- Keep PR descriptions action-oriented: summarize the outcome, highlight provider impacts, and call out any required configuration (API keys, Redis). |
0 commit comments