swiftlang / swift-format

Formatting technology for Swift source code
Apache License 2.0
2.38k stars 216 forks source link

Request for official `.pre-commit-hooks.yaml` #676

Open theNded opened 5 months ago

theNded commented 5 months ago

Thanks for the great work!

I'm wondering if the dev team has a plan of supporting pre-commit. It would be super helpful to have the pre-commit hook config in the official repo.

Right now we cannot use the remote repo approach in configuring swift-format as a hook; we have to either fork the repo or use the local repo approach. For reference, this is my configuration:

- repo: local
  hooks:
  - id: swift-format
    name: swift-format
    entry: swift-format format -i --configuration .swift-format
    language: system
    types: [swift]
  - id: swift-lint
    name: swift-lint
    entry: swift-format lint --configuration .swift-format --strict
    language: system
    types: [swift]

Background: I've been using SwiftLint as the linter. It does provide a pre-commit hook, but it is less satisfactory for the formatting task.

ahoppen commented 2 months ago

Tracked in Apple’s issue tracker as rdar://126948337