Skip to content

Conversation

@waahm7
Copy link
Contributor

@waahm7 waahm7 commented May 2, 2025

Issue #, if available:
#74

Description of changes:

  • Remove SwiftLint Formatter, it had the following problems

    • No good way to automatically format everything
    • VSCode auto formatting had different formatting
    • Warning and Error levels for formatting issues. The warning results in just getting ignored indefinitely because sometimes they were from Code that you didn't touch.
  • Use Swift-Format (Not Swift Format which is a different popular 3p tool). It has the following advantages

    • Officially by Apple and automatically included in the Swift toolchain.
    • Only one customization required. We should try to avoid customizing the formatter and just use defaults.
    • One command to automatically format all swift files.
    • No warnings, only errors
    • Defaults seem sensible enough like line length etc so that we don't need to customize it a lot.

From Rust Fmt experience, I believe that an auto formatter is crucial so that we can ignore personal formatting preferences and just focus on coding.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@waahm7 waahm7 changed the title WIP | Remove Swift Lint and Use Swift-Format Remove Swift Lint and Use Swift-Format May 2, 2025
@waahm7 waahm7 marked this pull request as ready for review May 2, 2025 20:53
Copy link
Contributor

@sbSteveK sbSteveK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pull out the non-formatting related changes into a separate PR. Formatting shows a huge diff and we don't want to lose the point we made non-formatting changes to ci.yml.

@waahm7
Copy link
Contributor Author

waahm7 commented May 8, 2025

Let's pull out the non-formatting related changes into a separate PR. Formatting shows a huge diff and we don't want to lose the point we made non-formatting changes to ci.yml.

Thanks, updated.

@waahm7 waahm7 requested a review from sbSteveK May 8, 2025 22:17
- name: Run Swift-Format
run: |
brew install swift-format
swift-format lint --recursive --strict .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we specify a swift-format version so that we could use the same version across the team.

Copy link
Contributor Author

@waahm7 waahm7 May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question but unfortunately for swift-format, I don't think there is an easy way to specify a version. The only option I can think of is building from source, which will be a pain. We can do something like brew install swift-format@version, but as new versions will be released, brew won't keep the old versions.

Using the latest from brew should work as we can just do brew upgrade whenever new swift-format versions are released with any breaking changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this is that we will need to do a reformatting PR as soon as new versions of Swift-format are released with incompatible changes but I'm not sure how often that would be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiazhvera Any concerns with this approach or are we good to ship it?

Copy link
Contributor

@xiazhvera xiazhvera May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other concerns, good to go.

@waahm7 waahm7 merged commit ca8d8a8 into main May 16, 2025
16 checks passed
@waahm7 waahm7 deleted the fix-formatter branch May 16, 2025 17:09
@sbSteveK sbSteveK mentioned this pull request Oct 14, 2025
2 tasks
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

Successfully merging this pull request may close these issues.

3 participants