Skip to content

[Bug]: react/jsx-no-leaked-render reports error on boolean values and tries to convert them #3908

Open
@bytasv

Description

@bytasv

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
    My issue appears in the command-line and not only in the text editor

Description Overview

Using following setup:

'react/jsx-no-leaked-render': ['error', { validStrategies: ['ternary', 'coerce'] }]

Image

The code reports error even though emptyCollection is already boolean value. I understand that the plugin does not take into account actual types that TS provides.

Running lint command reports an issue unless I convert the code to this 👇

Image

Is there a way to prevent this from being "fixed" since it's already a boolean value?

Expected Behavior

eslint-plugin-react version

v7.37.4

eslint version

v9.18.0

node version

v22.13.0

Activity

ljharb

ljharb commented on Mar 21, 2025

@ljharb
Member

When the type information is available, it would be a fine enhancement to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ljharb@bytasv

        Issue actions

          [Bug]: react/jsx-no-leaked-render reports error on boolean values and tries to convert them · Issue #3908 · jsx-eslint/eslint-plugin-react