Thank you for your interest in contributing to OpenSource Framework! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Development Environment Setup
- Making Changes
- Coding Standards
- Testing Requirements
- Documentation Guidelines
- Package-Specific Notes
- Pull Request Process
This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the maintainers.
- Node.js: Version 20.0.0 or higher
- pnpm: Version 9.0.0 or higher
- Git: For version control
-
Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/opensourceframework.git cd opensourceframework -
Install dependencies
pnpm install
-
Verify setup
pnpm build pnpm test pnpm lint
We recommend using VS Code with the following extensions:
- ESLint
- Prettier
- TypeScript
Use descriptive branch names with the following prefixes:
feat/- New featuresfix/- Bug fixesdocs/- Documentation changesrefactor/- Code refactoringtest/- Test additions/modificationschore/- Maintenance tasks
Examples:
feat/next-csrf-add-optionsfix/critters-css-parsingdocs/update-readme
We follow Conventional Commits:
type(scope): description
[optional body]
[optional footer]
Types:
feat- New featurefix- Bug fixdocs- Documentation onlystyle- Code style changes (formatting, etc.)refactor- Code refactoringperf- Performance improvementstest- Adding/modifying testsbuild- Build system changesci- CI configuration changeschore- Other changesrevert- Revert previous commitdeps- Dependency updates
Scopes:
next-csrf- Changes to next-csrf packagenext-images- Changes to next-images packagecritters- Changes to critters packagerepo- Repository-level changesdeps- Dependency updatesrelease- Release-related changes
Examples:
feat(next-csrf): add support for custom token length
fix(critters): resolve CSS parsing issue with nested media queries
docs(repo): update contributing guide with new testing requirements
chore(deps): update typescript to v5.4.0
-
Create a branch
git checkout -b feat/your-feature
-
Make your changes
- Write code following our coding standards
- Add/update tests
- Update documentation
-
Test your changes
# Run tests for all packages pnpm test # Run tests for a specific package pnpm --filter @opensourceframework/next-csrf test # Run tests with coverage pnpm test:coverage
-
Lint and format
pnpm lint pnpm format
-
Create a changeset (for user-facing changes)
pnpm changeset
This will prompt you to:
- Select affected packages
- Choose version bump type (major/minor/patch)
- Write a description of the change
-
Commit your changes
git add . git commitThe commit message will be validated against our conventions.
-
Push and create a PR
git push origin feat/your-feature
- Use strict mode enabled in tsconfig
- Prefer explicit types over
any - Use type-only imports where possible
- Document public APIs with JSDoc comments
- Formatting is enforced via Prettier
- Linting rules are enforced via ESLint
- Run
pnpm formatbefore committing - Run
pnpm lintto check for issues
packages/[package-name]/
� src/
� � index.ts # Public exports
� � [module].ts # Module implementations
� � __tests__/ # Test files (co-located)
â� test/
� � index.test.ts # Integration tests
â� package.json
â� tsconfig.json
â� tsup.config.ts
� vitest.config.ts
- All new features must have tests
- Bug fixes should include regression tests
- Aim for at least 80% coverage on new code
# All tests
pnpm test
# Watch mode
pnpm --filter @opensourceframework/next-csrf test:watch
# Coverage report
pnpm test:coverage
# Specific test file
pnpm --filter @opensourceframework/next-csrf vitest run src/index.test.tsWe use Vitest. Example:
import { describe, it, expect } from 'vitest';
import { myFunction } from './myModule';
describe('myFunction', () => {
it('should return expected value', () => {
expect(myFunction('input')).toBe('expected output');
});
it('should handle edge cases', () => {
expect(myFunction('')).toBe('');
});
});- Update package README for package-specific changes
- Update root README for repository-level changes
- Keep API documentation accurate and complete
/**
* Generates a CSRF token.
* @param options - Configuration options
* @param options.length - Token length (default: 32)
* @returns A cryptographically secure token string
* @example
* ```typescript
* const token = generateToken({ length: 64 });
* ```
*/
export function generateToken(options?: { length?: number }): string {
// ...
}- Changes are automatically documented via Changesets
- Ensure your changeset description is clear and user-facing
- Breaking changes should be clearly marked
- Security-critical package
- All changes require thorough security review
- Must test with multiple Next.js versions
- Document any security implications
- Test with various image formats
- Verify compatibility with Next.js image optimization
- Check performance implications of changes
- Test CSS parsing with real-world stylesheets
- Verify no CSS specificity issues
- Check for cross-browser compatibility
- Code compiles without errors
- All tests pass
- Linting passes
- Documentation updated
- Changeset created (if applicable)
- PR description filled out completely
- Fill out the PR template completely
- Link related issues
- Request review from maintainers
- Address all review feedback
- Automated checks must pass (CI)
- At least one maintainer approval required
- All conversations must be resolved
- PR is squashed and merged
- Changes will be included in the next release
- Packages are automatically published via Changesets
- GitHub releases are automatically created
- Questions? Open a discussion on GitHub
- Bugs? Open an issue with the bug template
- Security issues? Follow our Security Policy
Thank you for contributing to OpenSource Framework! �