First off, thank you for considering contributing to @usex/rule-engine! It's people like you that make this project better for everyone.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Coding Standards
- Testing
- Documentation
- Pull Request Process
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
- Fork the repository on GitHub
- Clone your fork locally
- Set up the development environment
- Create a branch for your changes
- Make your changes
- Submit a pull request
- Node.js >= 18.12.0
- pnpm >= 10.11.0
# Clone your fork
git clone https://github.com/YOUR_USERNAME/rule-engine.git
cd rule-engine
# Install dependencies
pnpm install
# Build all packages
pnpm buildrule-engine/
├── packages/
│ ├── core/ # Core rule engine library
│ └── builder/ # Visual rule builder UI
├── apps/
│ └── web/ # Documentation website
└── docs/ # Additional documentation
Before creating bug reports, please check existing issues. When creating a bug report, include:
- Clear title and description
- Steps to reproduce
- Expected behavior
- Actual behavior
- Code samples (if applicable)
- Environment details (Node version, OS, etc.)
Feature suggestions are welcome! Please:
- Check existing issues first
- Provide clear use cases
- Explain the benefits
- Consider implementation details
- Small changes: Bug fixes, documentation updates
- Large changes: New features, significant refactoring (discuss first in an issue)
- Use TypeScript for all new code
- Enable strict mode
- Provide proper types (avoid
any) - Document complex types
// Good
export function evaluateRule<T>(
rule: RuleType<T>,
data: unknown
): Promise<EvaluationResult<T>> {
// Implementation
}
// Bad
export function evaluateRule(rule: any, data: any): any {
// Implementation
}- Files: kebab-case (e.g.,
rule-engine.ts) - Classes: PascalCase (e.g.,
RuleEngine) - Functions/Variables: camelCase (e.g.,
evaluateRule) - Constants: UPPER_SNAKE_CASE (e.g.,
MAX_DEPTH) - Types/Interfaces: PascalCase (e.g.,
RuleType)
/**
* Evaluates a rule against the provided criteria.
*
* @param rule - The rule to evaluate
* @param criteria - The data to evaluate against
* @param trustRule - Skip validation if true
* @returns The evaluation result
*
* @example
* ```typescript
* const result = await evaluateRule(rule, { age: 25 });
* ```
*/# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage
# Run specific package tests
cd packages/core && pnpm testdescribe('RuleEngine', () => {
describe('evaluate', () => {
it('should evaluate simple rule correctly', async () => {
const rule = {
conditions: {
and: [
{ field: 'age', operator: 'greater-than', value: 18 }
]
}
};
const result = await RuleEngine.evaluate(rule, { age: 25 });
expect(result.isPassed).toBe(true);
expect(result.value).toBe(true);
});
});
});- Write tests for all new features
- Maintain or improve code coverage
- Test edge cases
- Include integration tests for complex features
- Document all public APIs
- Include JSDoc comments
- Provide usage examples
- Explain complex algorithms
Update relevant README files when:
- Adding new features
- Changing APIs
- Adding new operators
- Fixing significant bugs
packages/core/
├── README.md # Package documentation
└── docs/
├── api-reference.md
├── operators.md
└── best-practices.md
- Update documentation for any API changes
- Add tests for new functionality
- Run all tests locally
- Update CHANGELOG if applicable
- Ensure code follows style guidelines
<type>(<scope>): <subject>
Examples:
feat(core): add new date-between operator
fix(builder): resolve focus issue in field selector
docs(core): update migration guide
feat: New featurefix: Bug fixdocs: Documentation onlystyle: Code style changesrefactor: Code refactoringperf: Performance improvementstest: Test additions/changeschore: Maintenance tasks
## Description
Brief description of changes
## Motivation
Why these changes are needed
## Changes
- Change 1
- Change 2
## Testing
How the changes were tested
## Breaking Changes
List any breaking changes
## Related Issues
Fixes #123- Automated checks must pass
- Code review by maintainers
- Address feedback promptly
- Squash commits if requested
Feel free to:
- Open an issue for questions
- Join discussions in existing issues
- Contact maintainers
Thank you for contributing! 🎉