A Danger plugin to check Swift formatting using SwiftFormat.
This plugin is heavily inspired by danger-swiftlint.
Add this line to your Gemfile:
gem 'danger-swiftformat'SwiftFormat also needs to be installed before you run Danger.
Add this to your Dangerfile
swiftformat.check_formatBy default, danger-swiftformat will check added and modified files.
If you want errors to fail Danger, you can use the fail_on_error option:
swiftformat.check_format(fail_on_error: true)You can specify the swiftformat binary using the binary_path parameter:
swiftformat.binary_path = "/path/to/swiftformat"You can specify the Swift version of your project using the swiftversion parametter:
swiftformat.swiftversion = "5"You can specify additional swiftformat arguments using the additional_args parameter:
swiftformat.additional_args = "--indent tab --self insert"You can specify additional message (e.g. how to fix format issue) for danger comment using the additional_message parameter:
swiftformat.additional_message = "your additional message for contributor"By default, danger-swiftformat will run on any modified or created file ending in .swift. If you'd like to exclude
certain directories or files such as Pods, you can use the exclude parameter:
swiftformat.exclude = %w(Pods/** Carthage/** Sources/Nope.swift **/*_autogenerated.swift)If you want the format results shows in the diff instead of a comment, you can use the inline_mode option. Violations that are out of the diff will be shown in danger's fail or warn section:
swiftformat.inline_mode = trueThe exclude option takes an array of glob patterns; you can find additional documentation on the patterns
here.
- Clone this repo
- Run
bundle installto setup dependencies. - Run
bundle exec rake specto run the tests. - Use
bundle exec guardto automatically have tests run as you make changes. - Make your changes.
Use the release.sh script:
./scripts/release.shThen bump the gem to the next patch version.