Thank you for your interest in contributing to DevPockit! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Development Workflow
- Coding Standards
- Project Structure
- Adding New Tools
- Testing Guidelines
- Documentation
- Submitting Changes
- Getting Help
This project adheres to a Code of Conduct that all contributors are expected to follow. Please read CODE_OF_CONDUCT.md before contributing.
Before you begin, ensure you have the following installed:
- Node.js: Version 18+ (recommended: Node.js 20+)
- pnpm: Version 8+ (package manager)
- Git: Latest version
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/devpockit.git cd devpockit - Add the upstream repository:
git remote add upstream https://github.com/hypkey/devpockit.git
-
Install dependencies:
pnpm install
-
(Optional) Set up environment variables:
cp .env.example .env.local
Note: Environment variables are optional for local development.
# Start the development server
pnpm dev
# The application will be available at:
# http://localhost:3000 (or 3001 if 3000 is busy)The development server includes:
- Hot module replacement (HMR)
- Fast refresh for React components
- TypeScript type checking
- ESLint error reporting
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage
# Run tests for CI
pnpm test:ci# Run ESLint
pnpm lint
# Fix ESLint issues automatically
pnpm lint:fix
# Run TypeScript type checking
pnpm type-check
# Format code with Prettier
pnpm format
# Check code formatting
pnpm format:check# Build the application
pnpm build
# Start production server
pnpm start
# Preview production build locally
pnpm previewCreate branches using the following naming conventions:
- Features:
feature/description-of-feature- Example:
feature/add-base64-encoder
- Example:
- Bug fixes:
fix/description-of-bug- Example:
fix/json-formatter-error-handling
- Example:
- Documentation:
docs/description-of-docs- Example:
docs/update-contributing-guide
- Example:
- Refactoring:
refactor/description-of-refactor- Example:
refactor/tool-component-structure
- Example:
- Performance:
perf/description-of-improvement- Example:
perf/optimize-bundle-size
- Example:
We follow Conventional Commits specification:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, missing semicolons, etc.)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasksci: CI/CD changes
Examples:
feat(json-formatter): add syntax highlighting support
fix(uuid-generator): handle edge case for v1 UUIDs
docs(readme): update installation instructions
refactor(tools): extract common tool logic to shared utilitiesThis project uses a two-branch model:
| Branch | Purpose |
|---|---|
main |
Production only β updated exclusively by release PRs. Always stable. |
develop |
Active development β feature branches merge here. |
Fork users who sync main will always get released, stable code.
-
Update your fork:
git checkout develop git pull upstream develop git push origin develop
-
Create a feature branch from
develop:git checkout -b feature/your-feature-name
-
Make your changes:
- Write clean, well-documented code
- Follow coding standards
- Add tests for new features
- Update documentation as needed
-
Test your changes:
pnpm lint pnpm type-check pnpm test pnpm build -
Commit your changes:
git add . git commit -m "feat: your descriptive commit message"
-
Push to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request targeting
develop:- Go to the GitHub repository
- Click "New Pull Request"
- Set base to
develop(notmain) - Select your branch
- Fill out the PR template
- Link any related issues
- Request review from maintainers
-
Respond to feedback:
- Address review comments
- Make requested changes
- Update the PR as needed
- Strict Mode: Enabled for type safety
- Type Definitions: Prefer proper typing for functions and components
- Any Types:
anytypes are allowed when necessary, but prefer specific types when possible - Interfaces: Use interfaces for object shapes
- Types: Use types for unions, intersections, and complex types
Preferred:
interface ToolResult {
success: boolean;
data?: string;
error?: string;
}
function formatJson(input: string): ToolResult {
// Implementation
}Acceptable (when needed):
function formatJson(input: any): any {
// Implementation - use when type is truly unknown or dynamic
}- Functional Components: Use functional components with hooks
- Component Structure: Follow this order:
- Imports
- Types/Interfaces
- Component definition
- Exports
Example:
import { useState } from 'react';
import { Button } from '@/components/ui/button';
interface JsonFormatterProps {
onResult: (result: string) => void;
onError: (error: string) => void;
}
export function JsonFormatter({ onResult, onError }: JsonFormatterProps) {
const [input, setInput] = useState('');
// Component logic
return (
<div>
{/* JSX */}
</div>
);
}- Component files: PascalCase (e.g.,
JsonFormatter.tsx,UserProfile.tsx) - UI component files: kebab-case (shadcn/ui convention, e.g.,
button.tsx,input.tsx) - Route folders: kebab-case/lowercase (e.g.,
user-profile/,api/) - Route files: lowercase special files (
page.tsx,layout.tsx,route.ts) - Utility/config files: kebab-case or camelCase (e.g.,
utils.ts,api-config.ts) - Hook files: camelCase (e.g.,
useMobile.tsx,useMonacoEditor.ts)
- Indentation: 2 spaces
- Quotes: Double quotes for JSX, single quotes for JavaScript (or follow Prettier)
- Semicolons: Use semicolons
- Line Length: Maximum 100 characters (Prettier will handle this)
- Trailing Commas: Use trailing commas in multi-line objects/arrays
- Absolute Imports: Use path aliases (
@/components,@/libs, etc.) - Import Order:
- External dependencies
- Internal absolute imports
- Relative imports
- Type imports (use
import type)
Example:
import { useState, useEffect } from 'react';
import { Button } from '@/components/ui/button';
import { formatJson } from '@/libs/json-formatter';
import type { ToolResult } from '@/types/tools';- JSDoc: Use JSDoc for public APIs and complex functions
- Inline Comments: Explain "why", not "what"
- TODO Comments: Use
// TODO: descriptionfor future improvements
Example:
/**
* Formats JSON string with optional minification.
*
* @param input - The JSON string to format
* @param minify - Whether to minify the output
* @returns Formatted or minified JSON string
* @throws {Error} If input is not valid JSON
*/
export function formatJson(input: string, minify: boolean = false): string {
// Implementation
}devpockit/
βββ src/
β βββ app/ # Next.js 15 App Router
β β βββ globals.css # Global styles
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Home page
β βββ components/ # React components
β β βββ ui/ # Shadcn/ui components
β β βββ tools/ # Tool-specific components
β β βββ layout/ # Layout components
β β βββ pages/ # Page components
β βββ libs/ # Utility functions and tool logic
β βββ config/ # Tool configurations
β βββ hooks/ # Custom React hooks
β βββ types/ # TypeScript type definitions
βββ public/ # Static assets
βββ .github/ # GitHub templates and workflows
βββ docs/ # Documentation
βββ scripts/ # Build and utility scripts
src/app/: Next.js App Router pages and layoutssrc/components/ui/: Reusable UI components (Shadcn/ui)src/components/tools/: Tool-specific React componentssrc/libs/: Core tool logic and utilitiessrc/config/: Tool configuration filessrc/hooks/: Custom React hookssrc/types/: Shared TypeScript types
To add a new developer tool to DevPockit:
-
Create tool logic in
src/libs/:// src/libs/your-tool.ts export function processYourTool(input: string): string { // Tool logic }
-
Create tool configuration in
src/config/:// src/config/your-tool-config.ts export const yourToolConfig = { id: 'your-tool', name: 'Your Tool', category: 'utilities', // ... other config };
-
Create tool component in
src/components/tools/:// src/components/tools/YourTool.tsx export function YourTool() { // Component implementation }
-
Add tool to tools data in
src/libs/tools-data.ts -
Create route in
src/app/tools/[category]/[toolId]/page.tsx(if needed) -
Write tests in
__tests__/directory -
Update documentation:
- Add to README.md
- Update CHANGELOG.md
- Add usage examples
- Unit Tests: Test individual functions and utilities
- Component Tests: Test React components in isolation
- Integration Tests: Test tool workflows end-to-end
// __tests__/libs/json-formatter.test.ts
import { formatJson } from '@/libs/json-formatter';
describe('formatJson', () => {
it('should format valid JSON', () => {
const input = '{"name":"test"}';
const result = formatJson(input, false);
expect(result).toBe('{\n "name": "test"\n}');
});
it('should handle invalid JSON', () => {
const input = 'invalid json';
expect(() => formatJson(input, false)).toThrow();
});
});- Coverage: Aim for 80%+ code coverage
- Test Names: Use descriptive test names
- Test Organization: Group related tests with
describeblocks - Assertions: Use appropriate matchers
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage
# Run specific test file
pnpm test json-formatter.test.ts- JSDoc: Document all public functions and components
- Type Definitions: Document complex types and interfaces
- README Comments: Add comments for complex logic
- README.md: Keep installation and usage instructions updated
- CHANGELOG.md: Document all changes in each release
- API Documentation: Document tool APIs if applicable
When adding features:
- Update README.md if adding new tools or features
- Update CHANGELOG.md with your changes
- Add JSDoc comments to new functions
- Update relevant documentation files
Ensure your code:
- Follows coding standards
- Passes all tests (
pnpm test) - Passes linting (
pnpm lint) - Passes type checking (
pnpm type-check) - Builds successfully (
pnpm build) - Includes tests for new features
- Updates documentation as needed
- Follows commit message conventions
- Updates CHANGELOG.md (if applicable)
When creating a PR:
- Descriptive title and description
- Links to related issues
- Screenshots (for UI changes)
- Tests added/updated
- Documentation updated
- No breaking changes (or clearly documented)
- Follows PR template
- Automated Checks: CI will run tests and linting
- Code Review: Maintainers will review your code
- Feedback: Address any requested changes
- Approval: Once approved, your PR will be merged
- GitHub Discussions: Use for questions and general discussions
- GitHub Issues: Use for bug reports and feature requests
- Security Issues: Report to [security@example.com] (use private reporting)
- Documentation: Check README.md and docs/ directory
- Examples: Look at existing tools for reference
- Code: Review similar implementations in the codebase
- Be respectful and professional
- Provide context when asking questions
- Search existing issues/discussions before creating new ones
- Be patient - maintainers are volunteers
Contributors will be:
- Listed in the project's contributors
- Credited in release notes
- Appreciated by the community!
Thank you for contributing to DevPockit! π