react-doctor/rendering-conditional-render
Change to `{items.length > 0 && <List />}` or use a ternary: `{items.length ? <List /> : null}`
- Category: Correctness
- 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.
Rule flags numericValue && <Jsx /> where the left operand is either a .length member access (items.length) or an identifier whose name ends with count, length, total, size, or num — in camelCase like userCount or upper snake like USER_COUNT. When the value is 0, React renders the literal text '0' to the DOM. Confirm the left value can actually reach zero in practice.
Fix prompt
Use this once validation confirms the diagnostic is real.
Convert to an explicit boolean check: {items.length > 0 && <List />}, {Boolean(count) && <Badge />}, or a ternary {items.length ? <List /> : null}. Only false, null, and undefined render to nothing in JSX — 0 always renders. See https://react.dev/learn/conditional-rendering#logical-and-operator-
Related rules
More Correctness rules from the rules reference:
react-doctor/rendering-hydration-mismatch-time: Wrap dynamic time/random values in useEffect+useState (client-only) or add suppressHydrationWarning to the parent if intentionalreact-doctor/style-prop-object: Pass the `style` prop as an object literal like `{{ color: 'red' }}`, never a string or other primitive.react-doctor/void-dom-elements-no-children: Remove children from the void element, or use a non-void element if children are needed.react/jsx-key: Require a stable key on elements rendered from arrays or iterators so React can reconcile list items correctly.react/jsx-no-duplicate-props: Disallow duplicate props on a JSX element — React silently keeps only the last value.