|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure |
| 4 | + |
| 5 | +- `src/`: TypeScript library source. |
| 6 | +- `src/index.ts`: Public entrypoint (`observe`). |
| 7 | +- `src/services/`: Service-specific detection helpers. |
| 8 | +- `src/translations/`: Canary translation data. |
| 9 | + - `src/translations/Skip-to-main-content.yml`: Source-of-truth. |
| 10 | + - `src/translations/*.ts`: Generated artifacts (gitignored). |
| 11 | +- `src/test/`: Jest tests (`*.test.ts`) running in JSDOM. |
| 12 | +- `.bin/`: Dev scripts (not shipped), including language-id generation. |
| 13 | +- `.github/workflows/`: CI (`ci.yml`) and tag-driven releases (`release.yml`). |
| 14 | + |
| 15 | +## Build, Test, And Dev Commands |
| 16 | + |
| 17 | +This repo uses `pnpm` (see `package.json#packageManager`) and CI runs on Node 22. |
| 18 | + |
| 19 | +- `pnpm install`: Install dependencies. |
| 20 | +- `pnpm test`: Regenerates lang ids (`pnpm run langids`) then runs Jest. |
| 21 | +- `pnpm run lint`: Biome checks (lint + formatting rules). |
| 22 | +- `pnpm run format`: Auto-format with Biome. |
| 23 | +- `pnpm run typecheck`: `tsc --noEmit`. |
| 24 | +- `pnpm run knip`: Unused files/deps checks. |
| 25 | +- `pnpm run build`: Build ESM/CJS via `tsup` plus the browser bundle via `esbuild`. |
| 26 | +- `pnpm run prepublish`: Main local gate (tests + lint + typecheck + knip + build + publint + audit). |
| 27 | + |
| 28 | +## Coding Style & Naming |
| 29 | + |
| 30 | +- Formatting/linting: Biome (`biome.json`) with 2-space indentation, 80-char line width, and double quotes. |
| 31 | +- TypeScript: Prefer explicit types for public APIs; keep browser/DOM access guarded for testability. |
| 32 | +- Files: `camelCase.ts` for modules; tests in `src/test/*.test.ts`. |
| 33 | + |
| 34 | +## Testing Guidelines |
| 35 | + |
| 36 | +- Framework: Jest with a custom JSDOM environment (exposes global `jsdom` for `jsdom.reconfigure({ url })`). |
| 37 | +- Add/adjust tests when changing detection heuristics or public types. |
| 38 | +- Expect `coverage/` to be generated locally (gitignored). |
| 39 | + |
| 40 | +## Commit & Pull Request Guidelines |
| 41 | + |
| 42 | +- Commits follow Conventional Commits in practice: `fix: ...`, `docs: ...`, `chore(scope): ...` (see `git log`). |
| 43 | +- Husky runs `pnpm test`, `pnpm run lint`, and `pnpm run knip` on `pre-commit` (CI sets `HUSKY=0`). |
| 44 | +- PRs should include: a clear description, rationale for heuristic changes, and tests. Run `pnpm run prepublish` before opening/updating a PR. |
| 45 | + |
| 46 | +## Notes |
| 47 | + |
| 48 | +- Do not commit build outputs: `dist/` and `dist-browser/` are gitignored. |
| 49 | +- If you update `src/translations/Skip-to-main-content.yml`, rerun `pnpm run langids` and verify `pnpm test`. |
0 commit comments