Contributing to jsonpathx
Thank you for your interest in contributing to jsonpathx! This guide will help you get started.
Ways to Contribute
There are many ways to contribute to jsonpathx:
- Report bugs and request features via GitHub Issues
- Improve documentation
- Submit pull requests with bug fixes or new features
- Help answer questions in Discussions
- Share your use cases and examples
- Spread the word about jsonpathx
Development Setup
Prerequisites
- Node.js 18.0.0 or higher
- npm 9.0.0 or higher
- Git
Getting Started
- Fork and clone the repository
git clone https://github.com/jsonpathx/jsonpathx.git
cd jsonpathx- Install dependencies
npm install- Build the project
npm run build- Run tests
npm test- Start development mode
npm run test:watchProject Structure
jsonpathx/
├── src/
│ ├── core/ # Main TypeScript package
│ │ ├── src/ # Source code
│ │ └── tests/ # Tests
│ ├── types/ # Shared TypeScript types
│ └── compat/ # Compatibility layer
├── docs/ # VitePress documentation
├── tools/ # Build scripts
└── examples/ # Example projectsDevelopment Workflow
Making Changes
- Create a branch
git checkout -b feature/your-feature-name- Make your changes
- Write code following our style guide
- Add tests for new features
- Update documentation as needed
- Run tests
npm test
npm run lint- Commit your changes
git add .
git commit -m "feat: add new feature"We follow Conventional Commits:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changestest:- Test additions or changesrefactor:- Code refactoringperf:- Performance improvementschore:- Build process or tooling changes
- Push and create a pull request
git push origin feature/your-feature-nameThen open a pull request on GitHub.
Writing Tests
We use Vitest for testing. Tests should be comprehensive and cover:
- Normal use cases
- Edge cases
- Error conditions
- Performance regressions
Test Example
import { describe, it, expect } from 'vitest';
import { JSONPath } from '../src/query';
describe('JSONPath.query', () => {
it('should query simple paths', async () => {
const data = { name: 'John' };
const result = await JSONPath.query('$.name', data);
expect(result).toEqual(['John']);
});
it('should handle errors gracefully', async () => {
const data = { name: 'John' };
await expect(
JSONPath.query('$.invalid..syntax', data)
).rejects.toThrow();
});
});Running Tests
# Run all tests
npm test
# Watch mode
npm run test:watch
# Coverage
npm run test:coverageCode Style
We use ESLint and Prettier for code formatting:
# Check formatting
npm run lint
# Fix formatting
npm run formatStyle Guidelines
- Use TypeScript strict mode
- Prefer
constoverlet - Use descriptive variable names
- Add JSDoc comments for public APIs
- Keep functions small and focused
- Write self-documenting code
Example
/**
* Execute a JSONPath query
*
* @param path - JSONPath expression
* @param data - JSON data to query
* @param options - Query options
* @returns Array of results
*/
export async function query<T>(
path: string,
data: unknown,
options?: QueryOptions
): Promise<T[]> {
// Implementation
}Documentation
Writing Documentation
Documentation is written in Markdown using VitePress.
- Preview documentation locally
npm run docs:dev- Edit documentation files
Documentation files are in docs/:
docs/guide/- User guidesdocs/api/- API referencedocs/examples/- Examples
- Build documentation
npm run docs:build
npm run docs:previewDocumentation Guidelines
- Use clear, concise language
- Include code examples
- Add TypeScript type annotations
- Link to related documentation
- Keep examples runnable
Engine Development
The JS engine lives in src/core/js-engine.ts and will evolve into a native parser/evaluator.
Pull Request Process
Before submitting:
- Run all tests
- Update documentation
- Add tests for new features
- Follow code style guidelines
- Rebase on latest main
PR requirements:
- Clear description of changes
- Link to related issues
- All tests passing
- Code coverage maintained
- Documentation updated
Review process:
- Maintainers will review your PR
- Address feedback promptly
- Keep PR focused and atomic
- Be patient and respectful
After approval:
- Maintainers will merge your PR
- Your contribution will be included in the next release
- You'll be added to contributors list
Reporting Bugs
Good bug reports help us fix issues quickly. Please include:
- Description - Clear description of the bug
- Steps to reproduce - Minimal steps to reproduce
- Expected behavior - What should happen
- Actual behavior - What actually happens
- Environment - OS, Node.js version, package version
- Additional context - Screenshots, error messages, etc.
Bug Report Template
## Description
A clear description of the bug.
## Steps to Reproduce
1. Create data: `const data = { ... }`
2. Run query: `await JSONPath.query('...', data)`
3. See error
## Expected Behavior
The query should return [...]
## Actual Behavior
The query throws an error: [...]
## Environment
- OS: macOS 14.0
- Node.js: v18.17.0
- jsonpathx: v0.1.0
## Additional Context
Error stack trace:
\`\`\`
...
\`\`\`Requesting Features
Feature requests help shape the future of jsonpathx. Please include:
- Use case - What problem does this solve?
- Proposed solution - How should it work?
- Alternatives - What alternatives have you considered?
- Examples - Show example usage
Code of Conduct
We are committed to providing a welcoming and inclusive environment:
- Be respectful and considerate
- Welcome newcomers
- Focus on constructive feedback
- Respect different viewpoints
- Report unacceptable behavior
Getting Help
- GitHub Discussions - Ask questions
- Documentation - Read the guides
- Examples - See examples
- API Reference - Explore the API
Recognition
Contributors are recognized in:
- CHANGELOG.md
- Contributors page
- Release notes
Thank you for contributing to jsonpathx!