coding-standards
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCoding Standards
编码标准
You enforce coding standards by detecting the project language and applying the correct style guide.
你需要通过检测项目语言并应用正确的风格指南来强制执行编码标准。
Step 1 — Detect the language
步骤1 — 检测语言
Look at the file extensions, project config files, and context of the user's request to determine the primary language.
查看文件扩展名、项目配置文件以及用户请求的上下文,以确定主要语言。
Step 2 — Fetch the right guide
步骤2 — 获取对应的指南
Based on the detected language, fetch and read the corresponding style guide using :
WebFetch| Language | Guide | URL |
|---|---|---|
| Python | Google Python Style Guide | |
| TypeScript | Anthony Fu's ESLint Config | |
| Go | Uber Go Style Guide | |
| Rust | Rust API Guidelines | |
| C / C++ | LLVM Coding Standards | |
| JavaScript | Airbnb JavaScript Style Guide | |
根据检测到的语言,使用获取并阅读相应的风格指南:
WebFetch| 语言 | 指南 | 链接 |
|---|---|---|
| Python | Google Python风格指南 | |
| TypeScript | Anthony Fu的ESLint配置 | |
| Go | Uber Go风格指南 | |
| Rust | Rust API指南 | |
| C / C++ | LLVM编码标准 | |
| JavaScript | Airbnb JavaScript风格指南 | |
Step 3 — Satisfy the user's request
步骤3 — 满足用户的请求
Use the fetched guide as your reference to do what the user asked — whether that's reviewing code, fixing style issues, refactoring, or writing new code that follows the standard.
Always cite the specific rule or section from the guide when making suggestions.
以获取到的指南为参考,完成用户的请求——无论是代码审查、修复风格问题、重构还是编写符合标准的新代码。
提出建议时,请务必引用指南中的具体规则或章节。
Commit messages
提交信息
When writing commit messages, follow Conventional Commits:
Commit messages must be:
- Single line — header only, no body unless absolutely necessary
- Short — 72 character max ()
header-max-length - Minimal — state what changed, nothing more
- Conventional — format (e.g.
type(scope): subject)fix(api): handle null response
Good: | Bad:
feat(auth): add jwt refreshAdded a new feature that refreshes the JWT token when it expires编写提交信息时,请遵循Conventional Commits规范:
提交信息必须:
- 单行 — 仅包含标题,除非绝对必要,否则不要添加正文
- 简短 — 最多72个字符()
header-max-length - 简洁 — 说明变更内容即可,无需多余信息
- 符合规范 — 格式(例如:
type(scope): subject)fix(api): handle null response
良好: | 糟糕:
feat(auth): add jwt refreshAdded a new feature that refreshes the JWT token when it expires