benjamn / recast

JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator
MIT License
4.91k stars 347 forks source link

printer: Don't break on inline comments in JSX #1398

Closed PartMan7 closed 3 months ago

PartMan7 commented 3 months ago

Allows rewriting JSX with inline comments without potentially generating invalid code.

Source Code:

<Foo // comment
  prop1
  prop2
/>

Old Output:

<Foo // comment prop1 prop2 />

New Output:

<Foo // comment
  prop1
  prop2
/>
eventualbuddha commented 3 months ago

Closing as this doesn't appear to actually fix anything. Please comment if I got something wrong.