返回 Skill 列表
extension
分类: 开发与工程无需 API Key

react-code-smells

首席工程师级别的React重构模式,用于消除代码异味。涵盖了prop钻取、状态爆炸、组件组合、抽象质量、耦合、hooks、渲染模式和可测试性等问题。在重构现有的React代码库、审查PR中的架构问题或识别React应用程序中的技术债务时使用。

person作者: jakexiaohubgithub

Principal Engineering React Best Practices

Principal-engineer-level refactoring guide for React applications. Contains 42 rules across 8 categories, prioritized by impact from critical (state architecture, composition) to incremental (testability). Each rule includes code smell indicators, before/after examples, and safe transformation steps.

When to Apply

Reference these guidelines when:

  • Refactoring existing React codebases
  • Reviewing PRs for architectural issues
  • Identifying technical debt
  • Planning large-scale refactoring efforts
  • Deciding whether to extract, inline, or restructure components
  • Improving testability of React code

Rule Categories by Priority

| Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | State Architecture | CRITICAL | state- | | 2 | Component Composition | CRITICAL | comp- | | 3 | Abstraction Quality | HIGH | abs- | | 4 | Coupling & Cohesion | HIGH | couple- | | 5 | Hook Hygiene | MEDIUM-HIGH | hook- | | 6 | Render Patterns | MEDIUM | render- | | 7 | Side Effect Management | MEDIUM | effect- | | 8 | Testability | LOW-MEDIUM | test- |

Quick Reference

1. State Architecture (CRITICAL)

2. Component Composition (CRITICAL)

3. Abstraction Quality (HIGH)

4. Coupling & Cohesion (HIGH)

5. Hook Hygiene (MEDIUM-HIGH)

6. Render Patterns (MEDIUM)

7. Side Effect Management (MEDIUM)

8. Testability (LOW-MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples:

Related Skills

  • For React 19 API best practices, see react skill
  • For React core principles, see react-principle-engineer skill
  • For form handling, see react-hook-form skill

References

  1. react.dev - Official React documentation
  2. kentcdodds.com - Advanced React patterns
  3. patterns.dev - Design patterns in JavaScript
  4. testing-library.com - Testing best practices