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

Formatting should be more opinionated #908

Open
JarnoRFB opened this issue Jan 3, 2025 · 1 comment
Open

Formatting should be more opinionated #908

JarnoRFB opened this issue Jan 3, 2025 · 1 comment

Comments

@JarnoRFB
Copy link

JarnoRFB commented Jan 3, 2025

This is of course only my opinion, but after just adopting swift-format it feels like there are a lot of configuration options. In comparison, other successful formatting tools like gofmt or Python's black have taken the approach to offer no or very little configuration options to avoid divergence in style and discussions in teams about formatting details.

Ideally, swift-format would produce the same result for every equivalent AST (though there can be pragmatic exemptions from this rule). However, adapting the default configuration today with "respectsExistingLineBreaks": true does not produce this strict result and using "respectsExistingLineBreaks": false can collapse code in unexpected ways.

Defining and documenting the reasons for the default style, which usually are opitimizing diffs and readability, have helped for me to conciliate myself with the strict rules imposed by other formatters.

So starting a discussion about how a strict formatting style could look like would be useful to ease the adoption of swift-format.

@ahoppen
Copy link
Member

ahoppen commented Jan 3, 2025

Synced to Apple’s issue tracker as rdar://142317828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants