dprint-plugin-typescript
dprint-plugin-typescript copied to clipboard
Keep bracket of jsx expression in a single new line
If we have a code like:
function Ok() {
return (
<div>
{
isThisConditionOk
? (
<p><strong>Yes</strong></p>
)
: (
<p><strong>No</strong></p>
)
}
</div>
);
}
We expect it to be unchanged, actually it is formatted like:
function Ok() {
return (
<div>
{isThisConditionOk
? (
<p>
<strong>Yes</strong>
</p>
)
: (
<p>
<strong>No</strong>
</p>
)}
</div>
);
}
Line breaks after {
and before }
are deleted, this cause unpaired indentation and hard-to-read )}
.
Expression in jsx attribute has the same behavior:
function Ok() {
return (
<div
render={
work(
nice,
to,
have
)
}
/>
);
}
is unexpectedly formatted to:
function Ok() {
return (
<div
render={work(
nice,
to,
have,
)}
/>
);
}
Meybe we can have a new option to force {
and }
in a standalone new line
Don't forget to vote on this issue. I am looking for exactly the same.
I am willing to implement this feature if we can get confirmation (from a maintainer) that it is desired.
This is currently one of the few formatting idiosyncrasies (compared to prettier/biomejs) that are keeping my team from switching to dprint's formatter.
@dsherret Would you be willing to accept such a contribution?