Skip to main content
These rules help you maintain clean, maintainable React code by catching architectural anti-patterns.

Rules

Severity: warn
Rule ID: react-doctor/no-generic-handler-names
Requires descriptive event handler names. Names like handleClick don’t describe what the handler does, making code harder to understand.Why it’s bad:
  • handleClick doesn’t explain the action
  • Multiple handlers in a component become confusing
  • Reduces code readability
Bad:
Good:
Generic suffixes detected: Click, Change, Input, Blur, Focus.
Severity: warn
Rule ID: react-doctor/no-giant-component
Flags 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
Bad:
Good:
Consider breaking large components into:
  • Smaller sub-components
  • Custom hooks for logic
  • Utility functions for calculations
Severity: warn
Rule ID: react-doctor/no-render-in-render
Prevents 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
Bad:
Good:
Detects function names matching /^render[A-Z]/.
Severity: error
Rule ID: react-doctor/no-nested-component-definition
Prevents 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
Bad:
Good:
If you need to pass parent state, use props:

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)