Rules
no-generic-handler-names
no-generic-handler-names
Severity: warn
Rule ID:Good:Generic suffixes detected: Click, Change, Input, Blur, Focus.
Rule ID:
react-doctor/no-generic-handler-namesRequires descriptive event handler names. Names like handleClick don’t describe what the handler does, making code harder to understand.Why it’s bad:handleClickdoesn’t explain the action- Multiple handlers in a component become confusing
- Reduces code readability
no-giant-component
no-giant-component
Severity: warn
Rule ID:Good:Consider breaking large components into:
Rule ID:
react-doctor/no-giant-componentFlags components over 300 lines. Large components are hard to understand, test, and maintain.Why it’s bad:- Difficult to understand at a glance
- Hard to test in isolation
- Often violates single responsibility principle
- Makes refactoring risky
- Smaller sub-components
- Custom hooks for logic
- Utility functions for calculations
no-render-in-render
no-render-in-render
Severity: warn
Rule ID:Good:Detects function names matching
Rule ID:
react-doctor/no-render-in-renderPrevents calling render functions inline (e.g., renderHeader() in JSX). This breaks React’s reconciliation and causes unnecessary re-renders.Why it’s bad:- React can’t track component identity
- State is lost on every render
- Poor performance
- Can’t use hooks in render functions
/^render[A-Z]/.no-nested-component-definition
no-nested-component-definition
Severity: error
Rule ID:Good:If you need to pass parent state, use props:
Rule ID:
react-doctor/no-nested-component-definitionPrevents defining components inside other components. This creates a new component instance on every render, destroying all state.Why it’s bad:- Component recreated on every parent render
- All state is lost
- Props change even if values are the same
- Performance impact
Best Practices
Component Size
Keep components focused and small:- Extract complex logic into custom hooks
- Break UI into smaller sub-components
- Use composition over giant components
Component Organization
Naming Conventions
- Components: PascalCase (
UserProfile) - Handlers: descriptive names (
handleSubmitForm,handleDeleteUser) - Hooks: start with
use(useAuth,useDashboard)
Related Rules
- State and Effects Rules - State management patterns
- Performance Rules - Rendering optimization