Skip to content

jsx-no-leaked-render causes code to be incorrect by removing parentheses #3498

Closed
@tcl333

Description

// maybeObject: object | undefined
// isFoo: boolean
{maybeObject && (isFoo ? <Aaa /> : <Bbb />)}

// autofixes to:
{!!maybeObject && isFoo ? <Aaa /> : <Bbb />}

This has an entirely different meaning. My original code was hiding everything if maybeObject was undefined. The new code will display <Bbb /> instead.

To show how absurd this is, in other spot in my codebase, the else condition of the ternary was also maybeObject. This meant that my new code had a runtime error.

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions