Skip to content

Commit db2f57a

Browse files
jchrisclaude
andcommitted
docs: add code style guidelines including TypeScript best practices and testing mock policy
- Never use 'any' type - require specific types or union types - Use 'function' keyword for top-level functions over arrow functions - Document Vitest mocking patterns used in codebase (vi.fn(), custom mock classes) - Reference test helpers in tests/helpers.ts for consistent test setup - Specify mock call verification patterns (fn.mock.calls) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5cf8c5a commit db2f57a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CLAUDE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ pnpm check
1010

1111
This command runs formatting, linting, tests, and build to ensure code quality.
1212

13+
## Code Style Guidelines
14+
15+
### TypeScript Best Practices
16+
17+
- **Never use `any` type** - Always provide specific types or use union types
18+
- **Use `function` keyword** - Prefer `function functionName() {}` over arrow functions for top-level functions
19+
20+
### Testing and Mock Policy
21+
22+
- **Use Vitest mocking** - Use `vi.fn()` for creating mock functions and spies
23+
- **Custom mock classes** - Create mock implementations that implement interfaces (see `MockLoader`, `MockSuperThis` in `tests/helpers.ts`)
24+
- **Test helpers** - Use `mockSuperThis()` and other helpers from `tests/helpers.ts` for consistent test setup
25+
- **Mock call verification** - Access mock call data via `fn.mock.calls` for assertions
26+
- **Avoid real dependencies** - Use mocks to isolate units under test from external dependencies
27+
1328
## Branch Naming Convention
1429

1530
Use the format `{username}/{topic}` for branch names:

0 commit comments

Comments
 (0)