Skip to content

Smart linebreak for expressions #6432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cometkim opened this issue Oct 10, 2023 · 4 comments
Open

Smart linebreak for expressions #6432

cometkim opened this issue Oct 10, 2023 · 4 comments
Assignees
Labels

Comments

@cometkim
Copy link
Member

#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

@fhammerschmidt
Copy link
Member

For the record (haha): records already have smart breaking. [[Example]]

Copy link

github-actions bot commented Oct 8, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Old issues that went stale label Oct 8, 2024
@zth
Copy link
Collaborator

zth commented Oct 8, 2024

@fhammerschmidt @cometkim this one might still be interesting, right?

@cometkim
Copy link
Member Author

cometkim commented Oct 8, 2024

Definitely. IMHO, this shouldn't be stale

@fhammerschmidt fhammerschmidt added syntax and removed stale Old issues that went stale labels Oct 8, 2024
@fhammerschmidt fhammerschmidt self-assigned this Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

3 participants