-
Notifications
You must be signed in to change notification settings - Fork 156
Migrate from SwiftFormat to swift-format #248
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
Conversation
|
Tagging @ZachNagengast as he gave us good guidance on formatting last time. 100% agree these things are usually banal yet contentious. Any solution that works and causes minimal friction is fine with me. |
| /// - Parameters: | ||
| /// - localDir: The local directory where metadata files are downloaded. | ||
| /// - filePath: The path of the file for which metadata is being read. | ||
| /// - Parameter metadataPath: The path of the metadata file to read. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol nice
pcuenca
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike the unnecessary burden formatters impose, creating friction that in my opinion is artificial.
I'm happy to go with any solution that:
- Works for the team.
- Is acceptable / consistent with the community, especially projects in the neighborhood such as argmax's and mlx-swift.
ea8e0c5 to
66c4a66
Compare
SwiftFormat is a fantastic tool. But because it's not built-in to the Swift toolchain, adopting it for the project introduces friction. I've seen formatting issues creep up in several PR review threads (and not just from external contributors). To put some numbers behind that: GitHub says that the
formatworkflow fails 23% of the time (compared to 35% for unit tests)Me, I'll never remember to run this myself before committing changes, which is why I opened #216 to configure my editor to do this for me automatically. However, the suggested extension for SwiftFormat requires the user to have
swiftformatavailable inPATH.Even when
swiftformatis available, it's difficult to manage versions — as we saw in #212. I attempted to solve that by managing and running SwiftFormat via Swift Package Manager, but I don't like the ergonomics (swift package plugin --allow-writing-to-package-directory swiftformat --config .swiftformat .😵💫) and I especially don't like how it introduces a transitive dependency to all downstream consumers.So faced with these challenges, I propose that we go with the flow and standardize on
swift format, which is built into the Swift toolchain.I did my best to make
.swift-formatmatch the existing project settings as closely as possible. The resulting diff (97ad29f) is admittedly large, but I don't think it's too onerous (especially since we can ignore with.git-blame-ignore-revs). To my eyes, the formatting diff seems limited to:{ }->{})On the plus side,
swift formathas alintsubcommand that greatly simplifies our existing format checking workflow, and provides some helpful checks. For example, it flagged a few instances where documentation comments for a method were out of sync with the signature (e4f76dd).I understand and acknowledge that issues of project standards can be simultaneously contentious and banal. So I appreciate your taking the time to hear me out 🫶