-
Notifications
You must be signed in to change notification settings - Fork 38
Unnecessary format changes in JSX between 10.0.1 and 10.1.0-rc.1 #675
Comments
Hello, I investigated some popular formatter(prettier, deno format), and they put the It seems like a breaking change maybe it is better to release in the next major if you are in favor of this change. |
Don't forget our existing users. We should try to reserve this for v11 and restore the previous way of formatting. |
We need to revert this change on branch 10.1 and add it to master with a changelog listing as breaking change. |
Since this is the syntax repo, seems best to revert here and leave an open PR to add it back. |
Actually for Prettier this is a configuration option ( However, we are not following Prettier's defaults in other places either, e.g. Prettier 2.0+ has I agree that, if we do this format change, we should do it in v11, but I am not really convinced that we should do it at all. #664 was about fixing a missing comments case - can this be solved without introducing the format change? |
Just took a quick look, it seems possible although it requires a bit more logic in the case of
|
@ah-yu @cristianoc I tested again with latest syntax and am now seeing changes like this one in our codebase: <ChatComponents.Sidebar
variant={own ? #Own : #Other}
restricted
spaceBetweenButtons={message.location->Option.isSome}>
{children}
</ChatComponents.Sidebar> => <ChatComponents.Sidebar
variant={own ? #Own : #Other} restricted spaceBetweenButtons={message.location->Option.isSome}>
{children}
</ChatComponents.Sidebar> |
Looks fine on my computer zheyzhang@HANM18365 syntax % dune exec -- rescript -print res -width 80 test.res
<ChatComponents.Sidebar
variant={own ? #Own : #Other}
restricted
spaceBetweenButtons={message.location->Option.isSome}>
{children}
</ChatComponents.Sidebar>
zheyzhang@HANM18365 syntax % |
I confirm that. But it seems that is not introduced in my PR. I revert my changes and that issue still exists. See #684 (comment) |
And it's weird. I use |
<ChatComponents.Sidebar
variant={own ? #Own : #Other} restricted spaceBetweenButton={message.location->Option.isSome}>
{children}
</ChatComponents.Sidebar> This seems to be the correct behavior if the default width is I tested with |
// a minimal reproducible example
<A>
<B>
<ChatComponents.Sidebar
variant={own ? #Own : #Other} restricted spaceBetweenButtons={message.location->Option.isSome}>
{children}
</ChatComponents.Sidebar>
</B>
</A> That was my mistake. This format change is a side effect of dealing with this format issue <A
a=""
/* comment */>
<B />
</A> This situation is tricky to handle, another workaround is to put <A
a=""
/* comment */
>
<B />
</A> |
I just installed 10.1.0-rc.1 in a project of ours for testing and ran the formatter across the code. This resulted in 83 files changed.
The reason was that as a side effect of #664, JSX tags are now formatted differently, as can also be seen in the test result diffs in this PR.
Before:
After:
While it may be debatable which style is better, I think the difference is not worth causing so many format changes in users' codebases.
The text was updated successfully, but these errors were encountered: