Skip to content

Spaces get condensed by --fix when they are alone in a <span> #1717

Closed
@pbondoer

Description

@pbondoer

We often need to add spacing between two elements in JSX. For example:

<GenericTextComponent type='test' />
<span>{' '}</span>
<GenericTextComponent type='other' />

Applying --fix turns the code into this:

<GenericTextComponent type='test' />
<span />
<GenericTextComponent type='other' />

which is not the same thing.

I think I've traced down what's happening. The code above gives off this error:

error  Curly braces are unnecessary here  react/jsx-curly-brace-presence

Which, when corrected (by removing the curly braces and quotes), gives off another error:

error  Empty components are self-closing  react/self-closing-comp

which --fix happily turns into the <span /> above.

Versions:

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