tools icon indicating copy to clipboard operation
tools copied to clipboard

🐛 Formatter might remove intentionally set spaces in TSX files

Open tsteckenborn opened this issue 2 years ago • 6 comments

Environment information

IDE: VSCode
Extension: rome.rome v0.10.0
Package: "rome": "^0.7.0-next"
OS: Windows

What happened?

  1. TSX file contains spaces between two spans
          <h1
            className="..."
          >
            Some Text<br />
            <span
              className="..."
            >
              Text 1{' '}
            </span>
            and{' '}
            <span
              className="..."
            >
              Text 2
            </span>
          </h1>
  1. The spaces ({' '}) are getting removed

Expected result

I would expect the spaces to be preserved.

Code of Conduct

  • [X] I agree to follow Rome's Code of Conduct

tsteckenborn avatar Jul 07 '22 06:07 tsteckenborn

https://play.rome.tools/?lineWidth=80&indentStyle=tab&quoteStyle=double&indentWidth=2&sourceType=module&treeStyle=0&typescript=false&jsx=true#IAAgACAAIAAgACAAIAAgACAAIAA8AGgAMQAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgAGMAbABhAHMAcwBOAGEAbQBlAD0AIgAuAC4ALgAiAAoAIAAgACAAIAAgACAAIAAgACAAIAA+AAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAUwBvAG0AZQAgAFQAZQB4AHQAPABiAHIAIAAvAD4ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAA8AHMAcABhAG4ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAYwBsAGEAcwBzAE4AYQBtAGUAPQAiAC4ALgAuACIACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAA+AAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAFQAZQB4AHQAIAAxAHsAJwAgACcAfQAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgADwALwBzAHAAYQBuAD4ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIABhAG4AZAB7ACcAIAAnAH0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAA8AHMAcABhAG4ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAYwBsAGEAcwBzAE4AYQBtAGUAPQAiAC4ALgAuACIACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAA+AAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAFQAZQB4AHQAIAAyAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAPAAvAHMAcABhAG4APgAKACAAIAAgACAAIAAgACAAIAAgACAAPAAvAGgAMQA+AA==, It seems prettier has the same behavior.

IWANABETHATGUY avatar Jul 07 '22 09:07 IWANABETHATGUY

Alright. I'll use {` `} which is apparently not picked up by Prettier / Rome for now.

tsteckenborn avatar Jul 07 '22 09:07 tsteckenborn

I am just curious why you prefer to use {' '} , because this should be transformed to the same HTML finally.

IWANABETHATGUY avatar Jul 07 '22 10:07 IWANABETHATGUY

It's actually a bug:

Playground

The issue occurs when the children should go on multiple lines

ematipico avatar Jul 07 '22 10:07 ematipico

I am just curious why you prefer to use {' '} , because this should be transformed to the same HTML finally.

Due to two reasons:

  1. Spaces got stripped out by something, so the first idea was to make them explicit
  2. Visibility

tsteckenborn avatar Jul 07 '22 10:07 tsteckenborn

I am just curious why you prefer to use {' '} , because this should be transformed to the same HTML finally.

Due to two reasons:

  1. Spaces got stripped out by something, so the first idea was to make them explicit
  2. Visibility

Got it.

IWANABETHATGUY avatar Jul 07 '22 10:07 IWANABETHATGUY

This issue is stale because it has been open 14 days with no activity.

github-actions[bot] avatar Sep 09 '22 12:09 github-actions[bot]

The last release seems to have fixed the bug. If there's something else, please feel free to create a new issue.

ematipico avatar Sep 09 '22 12:09 ematipico