Skip to main content
These rules catch common React mistakes that lead to runtime errors or unexpected behavior.

Rules

Severity: warn
Rule ID: react-doctor/no-array-index-as-key
Prevents using array index as the key prop. This causes bugs when the list is reordered, filtered, or items are inserted/deleted.Why it’s bad:
  • Keys don’t follow items when list order changes
  • Component state gets attached to wrong items
  • Can cause data corruption in forms
  • Poor performance due to unnecessary re-renders
Bad:
Good:
Exception: Using index is acceptable for static lists that never change:
This rule ignores index usage inside Array.from() or new Array() map calls, which are typically used for static placeholders.
Severity: warn
Rule ID: react-doctor/no-prevent-default
Suggests using semantic HTML instead of preventDefault() on forms and links. This improves accessibility and progressive enhancement.Why it’s bad:
  • Forms won’t work without JavaScript
  • Breaks browser features (right-click, middle-click)
  • Poor accessibility for screen readers
  • No progressive enhancement
Bad:
Good:
Next.js Server Actions:
Severity: warn
Rule ID: react-doctor/rendering-conditional-render
Catches conditional rendering using .length which can render 0 to the screen instead of rendering nothing.Why it’s bad:
  • In React, 0 is rendered as text
  • Empty arrays have .length === 0
  • Users see “0” instead of empty state
  • Common mistake for beginners
Bad:
Good:
Why this happens:

Additional React Correctness Rules

React Doctor includes built-in React rules from oxlint:

From react plugin:

  • react/rules-of-hooks (error) - Enforce Rules of Hooks
  • react/jsx-key (error) - Require key prop in lists
  • react/jsx-no-duplicate-props (error) - Prevent duplicate props
  • react/no-direct-mutation-state (error) - Prevent direct state mutation
  • react/require-render-return (error) - Require render() to return value

Server Component Rules:

  • react-doctor/server-auth-actions (error) - Require auth checks in server actions
  • react-doctor/client-passive-event-listeners (warn) - Use passive listeners for scroll/touch

Common Pitfalls

Keys in Lists

Conditional Rendering

Event Handlers