|
| 1 | +# Contributing to JS Utils Kit |
| 2 | + |
| 3 | +Thank you for your interest in contributing to **JS Utils Kit**. Whether you're fixing bugs, proposing new utilities, refining documentation, or improving tests, your contributions are valuable and appreciated. |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +Before getting started, ensure you have the following installed: |
| 8 | + |
| 9 | +- Node.js |
| 10 | +- Yarn |
| 11 | +- Git |
| 12 | +- TypeScript (used during development) |
| 13 | + |
| 14 | +## Quick Start |
| 15 | + |
| 16 | +1. **Fork the repository** on GitHub. |
| 17 | + |
| 18 | +2. **Clone your fork:** |
| 19 | + |
| 20 | + ```sh |
| 21 | + git clone https://github.com/your-username/js-utils-kit.git |
| 22 | + cd js-utils-kit |
| 23 | + ``` |
| 24 | + |
| 25 | +3. **Install dependencies:** |
| 26 | + |
| 27 | + ```sh |
| 28 | + yarn install |
| 29 | + ``` |
| 30 | + |
| 31 | +4. **Run tests:** |
| 32 | + |
| 33 | + ```sh |
| 34 | + yarn test |
| 35 | + ``` |
| 36 | + |
| 37 | +## Project Structure |
| 38 | + |
| 39 | +| Directory | Purpose | |
| 40 | +| ---------- | -------------------------------------- | |
| 41 | +| `src/` | Source code organized by category | |
| 42 | +| `bin/` | CLI entry points | |
| 43 | +| `tests/` | Unit tests using Jest | |
| 44 | +| `scripts/` | Development tools (e.g. index builder) | |
| 45 | +| `docs/` | Generated TypeDoc documentation | |
| 46 | + |
| 47 | +## Scripts |
| 48 | + |
| 49 | +| Command | Description | |
| 50 | +| ------------------ | ------------------------------------------------- | |
| 51 | +| `yarn test` | Run all Jest tests | |
| 52 | +| `yarn gen:indexes` | Generate export indexes for all categories | |
| 53 | +| `yarn build` | Compile project to CJS, ESM, and type files | |
| 54 | +| `yarn docs` | Generate TypeScript documentation via TypeDoc | |
| 55 | +| `prebuild` | Automatically runs `gen:indexes` before build | |
| 56 | +| `postbuild` | Automatically generates documentation after build | |
| 57 | + |
| 58 | +## Development Workflow |
| 59 | + |
| 60 | +1. **Create a new branch:** |
| 61 | + |
| 62 | + ```sh |
| 63 | + git checkout -b feat/your-feature-name |
| 64 | + ``` |
| 65 | + |
| 66 | +2. **Make changes and commit with a clear message:** |
| 67 | + |
| 68 | + ```sh |
| 69 | + git commit -m "feat: add clamp utility" |
| 70 | + ``` |
| 71 | + |
| 72 | +3. **Test and build before opening a PR:** |
| 73 | + |
| 74 | + ```sh |
| 75 | + yarn test |
| 76 | + yarn build |
| 77 | + ``` |
| 78 | + |
| 79 | +4. **Push and open a Pull Request on GitHub.** |
| 80 | + |
| 81 | +## Commit Guidelines |
| 82 | + |
| 83 | +Follow [Conventional Commits](https://www.conventionalcommits.org/) for commit messages: |
| 84 | + |
| 85 | +- `feat:` for new features |
| 86 | +- `fix:` for bug fixes |
| 87 | +- `docs:` for documentation changes |
| 88 | +- `refactor:` for code refactoring (no feature or fix) |
| 89 | +- `test:` for adding or updating tests |
| 90 | +- `chore:` for tooling, CI, or build changes |
| 91 | + |
| 92 | +## Testing |
| 93 | + |
| 94 | +All tests are located in the `tests/` directory and use [Jest](https://jestjs.io). |
| 95 | + |
| 96 | +To run the test suite: |
| 97 | + |
| 98 | +```sh |
| 99 | +yarn test |
| 100 | +``` |
| 101 | + |
| 102 | +Ensure new utilities are covered with appropriate test cases. |
| 103 | + |
| 104 | +## CLI Usage |
| 105 | + |
| 106 | +The CLI entry point is in `bin/index.ts`, powered by [Commander](https://github.com/tj/commander.js). |
| 107 | + |
| 108 | +To test it locally: |
| 109 | + |
| 110 | +```sh |
| 111 | +node dist/cli/index.js --help |
| 112 | +``` |
| 113 | + |
| 114 | +## Pull Request Checklist |
| 115 | + |
| 116 | +Before opening a pull request, make sure: |
| 117 | + |
| 118 | +- [ ] The change has a clear purpose |
| 119 | +- [ ] Related tests are added or updated |
| 120 | +- [ ] The utility is compatible with both ESM and CJS |
| 121 | +- [ ] The utility is properly exported in `index.ts` |
| 122 | +- [ ] There are no unintended breaking changes |
| 123 | + |
| 124 | +If you have questions or need clarification, feel free to open an issue or start a discussion. Thank you for helping improve JS Utils Kit. |
0 commit comments