rescript-lang / rescript-lang/rescript
Smart linebreak for expressions
Open
@fhammerschmidt is already working on this.
Since Oct 8, 2024.
syntax
- Dominant language
- OCaml
- Stars
- 7.5k
- Forks
- 485
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 55
Description
#6380 will be landed in v11. This changes the user's coding experience for the better.
So I wonder if the same improvement can be applied to other comma-separated things like literals and some expressions, which are currently formatted by the line-width rule.
arrays:
let a = ["foo", "bar", "baz"]
// into
let a = [
"foo",
"bar",
"baz", // automatically add trailing comma will be nicer
]
types/records/objects
let a = {foo: 1, bar: 2, baz: ["foo", "bar", "baz"]}
// into
let a = {
foo: 1,
bar: 2,
baz: ["foo", "bar", "baz"],
}
// and then
let a = {
foo: 1,
bar: 2,
baz: [
"foo",
"bar",
"baz",
],
}
fn applications:
// same as above
let _ = func(~param1="foo", ~param2=["foo", "bar"])
// into
let _ = func(
~param1="foo",
~param2=["foo", "bar"],
)
// and then
let _ = func(
~param1="foo",
~param2=[
"foo",
"bar",
],
)
And also I strongly want similar to be in JSX but not sure how much more complicated it will
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.
Assessment
This issue has not been assessed yet.