Thank you for your interest in contributing! This document provides guidelines for contributing to the RTF toolkit.
This project follows the Contributor Covenant Code of Conduct. By participating, you agree to uphold this code.
Before creating bug reports, please check existing issues to avoid duplicates. When creating a bug report, include:
- Clear title describing the issue
- RTF sample that reproduces the problem (if possible)
- Expected behavior vs actual behavior
- Environment details (Node.js version, browser, OS)
- Error messages and stack traces
Use the bug report template when creating issues.
Feature requests are welcome! Please:
- Check existing issues/PRs for similar requests
- Provide clear use case and motivation
- Include example RTF input/output if applicable
- Consider implementation complexity
DO NOT report security vulnerabilities via public issues!
See SECURITY.md for instructions on responsible disclosure.
# Clone the repository
git clone https://github.com/jonahschulte/rtf-toolkit.git
cd rtf-toolkit
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build- Fork the repository and create a branch from
main - Write tests for your changes (TDD approach preferred)
- Implement your changes following the coding standards below
- Run the test suite - all tests must pass
- Run the linter -
npm run lint - Build successfully -
npm run build - Update documentation if needed
We follow Conventional Commits:
feat: add table parsing support
fix: handle nested revision groups correctly
docs: update API reference for track changes
test: add security tests for DoS protection
perf: optimize string concatenation in tokenizer
Types:
feat: New featurefix: Bug fixdocs: Documentation changestest: Adding or updating testsperf: Performance improvementsrefactor: Code refactoringchore: Build process or tooling changes
- Update tests - Ensure your changes are covered
- Update README - If adding new features
- Update CHANGELOG.md - Add entry under "Unreleased"
- Ensure CI passes - All checks must be green
- Request review - Maintainers will review your PR
- Address feedback - Make requested changes promptly
- Write tests before implementing (TDD)
- Aim for high coverage (we target 95%+)
- Test edge cases and error conditions
- Include security tests for parsing features
describe('Feature Name', () => {
it('should handle normal case', () => {
// Test expected behavior
});
it('should handle edge case', () => {
// Test boundaries
});
it('should reject malicious input', () => {
// Test security
});
});TypeScript:
- Use TypeScript (strict mode when possible)
- Provide type definitions for all public APIs
- Avoid
any- use proper types - Document complex types with JSDoc
Code Style:
- Run
npm run formatbefore committing (Prettier) - Follow existing code patterns
- Keep functions small and focused
- Use descriptive names
Performance:
- Avoid O(n²) algorithms
- Use array accumulation instead of string concatenation in loops
- Consider memory impact for large documents
Security:
- Validate all inputs at API boundaries
- Escape output properly (HTML, CSS, attributes)
- Add bounds checking for loops and allocations
- Include security tests
rtf-toolkit/
├── src/
│ ├── parser/ # Tokenizer and parser
│ ├── renderers/ # Output renderers (HTML, text, etc.)
│ ├── track-changes/ # Track changes API
│ └── index.ts # Public API
├── tests/
│ ├── unit/ # Unit tests
│ └── security/ # Security tests
├── examples/ # Usage examples
└── docs/ # Additional documentation
The library follows a clear pipeline:
RTF String → Tokenizer → Token Stream → Parser → AST → Renderer → Output
Each stage should be:
- Independent and testable
- Single responsibility
- Type-safe
New Control Words:
- Add to appropriate handler in
parser.ts - Update AST types if needed
- Add tests
- Update documentation
New Renderers:
- Create
src/renderers/[format].ts - Implement render functions for all node types
- Export from
src/index.ts - Add comprehensive tests
- Update README with examples
New RTF Features:
- Update tokenizer if new syntax needed
- Update parser to build AST nodes
- Update all renderers to handle new nodes
- Add tests at each layer
- Document in README
Pull requests will be reviewed for:
- ✅ Functionality - Does it work as intended?
- ✅ Tests - Are changes well-tested?
- ✅ Performance - No algorithmic regressions?
- ✅ Security - Input validation and output escaping?
- ✅ Documentation - README and JSDoc updated?
- ✅ Code Quality - Follows style guide?
- ✅ Breaking Changes - Are they necessary and documented?
(For maintainers)
- Update version in
package.json - Update
CHANGELOG.mdwith release notes - Create git tag:
git tag v0.x.0 - Push tag:
git push origin v0.x.0 - Publish to npm:
npm publish --access public - Create GitHub release with notes
- Questions? Open a discussion on GitHub
- Stuck? Ask in PR comments
- Found a bug? Create an issue
- Security issue? See SECURITY.md
Contributors are recognized in:
- GitHub contributors graph
- Release notes
- Special thanks in major releases
Thank you for helping make RTF parsing better for everyone! 🎉