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-loading-flag-reset-outside-finallyA trailing
setLoading(false)after anawaitnever runs if the awaited call rejects, so the flag stays stuck truthy; reset it in afinallyblock (or mirror the reset on every catch) so it clears on both paths.: warning in React projects -
react-doctor/no-locale-format-in-renderFormat locale/timezone-dependent values in a post-mount useEffect + state, or pass an explicit locale and timeZone so the server and the browser render the same text. Only runs on SSR-capable projects.
: warning in React projects -
react-doctor/no-match-media-in-state-initializerPrefer CSS media queries for layout, or subscribe with
useSyncExternalStoreand provide a stable server snapshot.: warning in React projects -
react-doctor/no-mixed-srcset-descriptorsUse either width descriptors with sizes or density descriptors throughout one srcSet, never both.
: warning in React projects -
react-doctor/no-multiple-main-landmarksKeep one visible main landmark per rendered view so assistive-technology users can jump to the primary content unambiguously.
: warning in React projects -
react-doctor/no-multiple-unlabeled-navigation-landmarksGive each coexisting navigation landmark a concise, unique aria-label or aria-labelledby value.
: warning in React projects -
react-doctor/no-mutable-in-depsRead mutable values like
location.pathnameorref.currentinside the effect body, or subscribe withuseSyncExternalStore. Changing them doesn't redraw the screen, so listing them in deps won't make the effect run again.: error in React projects -
react-doctor/no-mutate-queried-dom-node-in-componentDrive the node with state/props (or a ref for genuinely uncontrolled nodes) instead of querying it and mutating its style/class. Imperative edits to a node React renders are invisible to the virtual DOM and get reverted or clobbered on the next render.
: warning in React projects -
react-doctor/no-mutating-array-method-on-prop-or-hook-resultsort,reverse, andsplicemutate in place, so calling them on a prop or hook result corrupts shared state. Use the immutabletoSorted/toReversed/toSpliced, or copy the array first ([...array].sort()) when targeting pre-ES2023 runtimes.: warning in React projects -
react-doctor/no-mutating-reducer-stateReturn a new state object from the reducer instead of changing the old one and returning it. React only notices the change when the object is new.
: error in React projects -
react-doctor/no-namespaceUse a plain component or DOM tag because React cannot render JSX namespaced names like
ns:Foo.: warning in React projects -
react-doctor/no-non-literal-selector-query-without-try-catchquerySelector/querySelectorAll/matches/closestthrow aDOMExceptionon an invalid CSS selector, and href/hash fragments are frequently invalid. Wrap the call in try/catch or normalize the value withCSS.escape.: warning in React projects -
react-doctor/no-non-null-assertion-on-maybe-undefined-resultDrop the
!on.find/.match/.getresults and handle the miss (optional chaining, a guard, or a fallback). These built-ins returnundefined/nullwhen nothing matches, so the assertion just moves the crash one line later.: warning in React projects -
react-doctor/no-nondeterministic-id-value-in-render-bodyAn id generator (uniqueId/nanoid/crypto.randomUUID/shortid) bound in the render body re-runs every render, so the id is unstable and breaks htmlFor/aria/SVG references and SSR hydration. Use useId for reference ids, or a useRef/useState initializer to mint it once.
: warning in React projects -
react-doctor/no-noninteractive-element-interactionsPut interactions on a button or link, or add an interactive role.
: warning in React projects -
react-doctor/no-noninteractive-element-to-interactive-roleUse a real interactive element instead of adding an interactive role to a static one.
: warning in React projects -
react-doctor/no-noninteractive-tabindexOnly add
tabIndexto interactive elements or interactive roles.: warning in React projects -
react-doctor/no-nullish-coalescing-arithmetic-precedenceArithmetic binds tighter than
??, so wrap the nullish part in parentheses ((x ?? 0) / y) to compute the value you actually intend.: warning in React projects -
react-doctor/no-object-or-array-coerced-to-string-in-template-literalInterpolating an object or structurally nested array can produce
[object Object]or lose structure; read a specific value or use.join/JSON.stringify.: warning in React projects -
react-doctor/no-predicate-function-reference-in-boolean-positionA bare
is*/has*/can*/should*/will*function reference is always truthy in a condition, so the guarded branch never behaves as intended. Call the function (isReady()) to evaluate the predicate.: warning in React projects -
react-doctor/no-prop-callback-in-renderInvoke the callback from the event or asynchronous operation that produced the value, or from an effect when synchronizing with an external system. Render must stay pure because React can replay or discard it.
: error in React projects -
react-doctor/no-random-keyUse a stable id from the item itself, like
item.id, a content hash, or the index when the order never changes. Don't build the key from something that changes every time.: error in React projects -
react-doctor/no-redundant-rolesRemove redundant
roleattributes so assistive tech reads the element's native semantics without extra noise.: warning in React projects -
react-doctor/no-redundant-should-component-updateDrop
shouldComponentUpdate(PureComponent already shallow-compares) or extendReact.Componentif custom logic is needed.: warning in React projects -
react-doctor/no-ref-callback-cleanup-before-react-19React 18 ignores functions returned from ref callbacks. Handle cleanup when React calls the ref with
null, or require React 19 before returning a cleanup function.: warning in React projects -
react-doctor/no-ref-current-in-renderMove ref writes into an event handler or effect. Render must stay pure because React can replay or discard it. The predictable null-guarded lazy initialization pattern remains supported.
: error in React projects -
react-doctor/no-render-return-valueDon't use
ReactDOM.render's return value. It's legacy and was removed in React 19.: warning in React projects -
react-doctor/no-responsive-hidden-accessible-nameKeep an accessible name available at every breakpoint, such as persistent sr-only text or an aria-label on the control.
: warning in React projects -
react-doctor/no-secrets-in-client-codeMove secrets to server-only code. Anything in client env variables gets shipped to the browser, so it can't hold secrets.
: warning in React projects -
react-doctor/no-set-state-after-await-in-effectIn a
useEffectwhose dependencies can change, guard any setter call that runs after anawaitbehind a cancellation/ignore flag, or return a cleanup that cancels the async work.: warning in React projects -
react-doctor/no-set-state-in-renderMove the setter into a
useEffector an event handler, or compute the value while rendering. Calling a setter during render starts another render that calls it again, looping forever.: warning in React projects -
react-doctor/no-side-effect-in-state-updater-functionReact may replay a state updater, so callbacks, analytics, and persistence inside it can run more than once. Compute state purely, then perform the side effect outside the setter.
: warning in React projects -
react-doctor/no-srcset-without-sizesAdd a sizes attribute that describes the image's rendered width at each responsive breakpoint.
: warning in React projects -
react-doctor/no-stale-timer-refReset the ref right after clearing (
clearTimeout(ref.current); ref.current = null) so truthiness checks on the ref keep meaning “timer still pending”.: warning in React projects -
react-doctor/no-static-element-interactionsGive clickable static elements a
role, or use a button or link.: warning in React projects -
react-doctor/no-static-motion-config-neverUse
reducedMotion="user", or derive the value from an explicit user preference instead of permanently disabling reduced-motion support.: warning in React projects -
react-doctor/no-string-false-on-boolean-attributeUse the boolean form on boolean attributes:
disabled/disabled={true}/disabled={false}, notdisabled="false". A non-empty string is truthy, so="false"actually turns the attribute ON.: warning in React projects -
react-doctor/no-string-refsUse a callback ref or
useRefso ref ownership is explicit and not tied to legacy string lookup.: warning in React projects -
react-doctor/no-sync-xhrNever open an XMLHttpRequest synchronously (
async=false). It blocks the main thread. Usefetch()or passtrueand handle the response asynchronously.: warning in React projects -
react-doctor/no-this-in-sfcRead from the
propsargument because function components do not have a React instancethis.: warning in React projects