Thank you for your interest in contributing to the Scheduling SDK! This guide will help you get set up for development and understand our contribution process.
- Development Setup
- Project Structure
- Development Workflow
- Testing Guidelines
- Code Style
- Pull Request Process
- Issue Reporting
- Bun: v1.0+ (recommended runtime)
- Node.js: v18+ (alternative runtime)
- TypeScript: v5+ (peer dependency)
- Git: Latest version
-
Fork and Clone
git clone https://github.com/your-username/scheduling-sdk.git cd scheduling-sdk -
Install Dependencies
bun install
-
Verify Setup
bun run build bun test bun run typecheck bun run lint
# Development mode with file watching
bun run dev
# Build for distribution
bun run build
# Run tests
bun test
# Run tests in watch mode
bun test --watch
# Type checking
bun run typecheck
# Linting
bun run lint
# Code formatting
bun run prettier
# Pre-publish checks
bun run prepublishOnlyscheduling-sdk/
├── src/ # Source code
│ ├── core/ # Main Scheduler class
│ ├── helpers/ # Utility functions by domain
│ │ ├── busy-time/ # Busy time operations
│ │ ├── slot/ # Slot generation and filtering
│ │ └── time/ # Date/time utilities
│ ├── types/ # TypeScript type definitions
│ ├── utils/ # Shared constants and utilities
│ ├── validators/ # Input validation functions
│ └── index.ts # Main entry point
├── tests/ # Test files (mirrors src structure)
├── docs/ # Documentation
├── dist/ # Build output (generated)
└── package.json # Project configuration
src/core/: Core scheduling logic and main APIsrc/helpers/: Domain-specific helper functionssrc/types/: TypeScript interfaces and type definitionssrc/validators/: Input validation and error handlingsrc/utils/: Shared constants and utility functions
-
Create Feature Branch
git checkout -b feature/your-feature-name
-
Implement Feature
- Write code following existing patterns
- Add/update types as needed
- Include input validation
-
Write Tests
- Unit tests for new functions
- Integration tests for complex features
- Edge case testing
-
Update Documentation
- API documentation for new public methods
- Usage examples for new features
- Update README if needed
-
Create Bug Fix Branch
git checkout -b fix/bug-description
-
Reproduce Bug
- Create failing test case
- Understand root cause
-
Implement Fix
- Fix the issue
- Ensure tests pass
- Verify no regression
-
Add Regression Test
- Ensure bug won't reoccur
- Test edge cases
import { describe, it, expect, beforeEach } from 'bun:test'
describe('Feature Name', () => {
describe('method name', () => {
it('should handle basic case', () => {
// Arrange
const input = setupTestData()
// Act
const result = methodUnderTest(input)
// Assert
expect(result).toEqual(expectedOutput)
})
it('should handle edge case', () => {
// Test edge cases
})
it('should throw on invalid input', () => {
expect(() => methodUnderTest(invalidInput)).toThrow()
})
})
})- Test individual functions in isolation
- Mock dependencies where appropriate
- Focus on edge cases and error conditions
- Test feature workflows end-to-end
- Use real dependencies
- Verify complex interactions
- Benchmark critical paths
- Ensure performance targets are met
- Test with realistic data sizes
Use consistent test data patterns:
// Standard test dates
const testDate = new Date('2024-01-15T09:00:00Z')
const workDayStart = new Date('2024-01-15T09:00:00Z')
const workDayEnd = new Date('2024-01-15T17:00:00Z')
// Standard test options
const basicOptions = {
slotDuration: 60,
slotSplit: 60,
padding: 0,
offset: 0,
}- Line Coverage: 95%+
- Branch Coverage: 90%+
- Function Coverage: 100%
Run coverage with:
bun test --coverage// ✅ Use explicit interfaces
interface SchedulingOptions {
slotDuration: number
slotSplit?: number
}
// ✅ Use proper typing
function generateSlots(options: SchedulingOptions): TimeSlot[] {
// implementation
}
// ✅ Use readonly for immutable data
interface TimeSlot {
readonly start: Date
readonly end: Date
}
// ❌ Avoid any types
function badFunction(data: any): any {
return data
}- Files:
kebab-case.ts(e.g.,slot-generator.ts) - Functions:
camelCase(e.g.,generateSlots) - Classes:
PascalCase(e.g.,Scheduler) - Constants:
UPPER_SNAKE_CASE(e.g.,MS_PER_MINUTE) - Types/Interfaces:
PascalCase(e.g.,TimeSlot)
// File structure order:
// 1. Imports
import type { TimeSlot } from '../types/scheduling.types.ts'
import { MS_PER_MINUTE } from '../utils/constants.ts'
// 2. Type definitions (if any)
interface LocalOptions {
// ...
}
// 3. Main implementation
export function mainFunction() {
// ...
}
// 4. Helper functions (non-exported)
function helperFunction() {
// ...
}// ✅ Provide descriptive error messages
if (duration <= 0) {
throw new Error('Slot duration must be a positive number')
}
// ✅ Validate at function boundaries
export function validateTimeRange(start: Date, end: Date): void {
if (start >= end) {
throw new Error('Start time must be before end time')
}
}
// ✅ Use appropriate error types
class ValidationError extends Error {
constructor(message: string) {
super(message)
this.name = 'ValidationError'
}
}// ✅ Prefer immutable operations where possible
const newArray = [...existingArray, newItem]
// ✅ Use efficient algorithms
// Sort once, then process
const sortedBusyTimes = busyTimes.sort((a, b) => a.start.getTime() - b.start.getTime())
// ✅ Avoid unnecessary object creation in loops
for (const item of items) {
// Reuse variables where possible
}- All tests pass
- Code is formatted (
bun run prettier) - Linting passes (
bun run lint) - Type checking passes (
bun run typecheck) - Documentation is updated
- CHANGELOG is updated (for features)
Use this template:
## Description
Brief description of the change and why it's needed.
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
## Testing
- [ ] New tests added for new functionality
- [ ] All existing tests pass
- [ ] Edge cases covered
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No breaking changes (or breaking changes documented)- Automated Checks: CI must pass
- Code Review: At least one maintainer approval
- Manual Testing: Verify functionality works as expected
- Documentation Review: Ensure docs are accurate and complete
- All CI checks pass
- At least one approving review
- No requested changes outstanding
- Branch is up to date with main
Use the bug report template:
**Describe the bug**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Create scheduler with '...'
2. Call method '...'
3. See error
**Expected behavior**
What you expected to happen.
**Code example**
```typescript
// Minimal reproduction case
```Environment:
- Bun version: [e.g. 1.0.15]
- Node version: [e.g. 18.17.0]
- OS: [e.g. macOS 13.4]
- SDK version: [e.g. 1.2.3]
### Feature Requests
Use the feature request template:
```markdown
**Is your feature request related to a problem?**
A clear description of what the problem is.
**Describe the solution you'd like**
A clear description of what you want to happen.
**Describe alternatives you've considered**
Other solutions you've considered.
**Additional context**
Any other context about the feature request.
**Code example**
```typescript
// Example of how the feature might be used
### Security Issues
For security vulnerabilities:
1. **Do not** create a public issue
2. Email security concerns to: [security-email]
3. Include detailed reproduction steps
4. Allow time for responsible disclosure
## Development Tips
### Debugging
```typescript
// Use console.log sparingly in production code
// Prefer proper error messages and validation
// For debugging during development:
console.log('Debug: slot count', slots.length)
console.time('Performance check')
// ... code to measure
console.timeEnd('Performance check')
# Test your changes against real scenarios
bun run build
cd test-project
npm link ../scheduling-sdk
# Test integration- Keep documentation in sync with code changes
- Include practical examples
- Update type definitions
- Consider performance implications
- Questions: Create a discussion or issue
- Real-time help: [Community channel if available]
- Documentation: Check existing docs first
- Examples: Look at test files for usage patterns
Thank you for contributing to the Scheduling SDK! Your contributions help make scheduling easier for developers everywhere.