rescript-lang / rescript-lang/rescript

Smart linebreak for expressions

Open
#6,432 6 comments 2 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.