Skip to content
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

[SR-12484] Make trailing comma behavior configurable (again) #332

Open
allevato opened this issue Apr 1, 2020 · 2 comments
Open

[SR-12484] Make trailing comma behavior configurable (again) #332

allevato opened this issue Apr 1, 2020 · 2 comments
Labels
bug Something isn't working swift-format

Comments

@allevato
Copy link
Collaborator

allevato commented Apr 1, 2020

Previous ID SR-12484
Radar rdar://problem/62201593
Original Reporter @allevato
Type Bug
Additional Detail from JIRA
Votes 2
Component/s swift-format
Labels Bug
Assignee None
Priority Medium

md5: 87a114148682a4a2db0f13538dd1e622

Issue Description:

When we migrated trailing comma correction to the pretty-printer (#120), we unintentionally lost the ability to disable it.

We should make it configurable again and consider a tri-state: do nothing (keep whatever the user wrote), always remove trailing commas, or always add trailing commas.

@beccadax
Copy link

@swift-ci create

@swift-ci
Copy link

Comment by Jeremy Saklad (JIRA)

I think it is also important to consider the primary purpose of trailing commas: making version control diffing cleaner.

I think the default behavior should be thus:

  1. Trailing commas are not used when an array or dictionary literal has one line

  2. Trailing commas are always used when an array or dictionary literal spans multiple lines with one item per line

  3. Array and dictionary literals that span multiple lines have one item per line

That’s just my personal opinion, of course. Each of those rules should be independently configurable.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working swift-format
Projects
None yet
Development

No branches or pull requests

3 participants