contributing-guide
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseContributing Guide Expert
贡献指南专家
Эксперт по документации для open source contributors.
开源项目贡献者文档专家。
Структура CONTRIBUTING.md
CONTRIBUTING.md结构
markdown
undefinedmarkdown
undefinedContributing to Project Name
Contributing to Project Name
Thank you for your interest in contributing! 🎉
Thank you for your interest in contributing! 🎉
Table of Contents
Table of Contents
Quick Start Section
快速入门章节
markdown
undefinedmarkdown
undefinedQuick Start
Quick Start
- Fork the repository
- Clone your fork:
bash
git clone https://github.com/YOUR_USERNAME/project-name.git cd project-name - Install dependencies:
bash
npm install - Create a branch:
bash
git checkout -b feature/your-feature-name - Make changes and test:
bash
npm test - Submit a PR!
undefined- Fork the repository
- Clone your fork:
bash
git clone https://github.com/YOUR_USERNAME/project-name.git cd project-name - Install dependencies:
bash
npm install - Create a branch:
bash
git checkout -b feature/your-feature-name - Make changes and test:
bash
npm test - Submit a PR!
undefinedDevelopment Environment
开发环境
markdown
undefinedmarkdown
undefinedDevelopment Setup
Development Setup
Prerequisites
Prerequisites
- Node.js 18+ (download)
- npm 8+ or yarn 1.22+
- Git 2.28+
- Docker (optional, for integration tests)
- Node.js 18+ (download)
- npm 8+ or yarn 1.22+
- Git 2.28+
- Docker (optional, for integration tests)
Installation
Installation
bash
undefinedbash
undefinedClone repository
Clone repository
git clone https://github.com/org/project.git
cd project
git clone https://github.com/org/project.git
cd project
Install dependencies
Install dependencies
npm install
npm install
Copy environment file
Copy environment file
cp .env.example .env
cp .env.example .env
Run setup script
Run setup script
npm run setup
npm run setup
Verify installation
Verify installation
npm test
undefinednpm test
undefinedAvailable Scripts
可用脚本
| Command | Description |
|---|---|
| Start development server |
| Run all tests |
| Run tests in watch mode |
| Run ESLint |
| Fix linting issues |
| Run TypeScript checks |
| Build for production |
undefined| Command | Description |
|---|---|
| Start development server |
| Run all tests |
| Run tests in watch mode |
| Run ESLint |
| Fix linting issues |
| Run TypeScript checks |
| Build for production |
undefinedGit Workflow
Git工作流
markdown
undefinedmarkdown
undefinedGit Workflow
Git Workflow
Branch Naming Convention
分支命名规范
<type>/<short-description>Types:
- - New features
feature/ - - Bug fixes
fix/ - - Documentation only
docs/ - - Code refactoring
refactor/ - - Adding tests
test/ - - Maintenance tasks
chore/
Examples:
feature/user-authenticationfix/login-redirect-loopdocs/api-examples
<type>/<short-description>类型:
- - 新功能
feature/ - - Bug修复
fix/ - - 仅文档更新
docs/ - - 代码重构
refactor/ - - 添加测试
test/ - - 维护任务
chore/
示例:
feature/user-authenticationfix/login-redirect-loopdocs/api-examples
Commit Messages
提交信息
We follow Conventional Commits:
<type>(<scope>): <description>
[optional body]
[optional footer(s)]Types:
- : New feature
feat - : Bug fix
fix - : Documentation
docs - : Formatting (no code change)
style - : Code refactoring
refactor - : Adding tests
test - : Maintenance
chore
Examples:
feat(auth): add OAuth2 support
fix(api): handle null response from server
docs(readme): update installation stepsundefined我们遵循Conventional Commits:
<type>(<scope>): <description>
[optional body]
[optional footer(s)]类型:
- : 新功能
feat - : Bug修复
fix - : 文档更新
docs - : 格式调整(无代码逻辑变更)
style - : 代码重构
refactor - : 添加测试
test - : 维护任务
chore
示例:
feat(auth): add OAuth2 support
fix(api): handle null response from server
docs(readme): update installation stepsundefinedPull Request Template
拉取请求模板
markdown
undefinedmarkdown
undefinedPull Request Guidelines
Pull Request Guidelines
Before Submitting
提交前检查
- I have read the Contributing Guide
- My code follows the project's style guidelines
- I have performed a self-review
- I have added tests for my changes
- All new and existing tests pass
- I have updated documentation if needed
- My commits follow conventional commit format
- 我已阅读贡献指南
- 我的代码符合项目风格规范
- 我已完成自我审查
- 我为变更添加了测试
- 所有新测试和现有测试均通过
- 必要时我已更新文档
- 我的提交信息符合规范提交格式
PR Template
PR模板
markdown
undefinedmarkdown
undefinedDescription
描述
<!-- Describe your changes -->
<!-- 描述你的变更内容 -->
Type of Change
变更类型
- Bug fix (non-breaking change)
- New feature (non-breaking change)
- Breaking change
- Documentation update
- Bug修复(非破坏性变更)
- 新功能(非破坏性变更)
- 破坏性变更
- 文档更新
How Has This Been Tested?
测试方式
<!-- Describe test scenarios -->
<!-- 描述测试场景 -->
Screenshots (if applicable)
截图(如适用)
<!-- Add screenshots -->
<!-- 添加截图 -->
Checklist
检查清单
- Tests pass
- Lint passes
- Documentation updated
undefined- 测试通过
- 代码检查通过
- 文档已更新
undefinedIssue Templates
问题模板
Bug Report
Bug报告
markdown
---
name: Bug Report
about: Report a bug to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---markdown
---
name: Bug Report
about: Report a bug to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---Bug Description
Bug描述
<!-- Clear description of the bug -->
<!-- 清晰描述Bug内容 -->
Steps to Reproduce
复现步骤
- Go to '...'
- Click on '...'
- See error
- Go to '...'
- Click on '...'
- See error
Expected Behavior
预期行为
<!-- What should happen -->
<!-- 应该发生的结果 -->
Actual Behavior
实际行为
<!-- What actually happens -->
<!-- 实际发生的结果 -->
Environment
环境信息
- OS: [e.g., macOS 14.0]
- Node version: [e.g., 18.17.0]
- Project version: [e.g., 1.2.3]
- OS: [e.g., macOS 14.0]
- Node version: [e.g., 18.17.0]
- Project version: [e.g., 1.2.3]
Screenshots
截图
<!-- If applicable -->
<!-- 如适用 -->
Additional Context
补充信息
<!-- Any other information -->
undefined<!-- 其他相关信息 -->
undefinedFeature Request
功能请求
markdown
---
name: Feature Request
about: Suggest a new feature
title: '[FEATURE] '
labels: enhancement
assignees: ''
---markdown
---
name: Feature Request
about: Suggest a new feature
title: '[FEATURE] '
labels: enhancement
assignees: ''
---Problem Statement
问题陈述
<!-- What problem does this solve? -->
<!-- 该功能解决了什么问题? -->
Proposed Solution
提议的解决方案
<!-- How would you like it to work? -->
<!-- 你希望它如何工作? -->
Alternatives Considered
考虑过的替代方案
<!-- Other solutions you've considered -->
<!-- 你考虑过的其他解决方案 -->
Additional Context
补充信息
<!-- Any other information -->
undefined<!-- 其他相关信息 -->
undefinedCode Style Guide
代码风格指南
markdown
undefinedmarkdown
undefinedStyle Guide
风格指南
General Principles
通用原则
- Write self-documenting code
- Prefer explicit over implicit
- Keep functions small and focused
- DRY (Don't Repeat Yourself)
- 编写自文档化代码
- 优先显式而非隐式
- 保持函数短小且聚焦
- DRY(避免重复代码)
TypeScript/JavaScript
TypeScript/JavaScript
typescript
// ✅ Good
function calculateTotalPrice(items: CartItem[]): number {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}
// ❌ Bad
function calc(i: any[]): any {
let t = 0;
for (let x of i) t += x.p * x.q;
return t;
}typescript
// ✅ 良好示例
function calculateTotalPrice(items: CartItem[]): number {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}
// ❌ 不良示例
function calc(i: any[]): any {
let t = 0;
for (let x of i) t += x.p * x.q;
return t;
}Naming Conventions
命名规范
| Type | Convention | Example |
|---|---|---|
| Variables | camelCase | |
| Functions | camelCase | |
| Classes | PascalCase | |
| Constants | UPPER_SNAKE | |
| Files | kebab-case | |
| Interfaces | PascalCase + I prefix | |
| 类型 | 规范 | 示例 |
|---|---|---|
| 变量 | camelCase | |
| 函数 | camelCase | |
| 类 | PascalCase | |
| 常量 | UPPER_SNAKE | |
| 文件 | kebab-case | |
| 接口 | PascalCase + I前缀 | |
File Structure
文件结构
src/
├── components/ # UI components
├── hooks/ # Custom React hooks
├── services/ # Business logic
├── utils/ # Helper functions
├── types/ # TypeScript types
└── __tests__/ # Test filesundefinedsrc/
├── components/ # UI组件
├── hooks/ # 自定义React hooks
├── services/ # 业务逻辑
├── utils/ # 辅助函数
├── types/ # TypeScript类型定义
└── __tests__/ # 测试文件undefinedCode Review Process
代码审查流程
markdown
undefinedmarkdown
undefinedCode Review
代码审查
Review Checklist
审查检查清单
Functionality:
- Code works as intended
- Edge cases handled
- Error handling adequate
Code Quality:
- Readable and maintainable
- No unnecessary complexity
- Follows project conventions
Testing:
- Adequate test coverage
- Tests are meaningful
- Edge cases tested
Security:
- No hardcoded secrets
- Input validation present
- No SQL injection risks
功能:
- 代码按预期工作
- 边界情况已处理
- 错误处理充分
代码质量:
- 可读且易于维护
- 无不必要的复杂度
- 符合项目规范
测试:
- 测试覆盖率足够
- 测试用例有意义
- 边界情况已测试
安全:
- 无硬编码密钥
- 存在输入验证
- 无SQL注入风险
Response Times
响应时间
- First response: within 48 hours
- Follow-up reviews: within 24 hours
- Merge after approval: within 24 hours
- 首次响应:48小时内
- 后续审查:24小时内
- 批准后合并:24小时内
Approval Requirements
批准要求
- 1 maintainer approval required
- All CI checks must pass
- No unresolved conversations
undefined- 需要1位维护者批准
- 所有CI检查必须通过
- 无不解决的讨论
undefinedPre-commit Hooks
提交前钩子
json
// package.json
{
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md}": [
"prettier --write"
]
}
}json
// package.json
{
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md}": [
"prettier --write"
]
}
}Recognition Program
贡献者认可计划
markdown
undefinedmarkdown
undefinedRecognition
认可
Contributors
贡献者
All contributors are added to our CONTRIBUTORS.md file.
所有贡献者将被添加到我们的CONTRIBUTORS.md文件中。
Badges
徽章
| Badge | Criteria |
|---|---|
| 🥇 First Contribution | Merged first PR |
| 🔥 Frequent Contributor | 10+ merged PRs |
| 📚 Documentation Hero | 5+ docs PRs |
| 🐛 Bug Hunter | 5+ bug fixes |
| ⭐ Core Contributor | Significant impact |
| 徽章 | 获得条件 |
|---|---|
| 🥇 首次贡献 | 合并首个PR |
| 🔥 频繁贡献者 | 合并10个以上PR |
| 📚 文档英雄 | 提交5个以上文档PR |
| 🐛 Bug猎手 | 修复5个以上Bug |
| ⭐ 核心贡献者 | 对项目有重大影响 |
Rewards
奖励
- Stickers and swag for active contributors
- Shoutouts in release notes
- Conference ticket opportunities
- LinkedIn recommendations
undefined- 为活跃贡献者提供贴纸和周边
- 在发布说明中提及
- 会议门票机会
- LinkedIn推荐
undefinedCommunity Guidelines
社区指南
markdown
undefinedmarkdown
undefinedCommunity
社区
Communication Channels
沟通渠道
- Discord: Join our server
- GitHub Discussions: For questions and ideas
- Twitter: @project
Response Time Expectations
响应时间预期
- Issues: 48 hours
- PRs: 72 hours
- Questions: 24-48 hours
- 问题:48小时内
- PR:72小时内
- 咨询:24-48小时内
Getting Help
获取帮助
- Check existing issues and discussions
- Read the documentation
- Ask in Discord #help channel
- Create a GitHub Discussion
- 查看现有问题和讨论
- 阅读文档
- 在Discord的#help频道提问
- 创建GitHub Discussion
Code of Conduct
行为准则
We follow the Contributor Covenant.
Be respectful, inclusive, and constructive.
undefined我们遵循Contributor Covenant。请保持尊重、包容和建设性。
undefinedЛучшие практики
最佳实践
- Progressive disclosure — от простого к сложному
- Clear examples — реальные примеры кода
- Up-to-date — обновляйте при изменениях
- Welcoming tone — дружелюбный язык
- Multiple entry points — для разных типов contributions
- Automated checks — CI для валидации PR
- 渐进式披露 — 从简单到复杂
- 清晰示例 — 真实代码示例
- 实时更新 — 随变更同步更新
- 友好语气 — 使用亲切的语言
- 多入口点 — 适配不同类型的贡献内容
- 自动化检查 — 用CI验证PR