Thank you for your interest in contributing to Globlin! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Development Workflow
- Testing
- Benchmarking
- Code Style
- Submitting Changes
- Reporting Bugs
- Feature Requests
This project adheres to a code of conduct that all contributors are expected to follow. Please be respectful and constructive in all interactions.
Globlin is a hybrid Rust/Node.js project that uses NAPI-RS to create native bindings. Before contributing, familiarize yourself with:
- Node.js (v20.0.0 or higher)
- Rust (latest stable)
- NAPI-RS for native bindings
- The glob v13 API that we aim to replace
- Node.js 20.x or 22.x
- Rust (latest stable version)
- Cargo (comes with Rust)
- A C/C++ compiler toolchain for your platform
- Clone the repository:
git clone https://github.com/CapSoftware/globlin.git
cd globlin- Install Node.js dependencies:
npm install- Build the native module and TypeScript:
npm run buildFor development builds (faster, with debug symbols):
npm run build:debuggloblin/
├── src/ # Rust source code
├── js/ # TypeScript source code
├── tests/ # Test files
├── benches/ # Benchmark files
├── docs/ # Documentation
└── www/ # Website/landing page
- Create a new branch for your changes:
git checkout -b feature/your-feature-name-
Make your changes in the appropriate directory:
- Rust code:
src/ - TypeScript code:
js/ - Tests:
tests/ - Documentation:
docs/
- Rust code:
-
Build your changes:
npm run build- Run tests to ensure everything works:
npm test-
Full build (native + TypeScript):
npm run build
-
Native module only:
npm run build:native
-
TypeScript only:
npm run build:ts
-
Debug build (faster compilation):
npm run build:debug
-
Run all tests:
npm test -
Watch mode (for development):
npm run test:watch
-
With coverage:
npm run test:coverage
-
Type tests:
npm run test:types
- Place test files in the
tests/directory - Use descriptive test names that explain what is being tested
- Follow the existing test patterns in the codebase
- Ensure tests pass on all supported platforms (Linux, macOS, Windows)
Example test structure:
import { describe, it, expect } from 'vitest'
import { glob } from '../js/index.js'
describe('feature name', () => {
it('should do something specific', async () => {
const results = await glob('pattern')
expect(results).toEqual(['expected', 'results'])
})
})Globlin emphasizes performance. When making changes that could affect performance, run benchmarks:
-
Quick benchmark (small fixture):
npm run bench:small
-
Standard benchmark (medium fixture, 20k files):
npm run bench:medium
-
Full benchmark (large fixture, 100k files):
npm run bench:large
-
Comparison with fast-glob:
npm run bench:vs-fg
Before running benchmarks, you may need to generate test fixtures:
npm run bench:setupFor the large fixture (100k files):
npm run bench:setup:huge- We use ESLint and Prettier for TypeScript code
- Run linting:
npm run lint:ts
- Auto-fix issues:
npm run lint:fix
- Format code:
npm run format:ts
- We use Clippy and rustfmt for Rust code
- Run Clippy:
npm run lint:rust
- Format code:
npm run format:rust
-
Lint everything:
npm run lint
-
Format everything:
npm run format
-
Check formatting (CI):
npm run format:check
-
Before submitting:
- Ensure all tests pass:
npm test - Run linting:
npm run lint - Format code:
npm run format - Update documentation if needed
- Add/update tests for your changes
- Ensure all tests pass:
-
Commit guidelines:
- Write clear, descriptive commit messages
- Use conventional commit format when possible:
feat:for new featuresfix:for bug fixesdocs:for documentation changesperf:for performance improvementstest:for test changesrefactor:for code refactoringchore:for maintenance tasks
-
Submit your PR:
- Push your branch to your fork
- Open a pull request against the
mainbranch - Fill out the PR template with:
- Clear description of changes
- Related issue numbers (if applicable)
- Screenshots/benchmarks (if applicable)
- Breaking changes (if any)
-
Review process:
- Maintainers will review your PR
- Address any feedback or requested changes
- Once approved, a maintainer will merge your PR
- Tests pass locally (
npm test) - Code is linted (
npm run lint) - Code is formatted (
npm run format) - Documentation is updated (if needed)
- CHANGELOG.md is updated (for significant changes)
- Benchmarks run (for performance-related changes)
- PR description clearly explains the changes
When reporting bugs, please include:
- Description: Clear description of the bug
- Steps to reproduce: Minimal code example that demonstrates the issue
- Expected behavior: What you expected to happen
- Actual behavior: What actually happened
- Environment:
- Node.js version (
node --version) - Operating system and version
- Globlin version
- Any relevant error messages or stack traces
- Node.js version (
Use the GitHub issue tracker to report bugs.
We welcome feature requests! When proposing a new feature:
- Check existing issues: Ensure it hasn't been requested already
- Describe the use case: Why is this feature needed?
- Propose a solution: How should it work?
- Consider compatibility: How does it affect the glob v13 API compatibility?
- Performance impact: Consider performance implications
Globlin aims to be a drop-in replacement for glob v13. When contributing:
- Maintain 100% API compatibility with glob v13
- Don't break existing behavior unless fixing a bug
- If adding new features, ensure they're additive and optional
- Test against the glob test suite when possible
Globlin's primary goal is performance. When contributing:
- Consider the performance impact of your changes
- Run benchmarks for performance-related changes
- Optimize for the common case (large directories, simple patterns)
- Profile your changes if adding new features
- Document any performance trade-offs
Ensure your changes work on all supported platforms:
- Operating Systems: Linux, macOS, Windows
- Architectures: x64, ARM64
- Node.js versions: 20.x, 22.x
- Questions: Open a discussion
- Chat: Join our community (link TBD)
- Documentation: Check the docs directory
By contributing to Globlin, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to Globlin!