Skip to content

Commit 6cf0a57

Browse files
authored
Use explicit set of rules in SwiftFormat and SwiftLint and bump versions (#987)
* Use explicit set of rules in SwiftFormat and SwiftLint and bump versions * [CI] Snapshots (#990)
1 parent f50d1a4 commit 6cf0a57

19 files changed

+97
-51
lines changed

.swiftformat

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,66 @@
22
--header "\nCopyright © {year} Stream.io Inc. All rights reserved.\n"
33
--swiftversion 5.9
44

5-
--ifdef no-indent
6-
--disable redundantType
7-
--disable extensionAccessControl
8-
--disable andOperator
9-
--disable hoistPatternLet
10-
--disable typeSugar
11-
12-
--disable redundantGet # it removes get async throws from getters
5+
# Use allow-list
6+
--rules blankLinesAroundMark
7+
--rules blankLinesAtEndOfScope
8+
--rules blankLinesAtStartOfScope
9+
--rules blankLinesBetweenScopes
10+
--rules braces
11+
--rules consecutiveBlankLines
12+
--rules consecutiveSpaces
13+
--rules duplicateImports
14+
--rules elseOnSameLine
15+
--rules emptyBraces
16+
--rules enumNamespaces
17+
--rules fileHeader
18+
--rules indent
19+
--rules initCoderUnavailable
20+
--rules isEmpty
21+
--rules leadingDelimiters
22+
--rules linebreakAtEndOfFile
23+
--rules linebreaks
24+
--rules modifierOrder
25+
--rules numberFormatting
26+
--rules redundantBackticks
27+
--rules redundantBreak
28+
--rules redundantExtensionACL
29+
--rules redundantFileprivate
30+
--rules redundantLet
31+
--rules redundantLetError
32+
--rules redundantNilInit
33+
--rules redundantObjc
34+
--rules redundantPattern
35+
--rules redundantRawValues
36+
--rules redundantVoidReturnType
37+
--rules semicolons
38+
--rules sortedImports
39+
--rules spaceAroundBraces
40+
--rules spaceAroundBrackets
41+
--rules spaceAroundComments
42+
--rules spaceAroundGenerics
43+
--rules spaceAroundOperators
44+
--rules spaceAroundParens
45+
--rules spaceInsideBraces
46+
--rules spaceInsideBrackets
47+
--rules spaceInsideComments
48+
--rules spaceInsideGenerics
49+
--rules spaceInsideParens
50+
--rules strongOutlets
51+
--rules strongifiedSelf
52+
--rules todos
53+
--rules trailingCommas
54+
--rules trailingSpace
55+
--rules unusedArguments
56+
--rules void
57+
--rules wrap
58+
--rules wrapArguments
59+
--rules wrapAttributes
60+
--rules yodaConditions
1361

14-
# Rules inferred from Swift Standard Library:
15-
--disable anyObjectProtocol, wrapMultilineStatementBraces
62+
# Configuration for enabled rules
63+
--ifdef no-indent
1664
--indent 4
17-
--enable isEmpty
18-
--disable redundantParens # it generates mistakes for e.g. "if (a || b), let x = ... {}"
1965
--semicolons inline
2066
--nospaceoperators ..., ..< # what about ==, +=?
2167
--commas inline

.swiftlint.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ excluded:
77
- Sources/StreamChatSwiftUI/StreamNuke
88

99
only_rules:
10-
# Currently enabled autocorrectable rules
1110
- attribute_name_spacing
1211
- closing_brace
1312
- colon
@@ -19,14 +18,15 @@ only_rules:
1918
- empty_enum_arguments
2019
- empty_parameters
2120
- empty_parentheses_with_trailing_closure
22-
- explicit_init
21+
- file_name_no_space
2322
- joined_default_parameter
2423
- leading_whitespace
2524
- legacy_cggeometry_functions
2625
- legacy_constant
2726
- legacy_constructor
2827
- legacy_nsgeometry_functions
2928
- mark
29+
- multiline_arguments
3030
- no_space_in_method_call
3131
- prefer_type_checking
3232
- private_over_fileprivate
@@ -52,5 +52,11 @@ only_rules:
5252
- vertical_whitespace
5353
- void_return
5454

55+
multiline_arguments:
56+
only_enforce_after_first_closure_on_first_line: true
57+
5558
trailing_whitespace:
56-
ignores_empty_lines: true
59+
ignores_empty_lines: true
60+
61+
file_name_no_space:
62+
severity: error

DemoAppSwiftUI/ChannelHeader/CustomChannelHeader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct CustomChannelModifier: ChannelListHeaderViewModifier {
7575
actionsPopupShown: $actionsPopupShown
7676
)
7777
#if compiler(>=6.2)
78-
.sharedBackgroundVisibility(.hidden)
78+
.sharedBackgroundVisibility(.hidden)
7979
#endif
8080
}
8181
} else {

Githubfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export YEETD_VERSION='1.0'
66
export SONAR_VERSION='6.2.1.4610'
77
export IPSW_VERSION='3.1.592'
88
export INTERFACE_ANALYZER_VERSION='1.0.7'
9-
export SWIFT_LINT_VERSION='0.55.1'
10-
export SWIFT_FORMAT_VERSION='0.47.12'
9+
export SWIFT_LINT_VERSION='0.59.1'
10+
export SWIFT_FORMAT_VERSION='0.58.2'
1111
export SWIFT_GEN_VERSION='6.5.1'

Sources/StreamChatSwiftUI/ChatChannel/ChannelHeader/ChatChannelHeaderViewModifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public struct DefaultChannelHeaderModifier<Factory: ViewFactory>: ChatChannelHea
118118
isActive: $isActive
119119
)
120120
#if compiler(>=6.2)
121-
.sharedBackgroundVisibility(.hidden)
121+
.sharedBackgroundVisibility(.hidden)
122122
#endif
123123
}
124124
} else {

Sources/StreamChatSwiftUI/ChatChannel/Gallery/ShareButtonView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ struct ShareButtonView: View {
2121
.customizable()
2222
.frame(width: 18, height: 22)
2323
})
24-
.foregroundColor(Color(colors.text))
25-
.sheet(isPresented: $isSharePresented) {
26-
ShareActivityView(activityItems: content)
27-
}
24+
.foregroundColor(Color(colors.text))
25+
.sheet(isPresented: $isSharePresented) {
26+
ShareActivityView(activityItems: content)
27+
}
2828
}
2929
}
3030

Sources/StreamChatSwiftUI/ChatChannel/MessageList/AsyncVoiceMessages/VoiceRecordingContainerView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ struct VoiceRecordingView: View {
153153
)
154154
)
155155
})
156-
.opacity(loading ? 0 : 1)
157-
.overlay(loading ? ProgressView() : nil)
156+
.opacity(loading ? 0 : 1)
157+
.overlay(loading ? ProgressView() : nil)
158158

159159
VStack(alignment: .leading, spacing: 4) {
160160
Text(

Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollCommentsView.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ struct PollCommentsView<Factory: ViewFactory>: View {
6464
.bold()
6565
.foregroundColor(colors.tintColor)
6666
})
67-
.frame(maxWidth: .infinity)
68-
.withPollsBackground()
69-
.uiAlert(
70-
title: commentButtonTitle,
71-
isPresented: $viewModel.addCommentShown,
72-
text: $viewModel.newCommentText,
73-
accept: L10n.Alert.Actions.send,
74-
action: { viewModel.add(comment: viewModel.newCommentText) }
75-
)
67+
.frame(maxWidth: .infinity)
68+
.withPollsBackground()
69+
.uiAlert(
70+
title: commentButtonTitle,
71+
isPresented: $viewModel.addCommentShown,
72+
text: $viewModel.newCommentText,
73+
accept: L10n.Alert.Actions.send,
74+
action: { viewModel.add(comment: viewModel.newCommentText) }
75+
)
7676
}
7777
}
7878
.padding()

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelSwipeableListItem.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,19 @@ public struct TrailingSwipeActionsView: View {
287287
leftButtonTapped(channel)
288288
}
289289
})
290-
.frame(width: buttonWidth)
291-
.foregroundColor(Color(colors.text))
292-
.background(Color(colors.background1))
290+
.frame(width: buttonWidth)
291+
.foregroundColor(Color(colors.text))
292+
.background(Color(colors.background1))
293293

294294
if channel.ownCapabilities.contains(.deleteChannel) {
295295
ActionItemButton(imageName: "trash", action: {
296296
withAnimation {
297297
rightButtonTapped(channel)
298298
}
299299
})
300-
.frame(width: buttonWidth)
301-
.foregroundColor(Color(colors.textInverted))
302-
.background(Color(colors.alert))
300+
.frame(width: buttonWidth)
301+
.foregroundColor(Color(colors.textInverted))
302+
.background(Color(colors.alert))
303303
}
304304
}
305305
}

Sources/StreamChatSwiftUI/CommonViews/NavigationBarThemeViewModifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import SwiftUI
66

77
extension View {
8-
nonisolated public func toolbarThemed<Content>(@ToolbarContentBuilder content toolbarContent: @escaping () -> Content) -> some View where Content: ToolbarContent {
8+
public nonisolated func toolbarThemed<Content>(@ToolbarContentBuilder content toolbarContent: @escaping () -> Content) -> some View where Content: ToolbarContent {
99
modifier(NavigationBarThemeViewModifier(toolbarContent: toolbarContent))
1010
}
1111
}

0 commit comments

Comments
 (0)