Skip to content

Bug: jsx-no-leaked-render faulty autofix  #3323

Closed
@zaicevas

Description

@zaicevas

Version: 7.30.1
Config:

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

Before fix:

const MyComponent = () => {
  const items = []
  const breakpoint = { phones: true }

  return <div>{items.length > 0 && breakpoint.phones && <span />}</div>
}

Post fix:

const MyComponent = () => {
  const items = []
  const breakpoint = { phones: true }

  return <div>{!!!!!!!!!!!!!!!!!!!!items.length > 0 && breakpoint.phones && <span />}</div>
}

Expected:

const MyComponent = () => {
  const items = []
  const breakpoint = { phones: true }

  return <div>{items.length > 0 && !!breakpoint.phones && <span />}</div>
}

On top of that, the auto fix is quite slow.

Metadata

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