React Doctor
492 rules react-doctor@0.9.14
Complete effective rule inventory.
Rules
No enabled React Doctor rules match this search.
-
react-doctor/no-assertive-statusKeep
role="status"polite. Userole="alert"only when an interruption is genuinely imperative.: warning in React projects -
react-doctor/no-async-effect-callbackDon't make the effect callback
async. Define an async function inside the effect and call it, then return a real cleanup function if you need one.: warning in React projects -
react-doctor/no-async-event-handler-without-reentry-guardAn async onClick/onSubmit handler on a host control that awaits a mutating request and sets state only afterward stays interactive across the await, so a double-click fires the write twice. Add a leading
if (busy) returnguard, or set a flag before the await insidetryand reset it infinallywhile the control is disabled.: warning in React projects -
react-doctor/no-autofocusDo not use
autoFocus. It disorients users on load.: warning in React projects -
react-doctor/no-autoplay-without-mutedAlways pair
autoPlaywithmuted(andplaysInline):<video autoPlay muted loop playsInline />. If the sound matters, dropautoPlayand let users start it.: warning in React projects -
react-doctor/no-blocked-pasteAllow paste so people can use password managers, verification codes, assistive tools, and copied text without retyping it.
: error in React projects -
react-doctor/no-collapsed-literal-or-chain-as-valueCompare against each value separately (or use an array
.includes(x)) instead of an all-literal||/&&chain, which short-circuits to its first literal and drops the rest.: warning in React projects -
react-doctor/no-conflicting-spring-optionsChoose either stiffness/damping/mass or duration/bounce for a Motion spring so every configured value takes effect.
: warning in React projects -
react-doctor/no-controlled-input-value-without-state-updateDrive the input's
valuefrom state (const [value, setValue] = useState(...)) thatonChangeupdates, or dropvalueif the field is meant to be read-only.: warning in React projects -
react-doctor/no-create-context-in-renderMove
createContext(...)outside the component, to the top level of the file, so it stays the same on every render.: error in React projects -
react-doctor/no-create-object-url-in-renderCreate object URLs in an effect or event handler and revoke each URL when it is replaced or no longer needed.
: warning in React projects -
react-doctor/no-create-ref-in-function-componentReplace
createRef()with theuseRef()hook inside function components and hooks.createRefis only for class components.: warning in React projects -
react-doctor/no-create-store-in-renderCreate stores at module scope so subscribers are not cut off and saved state does not reset every render.
: error in React projects -
react-doctor/no-danger-with-childrenUse either
childrenordangerouslySetInnerHTMLso React does not ignore one source of content.: error in React projects -
react-doctor/no-deprecated-keyboard-event-keycode-whichKeyboardEvent.keyCode/which/charCodeare deprecated and layout/engine dependent for character keys. Branch onevent.key(logical key like'/') orevent.code(physical position) so the handler works across keyboard layouts and browsers.: warning in React projects -
react-doctor/no-did-mount-set-stateSetting state in
componentDidMounttriggers an extra render. UsegetDerivedStateFromPropsor initial state instead.: warning in React projects -
react-doctor/no-did-update-set-stateSetting state in
componentDidUpdatecauses another render and can loop. UsegetDerivedStateFromPropsinstead.: warning in React projects -
react-doctor/no-direct-mutation-stateDon't change
this.stateby hand.setState()overwrites it anyway, so always go throughsetState().: error in React projects -
react-doctor/no-direct-state-mutationCall the setter with a brand new value instead:
setItems([...items, newItem]),setItems(items.filter(x => x !== target)), orsetItems(items.toSorted(...)). React only redraws when the value is new, so changing it in place does nothing.: warning in React projects -
react-doctor/no-distracting-elementsReplace
<marquee>and<blink>with normal markup so motion does not distract or disorient users.: error in React projects -
react-doctor/no-document-writeDon't use
document.write()/document.writeln(). Append DOM nodes or setinnerHTML/textContenton a specific element instead.: warning in React projects -
react-doctor/no-effect-with-fresh-depsMove the value inside the hook body and depend on its simple inputs instead, or wrap it in useMemo / useCallback so it stays the same between renders.
: error in React projects -
react-doctor/no-effect-wrapper-discards-callback-cleanup-returnA custom effect wrapper must return its forwarded EffectCallback's result so React can run the cleanup. Calling it as a bare
fn()instead ofreturn fn()silently drops the cleanup, leaking every subscription/timer/listener it set up.: warning in React projects -
react-doctor/no-enter-submit-without-ime-composition-guardBail on IME composition before acting on Enter:
if (e.nativeEvent.isComposing) return;(or track composition withonCompositionStart/onCompositionEnd). Otherwise Enter fires mid-composition and commits a half-typed value for CJK users.: warning in React projects -
react-doctor/no-evalUse
JSON.parsefor data, or rewrite the code so it doesn't build and run code from strings.: error in React projects -
react-doctor/no-fetch-in-effectUse a data-fetching layer or Server Component so fetches do not race, double-fire, or leak from
useEffect.: warning in React projects -
react-doctor/no-fill-map-element-as-keyAfter
.fill(value)every element is identical, so a lone.map((n) => ...)bindsnto that value (whatever the parameter is named) and gives every child the same key. Add the index as the second parameter:.map((_, index) => ...).: warning in React projects -
react-doctor/no-find-dom-nodeUse a ref to reach DOM nodes because
findDOMNodewas removed in React 19 and can crash the app.: warning in React projects -
react-doctor/no-floating-then-in-jsx-handlerA
.then()chain with no.catchin an event handler becomes an uncaught promise rejection no error boundary can catch; add a.catchhandler (or make the handlerasyncandtry/catch).: warning in React projects -
react-doctor/no-focusable-content-in-aria-hiddenRemove focusable descendants from aria-hidden content, or hide and disable the whole subtree together.
: warning in React projects -
react-doctor/no-hydration-branch-on-browser-globalRender the same initial output on the server and client, then switch after mount or use useSyncExternalStore with a stable server snapshot.
: error in React projects -
react-doctor/no-img-lazy-with-high-fetchpriorityDon't combine
loading="lazy"withfetchPriority="high". A high-priority image (usually the LCP) should load eagerly; a lazy image is by definition not high priority.: warning in React projects -
react-doctor/no-impure-state-updaterKeep state updater callbacks pure and return only the next state. Move notifications, storage, timers, ref writes, and other external work into the event or effect that queues the update.
: error in React projects -
react-doctor/no-indeterminate-attributeAssign the checkbox element's
indeterminateDOM property, usually through a ref, because the HTML attribute does not control its visual state.: warning in React projects -
react-doctor/no-interactive-element-to-noninteractive-roleDo not give an interactive element a role that says it is not interactive.
: warning in React projects -
react-doctor/no-invalid-progress-rangeKeep determinate progress values within a valid positive range so visual and assistive feedback report the same advancement.
: error in React projects -
react-doctor/no-is-mountedisMounteddoesn't work in modern React. Track mount state with a ref, or cancel the async work instead.: warning in React projects -
react-doctor/no-json-parse-stringify-cloneReplace
JSON.parse(JSON.stringify(value))withstructuredClone(value). It is faster and preserves Dates, Maps, Sets, and cyclic references.: warning in React projects -
react-doctor/no-legacy-class-lifecyclesMove
componentWillMountwork tocomponentDidMount,componentWillReceivePropstocomponentDidUpdateor the staticgetDerivedStateFromProps, andcomponentWillUpdatetogetSnapshotBeforeUpdatepluscomponentDidUpdate. TheUNSAFE_prefix only hides the warning. React 19 removes both.: error in React projects -
react-doctor/no-legacy-context-apiSwap
childContextTypes+getChildContextforconst MyContext = createContext(...)and<MyContext.Provider value={...}>. SwapcontextTypesforstatic contextType = MyContextoruseContext()in a function component. Move the provider and every consumer together, or some consumers read the wrong context.: error in React projects