Contributing to cron-parser
August 1, 2026 ยท View on GitHub
Thank you for your interest in contributing to cron-parser! This document provides guidelines and information for contributors.
Table of Contents
- Code of Conduct
- Reporting Security Issues
- Getting Started
- Development Setup
- How to Contribute
- Pull Request Process
- Coding Standards
- Testing
- Benchmarking
- Documentation
- Issue Guidelines
Code of Conduct
This project and everyone participating in it are governed by the Code of Conduct. By participating, you are expected to uphold it. Please report unacceptable behavior using the channels listed there.
Reporting Security Issues
Do not open a public issue or pull request for a security vulnerability. Report it privately following the Security Policy.
Getting Started
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/your-username/cron-parser.git cd cron-parser - Add the original repository as upstream:
git remote add upstream https://github.com/harrisiirak/cron-parser.git
Development Setup
Prerequisites
- Node.js >= 18
- npm (comes with Node.js)
Installation
-
Install dependencies:
npm install -
Build the project:
npm run build -
Run tests to ensure everything works:
npm test
Available Scripts
npm run build- Build the TypeScript projectnpm run test- Run all tests (lint + type check + unit tests + coverage)npm run test:unit- Run unit tests onlynpm run test:coverage- Run tests with coverage reportnpm run lint- Run ESLintnpm run lint:fix- Fix ESLint issues automaticallynpm run format- Format code with Prettiernpm run format:check- Check code formattingnpm run bench- Run benchmarksnpm run docs- Generate documentation
How to Contribute
Types of Contributions
- Bug fixes - Fix issues in the existing codebase
- Features - Add new functionality
- Documentation - Improve or add documentation
- Code improvements - Refactoring, optimization, code quality
- Tests - Add or improve test coverage
- Performance - Performance optimizations
Before You Start
- Check existing issues to see if your contribution is already being worked on
- Create an issue to discuss new features or significant changes
- Look for good first issues labeled with
good first issuefor newcomers
Pull Request Process
-
Create a feature branch from
master:git checkout -b feature/your-feature-name -
Make your changes following the coding standards
-
Write or update tests for your changes
-
Run the test suite and ensure all tests pass:
npm test -
Update documentation if needed
-
Commit your changes with a clear commit message:
git commit -m "feat: add support for new cron expression syntax" -
Push to your fork:
git push origin feature/your-feature-name -
Create a pull request on GitHub
Pull Request Guidelines
- Clear title and description explaining the changes
- Reference related issues using keywords like "Fixes #123" or "Closes #456"
- Include test coverage for new functionality
- Update documentation for user-facing changes
- Keep commits atomic - one logical change per commit
- Rebase your branch on the latest master before submitting
Commit Message Format
This project follows conventional commits format:
type(scope): short description
[optional body]
[optional footer]
Types:
feat- New featurefix- Bug fixdocs- Documentation changesstyle- Code style changes (formatting, etc.)refactor- Code refactoringtest- Adding or updating testschore- Maintenance tasks, dependency updates
Examples:
feat: add support for timezone in cron expressions
fix: handle edge case in day of week calculation
docs: update README with new examples
test: add coverage for CronDate edge cases
Coding Standards
TypeScript
- Use TypeScript for all source code
- Enable strict mode - the project uses strict TypeScript settings
- Provide proper type annotations for public APIs
- Use meaningful variable and function names
- Follow existing code patterns and conventions
Code Style
- Use Prettier for code formatting (configuration in
.prettierrc) - Use ESLint for code linting (configuration in
eslint.config.js) - Run
npm run formatbefore committing - Fix lint issues with
npm run lint:fix
File Organization
- Source code: Place in
src/directory - Tests: Place in
tests/directory with.test.tsextension - Exports: Update
src/index.tsfor public API changes - Types: Define types in appropriate files, shared types in
src/fields/types.ts
Testing
Unit Tests
- Write tests for all new functionality
- Use Jest as the testing framework
- Place tests in the
tests/directory - Follow the naming convention:
ComponentName.test.ts - Maintain high test coverage
Test Structure
describe('ComponentName', () => {
describe('methodName', () => {
it('should handle normal case', () => {
// Arrange
const input = 'test input';
// Act
const result = component.method(input);
// Assert
expect(result).toBe(expectedOutput);
});
it('should throw error for invalid input', () => {
expect(() => component.method(invalidInput)).toThrow('Expected error message');
});
});
});
Running Tests
# Run all tests
npm test
# Run tests in watch mode
npm run test:unit -- --watch
# Run specific test file
npm run test:unit -- CronExpression.test.ts
# Run tests with coverage
npm run test:coverage
Benchmarking
The project includes benchmarking tools to measure performance:
# Run benchmarks
npm run bench
# Run pattern-specific benchmarks
npm run bench:pattern
# Clean benchmark results
npm run bench:clean
The run can be tuned with environment variables:
# Compare against a specific published version instead of the latest release
PACKAGE_VERSION=5.6.2 npm run bench
# Shorten a run while iterating (defaults: 10000 iterations, 5 samples)
BENCHMARK_ITERATIONS=100 BENCHMARK_SAMPLES=1 npm run bench
Each run writes a timestamped .txt report and a benchmark-results.json summary to
benchmarks/results/, which is gitignored.
When making performance-related changes:
- Run benchmarks before your changes to establish baseline
- Run benchmarks after your changes to measure impact
- Include benchmark results in your pull request description
Documentation
Code Documentation
- Document public APIs with JSDoc comments
- Include examples in documentation where helpful
- Update TypeScript definitions for exported types
README Updates
- Update examples when adding new features
- Update API documentation links if needed
- Keep the feature list current
API Documentation
The project uses TypeDoc for API documentation:
npm run docs
Issue Guidelines
Bug Reports
When reporting bugs, please use the bug report template and include:
- Clear description of the issue
- Steps to reproduce the problem
- Expected vs actual behavior
- Environment information (Node.js version, OS, etc.)
- Minimal code example that demonstrates the issue
Feature Requests
For feature requests, please:
- Explain the use case and why the feature would be useful
- Provide examples of how the feature would be used
- Consider backwards compatibility implications
- Check if similar functionality already exists
Questions
For questions about usage:
- Check the README and API documentation first
- Search existing issues for similar questions
- Provide context about what you're trying to achieve
- Include relevant code examples
Getting Help
- Read the documentation: API docs
- Browse examples in the README
- Check existing issues on GitHub
- Ask questions by creating an issue with the "question" label
Recognition
Contributors will be acknowledged in:
- GitHub contributors list
- Release notes for significant contributions
- Special mentions for major features or fixes
Thank you for contributing to cron-parser!