juniors-best-practice
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseJuniors Best Practice
初级开发者最佳实践
Juniors-focused best practices for React and TypeScript projects. The rules are short, practical, and organized by scope to guide consistent code reviews, refactoring, and new feature work.
面向React和TypeScript项目的初级开发者最佳实践。这些规则简洁实用,按领域分类,可指导一致的代码评审、重构和新功能开发工作。
When to Apply
适用场景
Reference these guidelines when:
- Writing or reviewing React/TypeScript code for clarity and consistency
- Teaching junior developers or establishing baseline team conventions
- Refactoring code to align with simple, maintainable patterns
- Standardizing project-wide practices (imports, tooling, naming, commits)
参考这些指南的场景:
- 编写或评审React/TypeScript代码以确保清晰性和一致性
- 指导初级开发者或建立团队基础规范
- 重构代码以契合简洁、可维护的模式
- 标准化全项目实践(导入、工具、命名、提交)
Rule Categories by Priority
按优先级划分的规则类别
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Beginner Foundations | HIGH | |
| 2 | TypeScript | MEDIUM | |
| 3 | React | MEDIUM | |
| 4 | Styling | MEDIUM | |
| 5 | Devtools | MEDIUM | |
| 6 | Assets | LOW-MEDIUM | |
| 7 | Git | LOW | |
| 优先级 | 类别 | 影响程度 | 前缀 |
|---|---|---|---|
| 1 | 入门基础 | 高 | |
| 2 | TypeScript | 中 | |
| 3 | React | 中 | |
| 4 | 样式 | 中 | |
| 5 | 开发工具 | 中 | |
| 6 | 资源 | 低-中 | |
| 7 | Git | 低 | |
Quick Reference
快速参考
1. Beginner Foundations (HIGH)
1. 入门基础(高优先级)
- - Prefer early returns to reduce nesting
beginner-early-return - - Avoid
beginner-double-negationpatterns!isNotX - - Keep objects intact for clarity
beginner-unnecessary-destructuring - - Default to const
beginner-const-vs-let - - Use ?? for defaults
beginner-nullish-vs-or - - Remove redundant return
beginner-useless-return-arrow - - Use UPPER_CASE only for stable constants
beginner-uppercase-constants
- - 优先使用提前返回以减少嵌套
beginner-early-return - - 避免
beginner-double-negation这类双重否定模式!isNotX - - 保持对象完整以提升可读性
beginner-unnecessary-destructuring - - 优先使用const
beginner-const-vs-let - - 使用??设置默认值
beginner-nullish-vs-or - - 移除冗余的return
beginner-useless-return-arrow - - 仅对稳定常量使用大写蛇形命名(UPPER_CASE)
beginner-uppercase-constants
2. TypeScript (MEDIUM)
2. TypeScript(中优先级)
- - Use safe path alias prefixes
typescript-alias-naming
- - 使用安全的路径别名前缀
typescript-alias-naming
3. React (MEDIUM)
3. React(中优先级)
- - Use string literals when possible
react-string-props - - Use children for composition
react-children-prop - - Extend native element props
react-extends-component - - Keep props typing readable
react-props-typing
- - 尽可能使用字符串字面量
react-string-props - - 使用children进行组件组合
react-children-prop - - 扩展原生元素属性
react-extends-component - - 保持属性类型定义可读性
react-props-typing
4. Styling (MEDIUM)
4. 样式(中优先级)
- - Use clsx for conditional classes
styling-classnames-function - - Prefer CSS selectors for component states
styling-css-states
- - 使用clsx处理条件类名
styling-classnames-function - - 优先使用CSS选择器处理组件状态
styling-css-states
5. Devtools (MEDIUM)
5. 开发工具(中优先级)
- - Use formatter and linter
devtools-formatter-linter - - Keep imports ordered and grouped
devtools-sorting-imports - - Use a single package manager
devtools-package-manager-lock
- - 使用代码格式化工具和语法检查工具
devtools-formatter-linter - - 保持导入语句有序且分组
devtools-sorting-imports - - 使用单一包管理器
devtools-package-manager-lock
6. Assets (LOW-MEDIUM)
6. 资源(低-中优先级)
- - Use SVGs as components
assets-svg-files
- - 将SVG作为组件使用
assets-svg-files
7. Git (LOW)
7. Git(低优先级)
- - Use consistent commit conventions
git-commit-convention
- - 使用一致的提交规范
git-commit-convention
How to Use
使用方法
Read individual rule files for detailed explanations and examples:
rules/beginner-early-return.md
rules/react-props-typing.mdEach rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
阅读单个规则文件以获取详细说明和示例:
rules/beginner-early-return.md
rules/react-props-typing.md每个规则文件包含:
- 规则重要性的简要说明
- 错误代码示例及解释
- 正确代码示例及解释
- 额外背景信息和参考资料
Full Compiled Document
完整编译文档
For the complete guide with all rules expanded:
AGENTS.md包含所有扩展规则的完整指南:
AGENTS.md