Thank you for your interest in contributing to ts-hooks-kit! We welcome contributions from the community. Please follow the guidelines below to ensure a smooth contribution process.
Before you begin, ensure you have the following installed:
- Node.js >=20.19.0
- pnpm 9 or higher
You can check your versions with:
node --version
pnpm --version-
Fork the repository on GitHub
-
Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/ts-hooks-kit.git cd ts-hooks-kit -
Install dependencies:
pnpm install
This automatically sets up Git hooks via Husky.
Every commit runs lint-staged on staged .ts/.tsx files:
- Prettier formats code using
.prettierrc(no semi, single quotes, 100 width) - ESLint auto-fixes lintable issues using
eslint.config.js
If the commit is blocked, fix the reported issues and try again.
Our ESLint config enforces:
- TypeScript strict rules (
consistent-type-imports,no-unused-vars) - React Hooks rules (
rules-of-hooks,exhaustive-deps) - Import hygiene (
import-x/order,no-duplicates,no-cycle)
Each hook is organized in its own directory under packages/core/src/. The standard structure for a hook is:
useHookName/
├── index.ts # Re-exports from hook file
├── useHookName.ts # Implementation
├── useHookName.test.ts # Vitest tests (required)
└── useHookName.md # Documentation (optional)
When adding a new hook or modifying existing ones, follow this structure and ensure all files are included.
Use these commands to develop and test your changes:
| Command | Description |
|---|---|
pnpm test |
Run all tests |
pnpm lint |
Type-check all packages |
pnpm lint:eslint |
Run ESLint on core package |
pnpm format |
Format all source files |
pnpm format:check |
Check formatting without writing |
pnpm build |
Build all packages |
-
Create a feature branch from
master:git checkout -b feature/your-hook-name
-
Write tests first (TDD approach):
- Create your test file before implementing the hook
- Ensure tests are comprehensive and cover edge cases
- All new code must have corresponding tests
-
Implement your code:
- Follow the TypeScript-first approach (strict types)
- Keep imports at the top of files
- Use minimal comments; rely on clear code and JSDoc
-
Verify everything passes:
pnpm test pnpm lint -
Commit and push your changes:
git add . git commit -m "Add/update: brief description of changes" git push origin feature/your-hook-name
-
Submit a pull request on GitHub with a clear description of your changes
When your pull request changes the public API, fixes a bug, or adds a feature to @ts-hooks-kit/core, include a changeset:
-
Run the changeset command:
pnpm changeset
-
Select the package: Choose
@ts-hooks-kit/core. -
Choose the bump type:
- patch: Bug fixes, documentation improvements
- minor: New hooks, new features
- major: Breaking changes to existing hook APIs
-
Write a summary: Describe the change from a user's perspective. This text appears in the CHANGELOG.
This creates a markdown file in .changeset/ — commit it with your PR.
When is a changeset NOT needed?
- Changes to tests only
- Changes to docs site (
apps/docs/) - Changes to the codemod package
- CI/tooling changes
- TypeScript-first: All code must use strict TypeScript types. Avoid
anyunless absolutely necessary. - Imports at top: Place all imports at the beginning of files. No inline imports.
- Minimal comments: Document function signatures with JSDoc. Avoid obvious inline comments.
- Peer dependencies: React ^18 or ^19 (no direct React dependency in the hook itself)
- No unnecessary complexity: Write clear, simple code that solves the problem at hand
If you have questions or need clarification, please open an issue or reach out to the maintainers. We're here to help!
Happy contributing!