Skip to content

Commit 6ba9bd2

Browse files
authored
CI: SwiftFormat linting (#507)
1 parent f54a840 commit 6ba9bd2

13 files changed

+65
-45
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18+
lint:
19+
name: Lint
20+
runs-on: macos-latest
21+
steps:
22+
- name: Git Checkout
23+
uses: actions/checkout@v5
24+
25+
- name: Install SwiftFormat
26+
run: |
27+
brew unlink swiftformat
28+
brew install swiftformat --HEAD
29+
30+
- name: SwiftFormat Lint
31+
run: swiftformat --lint . --reporter github-actions-log
32+
1833
lint-podspec:
1934
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.title, '[skip ci]')
2035
name: Lint Podspec

.swiftformat

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33

44
--header ignore
55
--indent tab
6-
--ifdef preserve
6+
--ifdef no-indent
77
--ranges preserve
88
--extensionacl on-declarations
99
--trailing-commas always
1010
--nil-init insert
11+
--import-grouping testable-last
12+
--wrap-conditions before-first
13+
--guard-else next-line
1114

1215
# Disabled rules
1316
--disable blankLinesAroundMark
@@ -20,5 +23,7 @@
2023
--disable redundantStaticSelf
2124
--disable redundantType
2225
--disable redundantTypedThrows
26+
--disable redundantViewBuilder
2327
--disable unusedArguments
24-
--disable wrapSingleLineBodies
28+
--disable wrapFunctionBodies
29+
--disable wrapPropertyBodies

Sources/Introspect.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public struct IntrospectionScope: OptionSet, Sendable {
1313
@_spi(Internals) public let rawValue: UInt
1414

1515
@_spi(Internals) public init(rawValue: UInt) {
16-
self.rawValue = rawValue
16+
self.rawValue = rawValue
1717
}
1818
}
1919

@@ -55,7 +55,7 @@ extension View {
5555
scope: IntrospectionScope? = nil,
5656
customize: @escaping (PlatformSpecificEntity) -> Void
5757
) -> some View {
58-
self.modifier(IntrospectModifier(viewType, platforms: platforms, scope: scope, customize: customize))
58+
self.modifier(IntrospectModifier(viewType, platforms: platforms, scope: scope, customize: customize))
5959
}
6060
}
6161

Tests/Tests/TestUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ enum TestUtils {
1111
#endif
1212

1313
static func present(view: some View, file: StaticString = #file, line: UInt = #line) {
14-
if let window =
15-
UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }).first?.windows.first
14+
if
15+
let window = UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }).first?.windows.first
1616
??
1717
UIApplication.shared.windows.first
1818
{

Tests/Tests/ViewTypes/FormTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ struct FormTests {
2525

2626
Form {
2727
Text("Item 1")
28-
#if os(iOS) || os(tvOS) || os(visionOS)
29-
.introspect(.form, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2)
30-
.introspect(.form, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
31-
#endif
28+
#if os(iOS) || os(tvOS) || os(visionOS)
29+
.introspect(.form, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2)
30+
.introspect(.form, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
31+
#endif
3232
}
3333
}
3434
}

Tests/Tests/ViewTypes/FormWithGroupedStyleTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ struct FormWithGroupedStyleTests {
2828

2929
Form {
3030
Text("Item 1")
31-
#if os(iOS) || os(tvOS) || os(visionOS)
32-
.introspect(.form(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
33-
.introspect(.form(style: .grouped), on: .tvOS(.v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2)
34-
#elseif os(macOS)
35-
.introspect(.form(style: .grouped), on: .macOS(.v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2)
36-
#endif
31+
#if os(iOS) || os(tvOS) || os(visionOS)
32+
.introspect(.form(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
33+
.introspect(.form(style: .grouped), on: .tvOS(.v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2)
34+
#elseif os(macOS)
35+
.introspect(.form(style: .grouped), on: .macOS(.v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2)
36+
#endif
3737
}
3838
.formStyle(.grouped)
3939
}

Tests/Tests/ViewTypes/ListTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ struct ListTests {
2626

2727
List {
2828
Text("Item 1")
29-
#if os(iOS) || os(tvOS) || os(visionOS)
30-
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2)
31-
.introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
32-
#elseif os(macOS)
33-
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2)
34-
#endif
29+
#if os(iOS) || os(tvOS) || os(visionOS)
30+
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2)
31+
.introspect(.list, on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
32+
#elseif os(macOS)
33+
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2)
34+
#endif
3535
}
3636
}
3737
}

Tests/Tests/ViewTypes/ListWithBorderedStyleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct ListWithBorderedStyleTests {
2020

2121
List {
2222
Text("Item 1")
23-
.introspect(.list(style: .bordered), on: .macOS(.v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2)
23+
.introspect(.list(style: .bordered), on: .macOS(.v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2)
2424
}
2525
.listStyle(.bordered)
2626
}

Tests/Tests/ViewTypes/ListWithGroupedStyleTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ struct ListWithGroupedStyleTests {
2020

2121
List {
2222
Text("Item 1")
23-
.introspect(.list(style: .grouped), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2)
24-
.introspect(.list(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
23+
.introspect(.list(style: .grouped), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2)
24+
.introspect(.list(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
2525
}
2626
.listStyle(.grouped)
2727
}

Tests/Tests/ViewTypes/ListWithInsetGroupedStyleTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ struct ListWithInsetGroupedStyleTests {
2020

2121
List {
2222
Text("Item 1")
23-
.introspect(.list(style: .insetGrouped), on: .iOS(.v14, .v15), scope: .ancestor, customize: spy2)
24-
.introspect(.list(style: .insetGrouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
23+
.introspect(.list(style: .insetGrouped), on: .iOS(.v14, .v15), scope: .ancestor, customize: spy2)
24+
.introspect(.list(style: .insetGrouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
2525
}
2626
.listStyle(.insetGrouped)
2727
}

0 commit comments

Comments
 (0)