|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thanks for taking the time to contribute! |
| 4 | + |
| 5 | +## Development setup |
| 6 | + |
| 7 | +Prerequisites: |
| 8 | + |
| 9 | +- Node.js 16+ |
| 10 | +- npm |
| 11 | + |
| 12 | +Clone and install: |
| 13 | + |
| 14 | +```bash |
| 15 | +git clone git@github.com:snatalenko/declarative-mapper.git |
| 16 | +cd declarative-mapper |
| 17 | +npm ci |
| 18 | +``` |
| 19 | + |
| 20 | +## Project structure |
| 21 | + |
| 22 | +- `src/` - mapper runtime and public APIs |
| 23 | +- `tests/unit/` - Jest tests |
| 24 | +- `tests/unit/data/` - test fixtures |
| 25 | +- `schemas/` - JSON schemas |
| 26 | +- `scripts/changelog/` - changelog templates/config |
| 27 | +- `dist/` and `types/` - generated build output |
| 28 | + |
| 29 | +## Common tasks |
| 30 | + |
| 31 | +```bash |
| 32 | +npm run cleanup # Remove dist/, types/, coverage/ |
| 33 | +npm test |
| 34 | +npm run test:coverage # Run tests with coverage report |
| 35 | +npm run lint # Run ESLint |
| 36 | +npm run build # Build both ESM and CJS outputs |
| 37 | +npm run build:esm # Build ESM only (generates dist/esm/ and types/) |
| 38 | +npm run build:cjs # Build CJS only (generates dist/cjs/) |
| 39 | +``` |
| 40 | + |
| 41 | +### Running a single test file |
| 42 | + |
| 43 | +```bash |
| 44 | +npm test tests/unit/mappingSchema.test.ts |
| 45 | +``` |
| 46 | + |
| 47 | +## Code style |
| 48 | + |
| 49 | +Code style and formatting are enforced via [EditorConfig](https://editorconfig.org) ([.editorconfig](.editorconfig)) and [ESLint](https://eslint.org) ([eslint.config.mjs](eslint.config.mjs)). |
| 50 | + |
| 51 | +- **Indentation:** Tabs (not spaces) |
| 52 | +- **Quotes:** Single quotes |
| 53 | +- **Semicolons:** Required |
| 54 | +- **Brace style:** Stroustrup |
| 55 | +- **No `console.log`** in production code |
| 56 | +- **No trailing commas** |
| 57 | +- **Line length:** Warn at 120 chars |
| 58 | +- **Type-only imports:** Use the `type` keyword for imports that are only used as types |
| 59 | +- **`.ts` file extensions in imports:** Always use explicit `.ts` extensions in relative import paths |
| 60 | + |
| 61 | +## Commits and pull requests |
| 62 | + |
| 63 | +- Keep commits focused and include tests for behavior changes |
| 64 | +- For PRs, include a short problem/solution summary and link the related issue (if any) |
| 65 | +- Use one of the following prefixes for the commit messages: |
| 66 | + - `New:`, `Feat:` - New functionality |
| 67 | + - `Change:` - Change to existing behavior |
| 68 | + - `Fix:`, `Fixes:` - Bug-fix |
| 69 | + - `Perf:` - Performance improvement |
| 70 | + - `Security:` - Fix of a security issue |
| 71 | + - `Docs:` - Documentation |
| 72 | + - `Tests:` - Tests |
| 73 | + - `Build:`, `CI:` - Build scripts change |
| 74 | + - `Chore:`, `Internal Fix:` - Internal changes or fixes of not-yet-released functionality |
| 75 | + |
| 76 | +## Licensing |
| 77 | + |
| 78 | +By contributing, you agree that your contributions are licensed under the project license. |
0 commit comments