You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7a94fc7
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .claude/rules/code-style.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,8 +35,8 @@ Export style follows the kind of module. Components, layouts, App Router route f
35
35
36
36
The counts, thresholds, and carve-outs behind these live in the skill. What follows is how they land here.
37
37
38
-
-**A component gets a directory, not a loose file.** Every one lives in its own kebab-case directory under `src/components/` with a PascalCase file and a colocated test, as [`navbar/Navbar.tsx`](../../src/components/navbar/Navbar.tsx) does. Eight of the nine directories spell the name that way, and [`Stars/`](../../src/components/Stars/StarsBackground.tsx) is the single PascalCase exception rather than a second convention: match the eight. Related files are grouped into a subdirectory rather than left flat beside unrelated ones, and entries sharing a name prefix are the group to propose.
39
-
-**Count the files sitting directly in a directory**, whatever subdirectories sit beside them: one subdirectory does not make the loose files next to it grouped. [`src/components/ServiceWorkerRegister.tsx`](../../src/components/ServiceWorkerRegister.tsx)and the two `ThemeRegistry` files sit directly in `src/components/` beside nine component directories, so the count there is three rather than twelve.
38
+
-**A component gets a directory, not a loose file.** Every one lives in its own kebab-case directory under `src/components/` with a PascalCase file and a colocated test, as [`navbar/Navbar.tsx`](../../src/components/navbar/Navbar.tsx) does. Eleven of the twelve directories spell the name that way, and [`Stars/`](../../src/components/Stars/StarsBackground.tsx) is the single PascalCase exception rather than a second convention: match the eleven. Related files are grouped into a subdirectory rather than left flat beside unrelated ones, and entries sharing a name prefix are the group to propose.
39
+
-**Count the files sitting directly in a directory**, whatever subdirectories sit beside them: one subdirectory does not make the loose files next to it grouped. [`ServiceWorkerRegister.tsx`](../../src/components/ServiceWorkerRegister.tsx), [`ServiceWorkerRegister.test.tsx`](../../src/components/ServiceWorkerRegister.test.tsx), [`ThemeRegistry.tsx`](../../src/components/ThemeRegistry.tsx), and [`ThemeRegistry.test.tsx`](../../src/components/ThemeRegistry.test.tsx)sit directly in `src/components/` beside twelve component directories, so the count there is four rather than sixteen.
40
40
-**A setting the tooling reads from configuration is set once, never per file.**[`jest.config.js`](../../jest.config.js) already sets `testEnvironment: 'jsdom'` for every test, so only the minority that needs another environment carries a `@jest-environment` docblock: tests that build a fetch `Request` or `Response` run in `node`, because jsdom has neither. Path aliases are declared in [`tsconfig.json`](../../tsconfig.json) and mirrored in [`jest.config.js`](../../jest.config.js) rather than re-declared per import. Where the same directive would go into three or more files, **search for the key rather than for the directive's own spelling**, since the two are rarely the same word, and hoist the majority while leaving the minority declared. Moving a directive into the key the tool reads is not deleting it.
41
41
-**A utility does one thing, and a parameter it branches on is a second thing.** Count the parameters of every function you write or review, splitting those supplying data from those the body branches on rather than operates on. Every exported helper here already matches that shape: [`convertAAAAHH(aaaaahhhh: string)`](../../src/helpers/aaaahhhh.ts) takes one value and no switch, and [`readConsent()`](../../src/util/consent/consentStore.ts) takes none, so a new helper carrying two booleans is the outlier rather than the norm. More than one switch on a utility is the trigger to split it into one function per behaviour; a function coordinating a sequence takes its modes legitimately. Each function a split produces has one caller the day it lands, and that is what a split looks like rather than a reason to keep the flag.
42
42
-**Reuse before writing.** Check this repository's own [`helpers`](../../src/helpers/ascii.ts) and [`util`](../../src/util/absoluteUrl.ts) modules, then [`package.json`](../../package.json) with the lockfile beside it, then the platform, before hand-writing behaviour that has a name outside this repository. Read what the modules a file already imports export before accepting a hand-written block beneath them. Where nothing present provides it, say so rather than adding a dependency. Never hand-roll anything that signs, verifies, hashes a credential, or settles an authorization outcome.
Copy file name to clipboardExpand all lines: .claude/rules/testing.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,9 @@ Retrieve mock state with `jest.requireMock('@configs/firebase').logAnalyticsEven
34
34
35
35
`next/image` is left unmocked, and is the pattern to follow. It rewrites `src` through its loader, so the test asserts with `expect.stringContaining('profile_pic_drawn.webp')` rather than mocking the component to get an exact path.
36
36
37
-
## Test file exemptions
37
+
## Modules that get no test file
38
38
39
-
Exempt from needing a colocated test: static data modules such as[`projects.ts`](../../src/data/projects.ts), type-only modules, metadata route exports ([`manifest.ts`](../../src/app/manifest.ts), [`robots.ts`](../../src/app/robots.ts)), and instrumentation entry points. Components are **not**exempt.
39
+
Static data modules (everything under[`src/data/`](../../src/data/projects.ts), such as `projects.ts` and `structuredData.ts`), type-only modules, metadata route exports ([`manifest.ts`](../../src/app/manifest.ts), [`robots.ts`](../../src/app/robots.ts)), and instrumentation entry points get **no** colocated test file. A test that only asserts a static data literal against itself adds no behaviour coverage; a test of a component or function that consumes a module may import its exported value as an expected value. Components are **not**in this list.
Copy file name to clipboardExpand all lines: .claude/skills/typescript-code-and-test-standards/SKILL.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,7 +191,7 @@ Prefer the readable form wherever it costs nothing at runtime, and wherever the
191
191
192
192
**One test file per source file**, colocated and same-named, following whatever suffix the project already uses. No orphan test file without a same-named source beside it, no test file named after a function that lives in another file, and no second test file for one source.
193
193
194
-
Files typically exempt: static data modules, type-only modules, generated files, framework metadata or route manifest exports, and instrumentation entry points. Components are **not**exempt. Confirm the project's own exemption list rather than assuming this one.
194
+
These typically get no test file: static data modules, type-only modules, generated files, framework metadata or route manifest exports, and instrumentation entry points. A test that only asserts a static data literal against itself adds no behaviour coverage; a test of code that consumes a module may still import its exported value as an expected value. Components are **not**in this list. Confirm the project's own list rather than assuming this one.
Copy file name to clipboardExpand all lines: .claude/skills/typescript-code-and-test-standards/agents/test-quality-reviewer.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,7 @@ These do **not** qualify: a module that is merely slow, a module that is awkward
65
65
- A test deleted or an assertion weakened in the diff, where the change is not a deliberate behaviour replacement stated as such.
66
66
- A fallback added in production code that exists only to make a test pass.
67
67
- An orphan test file with no same-named source beside it, or a second test file for one source.
68
+
- A test file whose subject is a module the host project's rules exempt, such as static data, type-only, generated, framework metadata, or an instrumentation entry point.
68
69
- A test that would still pass if the behaviour it names were broken. Break the behaviour in your head and ask which assertion fails; if none does, this is the finding.
69
70
- Cases that cannot fail independently of one another, which lock in one behaviour under several names.
70
71
- Setup or a fixture disproportionate to what the assertion reads, where most of the value built is never checked.
Copy file name to clipboardExpand all lines: .claude/skills/typescript-code-and-test-standards/references/test-standards.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ Where a source file has grown enough to want two test files, the signal is about
34
34
35
35
## Exemptions and why each one is exempt
36
36
37
-
Each of these is exempt because there is no behaviour to lock in, not because testing them is inconvenient:
37
+
Each category gets no test file for the reason listed below. A test of code that consumes a module may still import its exported value as an expected value:
38
38
39
39
-**Static data modules.** A module that exports a literal has no code path. A test asserting the literal equals itself fails only when someone edits the data deliberately.
40
40
-**Type-only modules.** They emit nothing. The compiler already checks them.
@@ -44,7 +44,7 @@ Each of these is exempt because there is no behaviour to lock in, not because te
44
44
45
45
**Components are not exempt.** They hold conditional rendering, event wiring, and prop handling, all of which are behaviour.
46
46
47
-
Confirm the host project's own exemption list before applying this one. A project that tests its data modules has a reason.
47
+
Confirm the host project's own list before applying this one.
48
48
49
49
## The prohibitions
50
50
@@ -54,6 +54,7 @@ Confirm the host project's own exemption list before applying this one. A projec
54
54
-**Never assert the implementation back at itself.** A test that mirrors the code line for line fails only when the code changes shape, not when it breaks.
55
55
-**Never type-assert an already-typed value.** Checking that a `string` is a string tests the compiler, and the compiler already ran.
56
56
-**Never build a one-row table.** A table with one row is a loop that runs once, which is a plain test case written indirectly.
57
+
-**Never write a test file for a module with no code path.** A test of static data asserts the literal equals itself and fails only when someone edits the data deliberately.
57
58
-**Never add a fallback in production code to make a test pass.** A `?? defaultValue` inserted to satisfy an assertion moves a defect from the test into production.
58
59
-**Never leave a test that would still pass if the behaviour it names were broken.** Break the behaviour in your head and ask which assertion fails. If none does, the test names something it does not check, and it will keep passing through the regression it was written to catch.
59
60
-**Never write cases that cannot fail independently of one another.** Several cases breaking together lock in one behaviour, not several. The extra names cost a reader time and buy no coverage, and they make a single regression look like a suite-wide collapse.
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ npm run build # Production build
34
34
35
35
-**One test file per source file**, colocated and same-named: `Banner.tsx` gives `Banner.test.tsx` (see `src/components/banner/Banner.test.tsx`). No orphan tests, no test file named after a function, no second test file for one source.
36
36
-**Logic changes, bug fixes, and new features land with their tests in the same change.** Pure refactors need no new tests, but every existing test must still pass. A diff that skips or weakens a test is a behaviour change, not a refactor.
37
-
-**Exempt**from needing a test: static data (`src/data/*`), type-only modules, metadata routes (`manifest.ts`, `robots.ts`), instrumentation entry points. Components are not exempt.
37
+
-**No test file**for static data (`src/data/*`), type-only modules, metadata routes (`manifest.ts`, `robots.ts`), or instrumentation entry points. A test that only asserts a static data literal against itself adds no behaviour coverage. A consumer's test may import an exported value as its expected value. Components always get one.
38
38
-**Never** skip, gut, or delete a failing test: read the test, read the source, fix the cause. No `it.skip`/`describe.skip`, no `expect(true).toBe(true)`, no assertions that restate the implementation, no `expect(typeof x).toBe('string')` on an already-typed value, no one-row `it.each` table, and never add a `?? fallback` in production code to make a test pass. Also never leave a test that would still pass if the behaviour it names were broken, write cases that cannot fail independently of one another, or build setup disproportionate to what the assertion reads.
39
39
-**Do not mock.** Start from zero and add one only when the real dependency cannot run in the test. This covers every substitution technique: mocks, stubs, fakes, behaviour-replacing spies, hand-written doubles. A test whose collaborators are all mocked asserts only that mocks were called. Try first, in order: the real implementation with real inputs; passing the dependency in as an argument instead of replacing a module; a real fixture asserted on its real output; moving the assertion to where the seam is real, or into Cypress
40
40
-**Never mock code that holds logic**, whoever wrote it: helpers, utilities, domain logic, components, hooks, constants, `src/data/*`. Never mock the subject under test, even partially
@@ -176,7 +176,7 @@ Not adopted: the ban on default exports (this repository uses them for the modul
176
176
### Structure & Reuse
177
177
178
178
- **Count seven things on any file you write or review**, since no tool checks them, each with the threshold that backstops it: lines in the file (600), members of each exported type against how many a caller uses (15), files sitting **directly** in the directory (20, counted whatever subdirectories sit beside them, so one subdirectory does not make the loose files next to it grouped), occurrences of a repeated block (3, counting test cases too, where three differing only in a value are one table-driven case), files repeating one declaration (3), parameters a function branches on rather than operates on (more than one, and only on a utility, meaning one named for a single operation or exported for general use rather than one coordinating a sequence, which takes its modes legitimately), and the shape of each function body as three numbers together (lines, nesting depth, widest expression), which is the one unit the other six never reach inside. Name the principle a structural finding violates rather than describing it: single responsibility, control coupling for a branched-on parameter, common coupling for shared mutable module state, content coupling for reaching past an interface, stamp coupling for a whole record where a field would do, dependency inversion, interface segregation, or DRY. Those numbers apply where every sibling is equally large; the sharper test is being an outlier in this tree, stated against what it is measured on. A count triggers a look and is never a finding alone; what makes it one is the concrete split
179
-
-**A component gets a directory, not a loose file**: kebab-case directory under `src/components/`, PascalCase file, colocated test, as `navbar/Navbar.tsx` does. Eight of the nine spell it that way, and `Stars/` is the single PascalCase exception rather than a second convention: match the eight. Related files are grouped into a subdirectory rather than left flat, and entries sharing a name prefix are the group to propose. Detect the scheme the tree uses; never impose a methodology
179
+
-**A component gets a directory, not a loose file**: kebab-case directory under `src/components/`, PascalCase file, colocated test, as `navbar/Navbar.tsx` does. Eleven of the twelve spell it that way, and `Stars/` is the single PascalCase exception rather than a second convention: match the eleven. Related files are grouped into a subdirectory rather than left flat, and entries sharing a name prefix are the group to propose. Detect the scheme the tree uses; never impose a methodology
180
180
-**A setting the tooling reads from configuration is set once, never per file.**`jest.config.js` already sets `testEnvironment: 'jsdom'` for every test, so only the minority that needs another environment carries a `@jest-environment` docblock (tests that build a fetch `Request` or `Response` run in `node`, because jsdom has neither), and path aliases live in `tsconfig.json` mirrored into `jest.config.js` rather than re-declared per import. Where the same directive would go into three or more files, **search for the key, not for the directive's own spelling**, since the two are rarely the same word, then hoist the majority and leave the minority declared, counting the majority over every file the setting governs rather than over the files in front of you
181
181
- **Reuse before writing.** Before hand-writing behaviour that has a name outside this repository (a wire format, a version-ordering rule, a retry schedule, a cryptographic construction), check three sources in order and say which you read: this repository's own `helpers` and `util` modules, then `package.json` and the lockfile, which lists what is resolved where the manifest lists only what was asked for, then the standard library and the platform. Read what the modules a file already imports export before accepting a hand-written block beneath them, since hand-rolling half of what the file imports is the shape this misses most often. The tell is vocabulary: code spelling a specification's own field names is implementing that specification whatever the function is called. Where nothing present provides it, say so and stop rather than adding a dependency. **Never hand-roll anything that signs, verifies, encrypts, hashes a credential, or settles an authorization outcome.** A test building a value by hand to exercise a rejection path is not this finding
0 commit comments