You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 15, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 15, 2023. It is now read-only.
Unnecessary format changes in JSX between 10.0.1 and 10.1.0-rc.1 #675
Hello, I investigated some popular formatter(prettier, deno format), and they put the > on a new line. Probably this code style is more familiar to Js users.
It seems like a breaking change maybe it is better to release in the next major if you are in favor of this change.
Actually for Prettier this is a configuration option (bracketSameLine). It's true that bracketSameLine = false is Prettier's default though (whereas what we have in ReScript 10.0 corresponds to bracketSameLine = true).
However, we are not following Prettier's defaults in other places either, e.g. Prettier 2.0+ has arrowParens = "always" as a default whereas ReScript's formatting corresponds to arrowParens = "avoid".
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?
// a minimal reproducible example
<A>
<B>
<ChatComponents.Sidebarvariant={own ? #Own : #Other} restrictedspaceBetweenButtons={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
<Aa=""/* comment */>
<B />
</A>
This situation is tricky to handle, another workaround is to put > on a new line if the tag or last prop has trailing comments. And I see prettier(with --bracket-same-line=true) does it in this way playground link
Activity
ah-yu commentedon Oct 14, 2022
Hello, I investigated some popular formatter(prettier, deno format), and they put the
>on a new line. Probably this code style is more familiar to Js users.It seems like a breaking change maybe it is better to release in the next major if you are in favor of this change.
IwanKaramazow commentedon Oct 14, 2022
Don't forget our existing users. We should try to reserve this for v11 and restore the previous way of formatting.
cristianoc commentedon Oct 14, 2022
We need to revert this change on branch 10.1 and add it to master with a changelog listing as breaking change.
cristianoc commentedon Oct 14, 2022
Since this is the syntax repo, seems best to revert here and leave an open PR to add it back.
And an issue on v11 milestone to add it later.
cknitt commentedon Oct 14, 2022
Actually for Prettier this is a configuration option (
bracketSameLine). It's true thatbracketSameLine = falseis Prettier's default though (whereas what we have in ReScript 10.0 corresponds tobracketSameLine = true).However, we are not following Prettier's defaults in other places either, e.g. Prettier 2.0+ has
arrowParens = "always"as a default whereas ReScript's formatting corresponds toarrowParens = "avoid".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?
IwanKaramazow commentedon Oct 14, 2022
Just took a quick look, it seems possible although it requires a bit more logic in the case of
cknitt commentedon Oct 15, 2022
@ah-yu @cristianoc I tested again with latest syntax and am now seeing changes like this one in our codebase:
=>
ah-yu commentedon Oct 15, 2022
Looks fine on my computer
ah-yu commentedon Oct 15, 2022
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)
@cknitt
ah-yu commentedon Oct 15, 2022
And it's weird. I use
dune exec -- rescript -print res -width 80 test.resto test, the result is right, but withmake test, the result is wrongah-yu commentedon Oct 15, 2022
This seems to be the correct behavior if the default width is
100.I tested with
rescript@9.1.4andrescript@10.0.1and the output is the same as aboveah-yu commentedon Oct 16, 2022
That was my mistake. This format change is a side effect of dealing with this format issue
This situation is tricky to handle, another workaround is to put
>on a new line if the tag or last prop has trailing comments. And I seeprettier(with--bracket-same-line=true) does it in this way playground link