Thank you for considering contributing to typed-id! 🎉 We welcome contributions from everyone, whether you're fixing a bug, adding a feature, improving documentation, or just asking questions.
- Code of Conduct
- How to Contribute
- Development Setup
- Pull Request Process
- Coding Standards
- Testing Guidelines
- Documentation Guidelines
- Issue Guidelines
- Contributors
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code:
- Be respectful: Treat everyone with respect, regardless of their background, identity, or experience level
- Be inclusive: Welcome newcomers and help them get involved
- Be constructive: Provide helpful feedback and suggestions
- Be patient: Remember that everyone is learning and growing
- Be collaborative: Work together towards common goals
- Report bugs - Help us identify and fix issues
- Suggest features - Share ideas for new functionality
- Fix bugs - Submit bug fixes with tests
- Add features - Implement new functionality
- Improve documentation - Make our docs clearer and more helpful
- Write tests - Improve test coverage
- Code reviews - Review pull requests from other contributors
- Fork the repository on GitHub
- Clone your fork locally
- Create a feature branch for your changes
- Make your changes following our guidelines
- Test your changes thoroughly
- Submit a pull request
# 1. Fork the repository on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/typed-id.git
cd typed-id
# 2. Install dependencies
bun install
# 3. Run tests to make sure everything works
bun test
# 4. Start development!typed-id/
├── src/ # Source code
│ ├── id-helper.ts # Main IdHelper class
│ ├── types.ts # Type definitions
│ ├── index.ts # Public API exports
│ └── validators/ # Optional validation schemas
│ └── zod.ts # Zod integration
├── tests/ # Test files
│ ├── id-helper.test.ts
│ └── validators/
├── dist/ # Built files (generated)
├── docs/ # Documentation
└── package.json
# Run tests
bun test # Run all tests
bun test:ui # Run tests with UI
bun test:run # Run tests once (CI mode)
# Build
bun run build # Build the package
# Development
bun run dev # Watch mode (if available)- Ensure tests pass:
bun test - Add tests for new features or bug fixes
- Update documentation if needed
- Follow coding standards (see below)
- Write clear commit messages
We use conventional commits for clear history:
type(scope): description
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changestest: Adding or updating testsrefactor: Code refactoringperf: Performance improvementschore: Maintenance tasks
Examples:
feat: add custom separator support for ID generation
fix(validation): handle edge case in zod schema validation
docs: update README with new API examples
test: add comprehensive tests for custom alphabets
When creating a PR, please include:
- Description: What changes you made and why
- Type of change: Bug fix, new feature, documentation, etc.
- Testing: How you tested your changes
- Screenshots: If applicable (UI changes)
- Breaking changes: If any, with migration guide
- Use TypeScript strictly: Enable strict mode, no
anytypes - Prefer explicit types: When type inference isn't clear
- Use generic types: For reusable components
- Document complex types: Add JSDoc for complex type definitions
- Use Prettier: Code formatting is handled automatically
- Use meaningful names: Variables, functions, and classes should be self-documenting
- Keep functions small: One responsibility per function
- Use async/await: Instead of Promise chains where possible
- One export per file: For main functionality
- Group related functionality: Keep related code together
- Use barrel exports: Re-export from index files
- Consistent naming: Use kebab-case for files, PascalCase for classes
All contributions should include appropriate tests:
- Unit tests: For individual functions/methods
- Integration tests: For component interactions
- Type tests: For TypeScript type safety
- Edge cases: Test boundary conditions
import { describe, it, expect } from "vitest";
import { IdHelper } from "../src";
describe("IdHelper", () => {
it("should describe what it tests", () => {
// Arrange
const idHelper = new IdHelper("test");
// Act
const result = idHelper.generate();
// Assert
expect(result).toMatch(/^test_[a-zA-Z0-9]{10}$/);
});
});- Aim for 90%+ coverage on new code
- Test happy paths and error cases
- Include regression tests for bug fixes
- Test TypeScript types where applicable
- JSDoc comments for public APIs
- Inline comments for complex logic
- README updates for new features
- Type documentation for complex generics
/**
* Generates a prefixed ID with customizable options.
*
* @returns A type-safe string in format `${prefix}${separator}${id}`
* @example
* ```typescript
* const userIds = new IdHelper('user');
* const id = userIds.generate(); // "user_abc123xyz"
* ```
*/
public generate(): GeneratedID<P, SeparatorOrDefault<S>> {
// Implementation
}When reporting bugs, please include:
- Clear title: Describe the issue briefly
- Expected behavior: What should happen
- Actual behavior: What actually happens
- Steps to reproduce: Clear, numbered steps
- Environment: Node.js/Bun version, OS, etc.
- Code example: Minimal reproduction case
For new features, please provide:
- Problem description: What problem does this solve?
- Proposed solution: How should it work?
- Alternatives considered: Other ways to solve this
- Implementation ideas: Technical approach (if any)
- Breaking changes: Would this break existing code?
If you need help:
- Check existing issues - Your question might already be answered
- Read the documentation - The README has extensive examples
- Create a discussion - For general questions
- Join our community - [Discord/Slack link if applicable]
For maintainers:
- Update version in
package.json - Update
CHANGELOG.md - Create git tag:
git tag v1.0.0 - Push tag:
git push origin --tags - GitHub Actions will handle npm publishing
We appreciate all contributions, no matter how small! Contributors will be:
- Listed in this file
- Mentioned in release notes
- Given credit in commit history
- Thanked publicly (if desired)
Thank you for contributing to typed-id! Together, we can make type-safe ID generation better for everyone. 🚀