Thank you for your interest in contributing to slottify! This document provides guidelines and information for contributors.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Pull Request Process
- Code Style
- Documentation
This project is committed to providing a welcoming and inclusive environment for all contributors. Please be respectful and considerate in all interactions.
- Node.js >= 18
- npm >= 8
- Git
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/your-username/slottify.git cd slottify - Add the upstream remote:
git remote add upstream https://github.com/dsfcoll/slottify.git
npm installnpm run buildFor development with watch mode:
npm run devAlways create a new branch for your changes:
git checkout -b feature/your-feature-nameOr for bug fixes:
git checkout -b fix/your-bug-description- Follow the existing code style (see Code Style)
- Write tests for new functionality
- Update documentation if needed
- Keep commits atomic - one logical change per commit
Use conventional commit format:
type(scope): description
[optional body]
[optional footer]
Examples:
feat(filters): add reverse filterfix(parser): handle edge case in ternary expressionsdocs(readme): update installation instructionstest(engine): add tests for custom filters
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
# Run all tests
npm test
# Run tests with coverage
npm run coverage
# Run tests in debug mode
npm run test:debug
# Run tests in watch mode
npm test -- --watch- Tests should be in
.spec.tsfiles alongside the source code - Use descriptive test names
- Test both success and error cases
- Test edge cases and boundary conditions
Example test structure:
describe('TemplateEngine', () => {
let engine: TemplateEngine;
beforeEach(() => {
engine = new TemplateEngine();
});
describe('Feature Name', () => {
it('should handle normal case', () => {
const result = engine.render('{{ variable }}', { variable: 'value' });
expect(result).toBe('value');
});
it('should handle edge case', () => {
const result = engine.render('{{ variable }}', {});
expect(result).toBe('');
});
it('should throw error for invalid input', () => {
expect(() => {
engine.render('{{ variable | unknown }}', { variable: 'value' });
}).toThrow('Unknown filter: unknown');
});
});
});-
Ensure tests pass:
npm test npm run coverage -
Check code style:
npm run lint:fix
-
Build the project:
npm run build
-
Update documentation if your changes affect the public API
-
Update CHANGELOG.md with your changes under the [Unreleased] section
-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub
-
Fill out the PR template with:
- Description of changes
- Related issue (if any)
- Testing performed
- Breaking changes (if any)
-
Request review from maintainers
- All PRs require at least one review
- Address review comments promptly
- Keep the PR focused and manageable in size
- Update the PR if requested changes are made
- Use TypeScript for all new code
- Prefer interfaces over types for object shapes
- Use explicit return types for public methods
- Use
anysparingly, preferunknownwhen type is truly unknown
- Classes: PascalCase (
TemplateEngine) - Functions/Methods: camelCase (
render,addFilter) - Variables: camelCase (
template,context) - Constants: UPPER_SNAKE_CASE (
MAX_FILTER_ARGS) - Interfaces: PascalCase with descriptive names (
TemplateNode)
- Keep functions small and focused
- Use meaningful variable names
- Add comments for complex logic
- Group related functionality together
- Use descriptive error messages
- Throw errors for invalid inputs
- Handle edge cases gracefully
- Log errors for debugging when appropriate
- Add JSDoc comments for public methods
- Include parameter types and return types
- Provide usage examples for complex methods
Example:
/**
* Renders a template string with the provided context.
*
* @param template - The template string to render
* @param context - Optional context object containing variables
* @returns The rendered template string
*
* @example
* ```javascript
* const engine = new TemplateEngine();
* const result = engine.render('Hello {{ name }}!', { name: 'World' });
* // Returns: "Hello World!"
* ```
*/
render(template: string, context?: Record<string, any>): string {
// Implementation...
}When making changes that affect the public API:
- Update README.md with new features/examples
- Update API.md with detailed documentation
- Add migration notes if breaking changes
- Update CHANGELOG.md
- Update version in
package.json - Update CHANGELOG.md:
- Move [Unreleased] content to new version
- Update release date
- Create release tag:
git tag v0.1.5 git push origin v0.1.5
- Publish to npm:
npm publish
- All tests pass
- Documentation is up to date
- CHANGELOG.md is updated
- Version is bumped in package.json
- Release is tagged
- Package is published to npm
- Issues: Use GitHub Issues for bug reports and feature requests
- Discussions: Use GitHub Discussions for questions and general discussion
- Security: Report security issues privately to maintainers
Contributors will be recognized in:
- GitHub contributors list
- CHANGELOG.md for significant contributions
- README.md for major contributors
Thank you for contributing to slottify! 🧩