-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy path.swiftlint.yml
More file actions
203 lines (145 loc) · 5.79 KB
/
Copy path.swiftlint.yml
File metadata and controls
203 lines (145 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
swiftlint_version: 0.63.3
included:
- Sources
- Tests
- Modules/Sources
- Modules/Tests
- WordPress
# Rules – Opt-in only, so we can progressively introduce new ones
#
only_rules:
# Prefer `Array(xs)` over `xs.map { $0 }`.
- array_init
# All elements in a collection literal should be vertically aligned.
- collection_alignment
# Colons should be next to the identifier when specifying a type.
- colon
# There should be no space before and one after any comma.
- comma
# There should be a space after the comma in inheritance lists.
- comma_inheritance
# Prefer `contains` over `filter(where:).count`.
- contains_over_filter_count
# Prefer `contains` over using `filter(where:).isEmpty`.
- contains_over_filter_is_empty
# Prefer `contains` over `first(where:) != nil`.
- contains_over_first_not_nil
# Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`.
- contains_over_range_nil_comparison
# if,for,while,do statements shouldn't wrap their conditionals in parentheses.
- control_statement
# Allow custom rules. See the end of the config for our custom rules
- custom_rules
- discarded_notification_center_observer
- duplicate_imports
# Prefer checking `isEmpty` over comparing `count` to zero.
- empty_count
# Arguments can be omitted when matching enums with associated types if they
# are not used.
- empty_enum_arguments
# Prefer `() -> ` over `Void -> `.
- empty_parameters
# Prefer checking `isEmpty` over comparing to empty string literal `""`.
- empty_string
# Avoid explicitly calling `.init()`; prefer `Type(...)` over `Type.init(...)`.
- explicit_init
# Prefer `first(where:)` over `filter { }.first`.
- first_where
# Prefer `flatMap { ... }` over `map { ... }.reduce([], +)`.
- flatmap_over_map_reduce
# When calling the `joined` method on an array of strings, omit an
# explicit empty-string separator since that is the default.
- joined_default_parameter
# Prefer `last(where:)` over `filter { }.last`.
- last_where
# Trailing closing brackets/parens of literal expressions (arrays, dicts)
# should match the indentation of the line that introduced them.
- literal_expression_end_indentation
# MARK comment should be in valid format.
- mark
# Opening braces should be preceded by a single space and on the same line as
# the declaration.
- opening_brace
- operator_usage_whitespace
- overridden_super_call
# There should be no whitespace immediately after a period.
- period_spacing
# Example: CGPoint.zero instead of CGPoint(x: 0, y: 0)
- prefer_zero_over_explicit_init
# Prefer `reduce(into:_:)` over `reduce(_:_:)` for non-trivial accumulator types.
- reduce_into
# `nil` coalescing on a non-optional is redundant.
- redundant_nil_coalescing
# Type annotations are redundant when the type can be inferred.
- redundant_type_annotation
- shorthand_optional_binding
# Prefer `someBool.toggle()` over `someBool = !someBool`.
- toggle_bool
# Prefer `min(by:)` / `max(by:)` over `sorted { ... }.first` / `.last`.
- sorted_first_last
# Files should have a single trailing newline.
- trailing_newline
# Lines should not have trailing semicolons.
- trailing_semicolon
# Lines should not have trailing whitespace.
- trailing_whitespace
# Closure arguments don't need to be wrapped in parentheses.
- unneeded_parentheses_in_closure_argument
# Catch statements should not declare error variables without type casting.
- untyped_error_in_catch
# Unused parameter in a closure should be replaced with _.
- unused_closure_parameter
- vertical_whitespace
- vertical_whitespace_closing_braces
- weak_delegate
# Rules configuration
#
control_statement:
severity: error
discarded_notification_center_observer:
severity: error
opening_brace:
ignore_multiline_statement_conditions: true
operator_usage_whitespace:
skip_aligned_constants: false
overridden_super_call:
severity: error
trailing_whitespace:
ignores_empty_lines: false
ignores_comments: false
weak_delegate:
severity: error
# Custom rules
#
custom_rules:
natural_content_alignment:
name: "Natural Content Alignment"
regex: '\.contentHorizontalAlignment(\s*)=(\s*)(\.left|\.right)'
message: "Forcing content alignment left or right can affect the Right-to-Left layout. Use naturalContentHorizontalAlignment instead."
severity: warning
natural_text_alignment:
name: "Natural Text Alignment"
regex: '\.textAlignment(\s*)=(\s*).left'
message: "Forcing text alignment to left can affect the Right-to-Left layout. Consider setting it to `natural`"
severity: warning
inverse_text_alignment:
name: "Inverse Text Alignment"
regex: '\.textAlignment(\s*)=(\s*).right'
message: "When forcing text alignment to the right, be sure to handle the Right-to-Left layout case properly, and then silence this warning with this line `// swiftlint:disable:next inverse_text_alignment`"
severity: warning
localization_comment:
name: "Localization Comment"
regex: 'NSLocalizedString([^,]+,\s+comment:\s*"")'
message: "Localized strings should include a description giving context for how the string is used."
severity: warning
string_interpolation_in_localized_string:
name: "String Interpolation in Localized String"
regex: 'NSLocalizedString\("[^"]*\\\(\S*\)'
message: "Localized strings must not use interpolated variables. Instead, use `String(format:`"
severity: error
swiftui_localization:
name: "SwiftUI Localization"
regex: 'LocalizedStringKey'
message: "Using `LocalizedStringKey` is incompatible with our tooling and doesn't allow you to provide a hint/context comment for translators either. Please use `NSLocalizedString` instead, even with SwiftUI code."
severity: error
excluded: '.*Widgets/.*'