tools icon indicating copy to clipboard operation
tools copied to clipboard

🐛 Various spacing/line length formatting incompatibilities with Prettier

Open nstepien opened this issue 2 years ago • 12 comments

Environment information

OS: win11, 64bit
install: `npm i rome@nightly`

What happened?

  1. Open this playground
  2. Notice the multiple formatting differences between the Rome output and Prettier output

Expected result

Prettier compatibility.

I've tested Nightly Rome's formatter in our biggest codebase, and these were the only differences I found.

Code of Conduct

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

nstepien avatar Oct 28 '22 10:10 nstepien

I'll take a look. We can split this task to:

  • [x] shothanded named import line break with default
    • #3826
  • [x] export line break
    • #3726
  • [x] jsx comment to props (specifically props count is 2, and comment to 2nd)
  • [x] jsx whitespace is meaningful jsx text
  • [x] jsx whitespace in childNodes with long strings
    • #3732
  • [x] object destructing in arguments (playground) from nsteien's comment
    • #3802
  • [ ] single-character-in-jsx formatting
    • #3842

unvalley avatar Nov 03 '22 09:11 unvalley

I have found some more incompatibility with prettier: playground

nstepien avatar Nov 08 '22 19:11 nstepien

Yet another example: playground

nstepien avatar Nov 11 '22 13:11 nstepien

I'll take a look. We can split this task to:

* [ ]  imports/exports line break

* [ ]  JSX comment to props (specifically props count is 2, and comment to 2nd)

* [ ]  JSX space in childNodes

* [ ]  JSX space in childNodes with long strings

@unvalley Are you looking into all these issues or some of them? Can other contributors help you with some of the work?

MichaReiser avatar Nov 14 '22 08:11 MichaReiser

@MichaReiser

Can other contributors help you with some of the work?

Yes, thanks. I'm working on import/exports line break now. Other tasks remain.

unvalley avatar Nov 14 '22 09:11 unvalley

I'll work on fixing to named import line break.

unvalley avatar Nov 16 '22 14:11 unvalley

I have found some more incompatibility with prettier: playground

I can help with this =)

denbezrukov avatar Nov 17 '22 07:11 denbezrukov

Probably the last prettier incompatibility I'll find, seems very very minor though: playground

nstepien avatar Nov 17 '22 11:11 nstepien

Probably the last prettier incompatibility I'll find, seems very very minor though: playground

That might be a tough one. Prettier has some special handling for single character texts that we don't fully support yet.

MichaReiser avatar Nov 17 '22 11:11 MichaReiser

Yeah I personally don't mind if this doesn't get fixed. Maybe it affects other repos differently.

nstepien avatar Nov 17 '22 11:11 nstepien

Does anyone want to look into the single-character-in-jsx formatting incompatibility?

Otherwise I'm happy with closing this issue, thank you everyone!

nstepien avatar Nov 23 '22 12:11 nstepien

Does anyone want to look into the single-character-in-jsx formatting incompatibility?

Otherwise I'm happy with closing this issue, thank you everyone!

I'll check it =)

denbezrukov avatar Nov 23 '22 13:11 denbezrukov