rescript-lang / rescript-lang/rescript
long matches in switch statements mutline-formats records (but moving to next line is better)
Open
Nobody has claimed this yet.
formatter
- Dominant language
- OCaml
- Stars
- 7.5k
- Forks
- 485
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 55
Description
switch "" {
| "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" => {a: 1, b: 2, c: 3}
}
formats to:
switch "" {
| "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" => {
a: 1,
b: 2,
c: 3,
}
}
but this would likely be better:
switch "" {
| "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" =>
{a: 1, b: 2, c: 3}
}
the formatter won't let you do that, but splits it to multiplie lines again. workaround i use is to add a comment:
switch "" {
| "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" => //
{a: 1, b: 2, c: 3}
}
minor, but it's still an annoyance
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the formatter entry point for switch statements and match arms, then reproduce the supplied long-string example. Done means the formatter places a long match arm on the next line with its record kept compact, without requiring a comment workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100