Skip to content

Commit 54d7ece

Browse files
authored
[gardening]: batch swiftlint calls for all modified files (#261)
### Issue the current pre-commit hook builds & runs swiftformat on every lint-able file, which can take a relatively long time if many changes have been made ### Description - updates commit hook script to make one call to swiftformat with all the files to lint - adds a `swiftversion` config specifying 5.7 as the language version the linter will use when running
1 parent fb95bae commit 54d7ece

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.hooks/pre-commit

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
2-
git diff --diff-filter=d --staged --name-only | grep -e '\.swift$' | while read line; do
3-
swift run swiftformat "${line}" --quiet;
4-
git add "$line";
5-
done
2+
3+
swift_files=$(git diff --diff-filter=d --staged --name-only -- '*.swift')
4+
5+
echo $swift_files | xargs swift run swiftformat --quiet
6+
7+
echo $swift_files | xargs git add

.swiftformat

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
--indent 4
1+
# file config
22

3+
--swiftversion 5.7
34
--exclude Pods,Tooling,**Dummy.swift
45

6+
# format config
7+
8+
--indent 4
9+
510
--wraparguments before-first
611
--importgrouping testable-bottom
712

0 commit comments

Comments
 (0)