|
1 | 1 | # zod-from-json-schema Development Guidelines |
2 | 2 |
|
3 | 3 | ## Commands |
4 | | -- **Build:** `npm run build` (generates CJS and ESM outputs) |
5 | | -- **Test all:** `npm test` |
6 | | -- **Test single file:** `npx vitest run src/path/to/file.test.ts` |
7 | | -- **Test with pattern:** `npx vitest run -t "test pattern"` |
8 | | -- **Clean:** `npm run clean` (removes dist directory) |
| 4 | +- **Build**: `npm run build` (generates CJS and ESM outputs) |
| 5 | +- **Test all**: `npm test` |
| 6 | +- **Test single file**: `npx vitest run src/path/to/file.test.ts` |
| 7 | +- **Test with pattern**: `npx vitest run -t "test pattern"` |
| 8 | +- **Run specific test**: `npx vitest run src/index.test.ts -t "should extract properties"` |
| 9 | +- **Clean**: `npm run clean` (removes dist directory) |
| 10 | +- **Prepare for publishing**: `npm run prepublishOnly` |
9 | 11 |
|
10 | 12 | ## Code Style |
11 | | -- **TypeScript:** Use strict types, avoid `any` except in JSON Schema interfaces |
12 | | -- **Imports:** Use named imports from zod (`import { z } from "zod"`) |
13 | | -- **Formatting:** 4-space indentation, avoid lines > 80 chars |
14 | | -- **Naming:** Use camelCase for functions/variables, PascalCase for types/interfaces |
15 | | -- **Error handling:** Use Zod's built-in validation or custom refinements |
16 | | -- **Comments:** Document functions with JSDoc comments including params, return types |
17 | | -- **Compatibility:** Keep dual-module support (CJS/ESM) for all exported functions |
| 13 | +- **TypeScript**: Use strict types with proper JSON Schema interface typing |
| 14 | +- **Imports**: Use named imports (`import { z } from "zod"`) |
| 15 | +- **Formatting**: 4-space indentation, prefer lines under 80 chars |
| 16 | +- **Functions**: Pure functions with no side effects, descriptive names in camelCase |
| 17 | +- **Types/Interfaces**: Use PascalCase, export types used in public API |
| 18 | +- **Error handling**: Use Zod's built-in validation rather than throwing errors |
| 19 | +- **Documentation**: JSDoc comments for all exported functions and types |
18 | 20 |
|
19 | 21 | ## Architecture |
20 | | -- Functions should be pure with no side effects |
21 | | -- Keep JSON Schema to Zod conversion logic separate from utility functions |
22 | | -- Write tests for each supported feature and edge case |
| 22 | +- Maintain dual module support (CJS/ESM) for all exports |
| 23 | +- Keep conversion logic modular with single-responsibility functions |
| 24 | +- Write tests for each feature and edge cases, including type validation |
| 25 | +- CI runs tests on Node 18, 20, and 22 through GitHub Actions workflow |
| 26 | +- Use esbuild for bundling with targeted ES2018 output |
| 27 | +- Follow semantic versioning for releases |
| 28 | + |
| 29 | +For release process, see RELEASE.md |
0 commit comments