-
Notifications
You must be signed in to change notification settings - Fork 468
Improve jsx preserve output #7439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
rescript
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/win32-x64
@rescript/darwin-arm64
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! This is great.
Some remarks:
</span> | ||
]; | ||
|
||
let _container_with_spread_children = <div className={"barry"} title={"barry"}> | ||
{baseChildren} | ||
let _container_with_spread_children = <div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could/should add a line break (+ indent) before the opening tag, too?
className={"barry"} | ||
> | ||
{"Hello, world!"} | ||
<input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a further improvement, maybe we could break only if there is more than one prop?
onMouseDown={param => {}} | ||
> | ||
<p | ||
className={"bar"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible improvement: Do not add braces for string props.
let _container_with_spread_props_keyed = <div key={"barry-key"} {...newrecord$4} title={"barry"} className={"barry"}> | ||
{"Hello, world!"} | ||
<input type={"text"}/> | ||
let _container_with_spread_props_keyed = <div key={"barry-key"} {...newrecord$4} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also break before the key
prop and before the props spread.
@cknitt just my 5c, but it honestly feels like wasted effort to go into this much details in formatting. IMO the current state in this PR is good (great!) enough, and more details/improvements should be solved in a better way than us going down the rabbit hole of trying to replicate Prettier et al. A better long term solution that we've talked a bit about is that Rewatch could potentially do real formatting via Biome or similar, on all of our generated JS. We had a discussion about that with @jfrolich on the retreat. Then we'll have solved all of our formatting issues for the foreseeable future. |
I am a bit skeptical of the Biome idea. But I agree that replicating prettier is a non-goal. My comments are mostly just suggestions, except for the last one where the output is inconsistent with the other examples. I would say let's do what can be done with little effort. |
I would like to merge this as is. I consider this "improved." Others can still send PRs to their heart's content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Great work!
Fixes #7434