Repo for useful js utilities
This monorepo has some useful javascript utilities that merge seamlessly with vanilla javascript
- Node.js >= 22
- pnpm >= 10.12.4
- Git
-
Clone the repository
git clone https://github.com/codibre/js-utils.git cd js-utils -
Install dependencies
pnpm install
-
Run tests
pnpm test -
Build packages
pnpm build
# Build all packages
pnpm build
# Run all tests
pnpm test
# Run tests with coverage
pnpm test:cov
# Lint all packages
pnpm lint
# Auto-fix linting issues
pnpm lint:fix
# Format code
pnpm prettier:fix
# Validate commit messages
pnpm commit:validateFocus on your logic, not formatting while developing. The project has automated tools to handle code style:
# After writing your code, run this to fix all formatting/linting issues:
pnpm lint:fixThis command will automatically:
- β Fix ESLint rule violations
- β Format code with Prettier
- β Organize imports
- β Remove unused variables
- β Apply consistent code style
Pre-commit hooks will also run these fixes automatically when you commit, so you can stay in the flow of coding without interruption!
- Strict TypeScript configuration
- Comprehensive type definitions
- TSDoc documentation for all public APIs
- Unit Tests: All business logic and utilities
- Integration Tests: Real HTTP request testing with spies
- Coverage: Maintained above 80%
- Test Structure: Descriptive names, success/error scenarios
We use Conventional Commits:
# Examples
feat(newrelic): add support for HTTP/2 instrumentation
fix(events): resolve memory leak in event emitter
docs(readme): update installation instructions
test(guard): add integration tests for transaction contextCommit Types:
feat: New featuresfix: Bug fixesdocs: Documentation changestest: Test additions or modificationsrefactor: Code refactoringperf: Performance improvementschore: Build process or auxiliary tool changes
The monorepo uses intelligent change detection to automatically:
- Detect Changed Packages: Only builds and tests packages that have changes
- Semantic Versioning: Automatically bumps versions based on conventional commits
- Automated Publishing: Publishes to npm registry when changes are merged to main
- Release Notes: Generates changelogs from commit messages
# Automatically triggers on:
# - Pull requests (run tests)
# - Push to main (run tests + publish if needed)
# - Manual dispatch (force publish)Pipeline Steps:
- Setup: Node.js, pnpm, dependencies
- Build: Compile TypeScript, generate types
- Test: Unit tests, integration tests, coverage
- Lint: Code style and formatting checks
- Publish: Automatic npm publishing for changed packages
Releases are fully automated:
- Commit Changes: Using conventional commit format
- Create PR: CI runs all tests and checks
- Merge to Main: Automatic version bump and publishing
- Monitor: Check npm and GitHub releases
We welcome contributions! Here's how to get started:
# Fork on GitHub, then clone your fork
git clone https://github.com/your-username/js-utils.git
cd js-utilsgit checkout -b feat/your-feature-name# Install dependencies
pnpm install
# Make your changes
# Add tests for new functionality
# Update documentation
# Validate your changes
pnpm build
pnpm test
pnpm lint# Use conventional commit format
git add .
git commit -m "feat(scope): description of your changes"
git push origin feat/your-feature-name- Provide clear description of changes
- Link any related issues
- Ensure all CI checks pass
- Code follows style guidelines
- Tests pass locally
- New functionality has tests
- Documentation is updated
- Commit messages follow conventional format
- No breaking changes (or properly documented)
- Identify Use Case: What isn't covered by existing instrumentation?
- Design Solution: Integration with existing components vs. new components
- Implement with Tests: Comprehensive unit and integration tests
- Documentation: Update README, add examples, document APIs
- Reproduce Issue: Create test demonstrating the bug
- Fix Minimally: Smallest change to resolve the issue
- Test Thoroughly: Verify fix + full test suite + edge cases
-
Create Package Directory
mkdir libs/your-new-package cd libs/your-new-package -
Package Configuration
# Create package.json with proper workspace config # Add to pnpm-workspace.yaml # Configure turbo.json for build pipeline
-
Development Setup
# Add scripts in turbo.json # Configure Jest for testing # Set up TypeScript configuration
- Use
--runInBandfor consistent test execution - Mock external dependencies (New Relic, databases, etc.)
- Test both success and error scenarios
- Maintain high coverage (>80%)
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check package-specific READMEs in
libs/ - Issues: GitHub Issues
- Discussions: GitHub Discussions
- β Battle-tested in high-traffic production environments
- β Comprehensive testing with >90% coverage
- β Performance optimized with minimal overhead
- β Error resilient with graceful degradation
- β TypeScript first with complete type definitions
- β Easy integration with minimal configuration
- β Extensive documentation with real-world examples
- β Active maintenance with regular updates
- β Distributed tracing across microservices
- β Custom transaction naming for better monitoring
- β Event-driven architecture for real-time insights
- β Background job instrumentation for complete visibility
Built with β€οΈ by Codibre