- Install dependencies:
pnpm install- Start the development server:
pnpm run dev- Open your browser and navigate to
http://localhost:5174
pnpm run build- Build for productionpnpm run lint:fix- Run ESLint (and fix most of them automatically)pnpm run test- Run unit testspnpm run test:e2e- Run e2e tests
Code should be self-documenting through clear naming. Don't explain what the code does with comments — use a
well-named function or variable instead. Don't use {/* ... */} JSX comments either — the surrounding structure
and data-testid attributes already convey intent. Only add a comment when documenting a non-obvious why
(a hidden constraint, subtle invariant, or external workaround) that can't be expressed in a name — and put it in
the JSDoc of the enclosing function, not inline.
// ❌
// get present players
const v = arr.filter(p => p.present);
// ✅
const presentPlayers = arr.filter(p => p.present);Use JSDoc only on exported functions and classes. Describe why or what at a high level; omit @param and
@returns tags — the type signatures and names are already self-documenting.
// ❌
/**
* @param bracketSize Power-of-2 total slot count
* @returns Array of rounds
*/
export function computeWBTree(bracketSize: number): BracketNode[][] { ... }
// ✅
/**
* Computes a round-by-round bracket tree. Indices beyond teams.length are treated as byes.
*/
export function computeWBTree(bracketSize: number): BracketNode[][] { ... }Always use the node: protocol prefix for Node.js built-in modules:
// ❌
import fs from 'fs';
import path from 'path';
// ✅
import fs from 'node:fs';
import path from 'node:path';This applies to all built-ins: node:fs, node:path, node:url, node:crypto, etc.
- Use
interfacefor object shapes and class contracts. - Use
typefor unions, aliases, and simple literals.
interface Court {
courtNumber: number;
players: Player[];
}
type EngineType = 'sa' | 'sl';- Functional components only, typed as
React.FC<Props>. - Use named
export constdeclarations, not default exports. - Define a
Propsinterface directly above the component. - Destructure props in the function signature with defaults where relevant.
- Prefix event handlers with
handle(e.g.handleTeamClick).
Before adding a helper, check whether it already exists:
- Unit test utilities →
tests/shared.ts,tests/setup.ts,tests/data/*, - E2E utilities →
e2e/helpers.ts
Extend those files rather than copy-pasting setup logic across test files.
Unit (tests/) |
E2E (e2e/) |
|
|---|---|---|
| Scope | A single function or class | A full user workflow |
| Framework | Vitest + Testing Library | Playwright |
| File suffix | .test.ts |
.spec.ts |
| What to test | Algorithm correctness, edge cases, state management | UI interactions, cross-page navigation, real browser behaviour |
Prefer unit tests for logic. Only reach for E2E when the value comes from testing the real browser.
src/engines/SimulatedAnnealingEngine.ts
tests/engines/SimulatedAnnealingEngine.test.ts
Wrap all tests for a class in a top-level describe('ClassName'). Inside it, use a nested describe('methodName') only when a method has more than one test. Single-test methods use a bare it directly inside the class describe.
describe('MyClass', () => {
// single test → bare it, no nested describe
it('someMethod returns the expected value', () => { ... });
// multiple tests → nested describe
describe('otherMethod', () => {
it('returns X when ...', () => { ... });
it('returns Y when ...', () => { ... });
});
});Use it.each or describe.each to limit duplication for test setup.
Translations are defined in YAML files under src/i18n/locales/<lang>.yml, with en.yml as the source of truth. Nested YAML structures are flattened into dot-separated keys (e.g. app.title) at build time.
const { t } = useTranslation();
<h1>{t('app.title')}</h1>- Key parity: Every key in
en.ymlmust exist in every other locale file — no missing keys, no extra keys. - Non-empty values: Values must be non-empty strings.
- Build-time enforcement: The Vite YAML plugin validates parity and non-empty values on dev and build; mismatched keys fail compilation.
- Create
src/i18n/locales/<lang>.ymlmatching all keys fromen.yml. - Register
<lang>inSUPPORTED_LOCALES(src/i18n/detectLocale.ts), lazy imports (src/i18n/index.ts), andLANGUAGE_LABELS(src/i18n/LanguageSelector.tsx). - Verify parity:
pnpm vitest run tests/i18n/localeParity.test.tsUse the imperative mood — write the message as a command:
# ❌
Added rotation button
Fixing bench fairness bug
# ✅
Add rotation button
Fix bench fairness bug
Keep the history linear.
Rebase your branch on main before marking a PR ready for review instead of merging main into your branch.
git fetch origin
git rebase origin/main