react-doctor/client-passive-event-listeners
Add `{ passive: true }` as the third argument: `addEventListener('scroll', handler, { passive: true })`. Only do this if the handler does NOT call `event.preventDefault()` — passive listeners silently ignore `preventDefault()`, which breaks features like pull-to-refresh suppression, custom gestures, and nested-scroll containment.
- Category: Performance
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: always
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Confirm an addEventListener call whose first string-literal argument is one of scroll, wheel, touchstart, touchmove, or touchend AND whose third options argument is missing or an ObjectExpression without passive: true. False positive: the handler intentionally calls event.preventDefault() to block pull-to-refresh, implement a custom gesture, or contain a nested scroll container.
Fix prompt
Use this once validation confirms the diagnostic is real.
Pass { passive: true } as the third argument so the browser can scroll without waiting for the handler to return. If the handler must call preventDefault(), leave the option off (or set passive: false explicitly) since passive listeners silently ignore preventDefault. See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#using_passive_listeners
Related rules
More Performance rules from the rules reference:
react-doctor/js-async-reduce-without-awaited-acc: Await the accumulator inside an async .reduce reducer: const acc = await previous; ...; return acc;react-doctor/js-batch-dom-css: Batch DOM/CSS reads and writes — interleaving them inside a loop causes layout thrashing. Read first, then writereact-doctor/js-cache-property-access: Hoist the deep member access into a const at the top of the loop body: `const { x, y } = obj.deeply.nested`react-doctor/js-cache-storage: Cache repeated `localStorage`/`sessionStorage` reads in a local variable — each access serializes/deserializesreact-doctor/js-combine-iterations: Combine `.map().filter()` (or similar chains) into a single pass with `.reduce()` or a `for...of` loop to avoid iterating the array twice