Rules
no-array-index-as-key
no-array-index-as-key
Severity: warn
Rule ID:Good:Exception: Using index is acceptable for static lists that never change:
Rule ID:
react-doctor/no-array-index-as-keyPrevents 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
This rule ignores index usage inside
Array.from() or new Array() map calls, which are typically used for static placeholders.no-prevent-default
no-prevent-default
Severity: warn
Rule ID:Good:Next.js Server Actions:
Rule ID:
react-doctor/no-prevent-defaultSuggests 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
rendering-conditional-render
rendering-conditional-render
Severity: warn
Rule ID:Good:Why this happens:
Rule ID:
react-doctor/rendering-conditional-renderCatches conditional rendering using .length which can render 0 to the screen instead of rendering nothing.Why it’s bad:- In React,
0is rendered as text - Empty arrays have
.length === 0 - Users see “0” instead of empty state
- Common mistake for beginners
Additional React Correctness Rules
React Doctor includes built-in React rules from oxlint:From react plugin:
react/rules-of-hooks(error) - Enforce Rules of Hooksreact/jsx-key(error) - Require key prop in listsreact/jsx-no-duplicate-props(error) - Prevent duplicate propsreact/no-direct-mutation-state(error) - Prevent direct state mutationreact/require-render-return(error) - Require render() to return value
Server Component Rules:
react-doctor/server-auth-actions(error) - Require auth checks in server actionsreact-doctor/client-passive-event-listeners(warn) - Use passive listeners for scroll/touch
Common Pitfalls
Keys in Lists
Conditional Rendering
Event Handlers
Related Rules
- State and Effects Rules - State management patterns
- Architecture Rules - Component structure
- Next.js Rules - Next.js-specific correctness