-
Notifications
You must be signed in to change notification settings - Fork 0
/
.swiftlint.yml
395 lines (317 loc) · 11.1 KB
/
.swiftlint.yml
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# See all available rules: https://realm.github.io/SwiftLint/rule-directory.html
# Don't use `included` parameter even though we'd like to limit which paths should be linted.
# When it's set, all paths passed as arguments to the command are ignored.
# SwiftLint by default isn't efficient in excluding, `--use-alternative-excluding` flag makes it faster.
excluded:
- .direnv
- android
- apps
- bin
- docs
- exponent-view-template
- fastlane
- guides
- home
- ios/Pods
- ios/vendored
- ios/versioned
- ios/versioned-react-native
- node_modules
- packages/*/ios/Tests
- packages/*/ios/UITests
- packages/expo-module-template
- react-native-lab
- scripts
- secrets
- template-files
- tools
# Enable rules that are turned off by default. Run `swiftlint rules` to see what's available to opt-in.
opt_in_rules:
- anyobject_protocol
- array_init
- capture_variable
- closure_body_length
- closure_end_indentation
- closure_spacing
- collection_alignment
- comma_inheritance
- conditional_returns_on_newline
- discouraged_object_literal
- empty_collection_literal
- empty_count
- empty_string
- enum_case_associated_values_count
- fatal_error_message
- file_name_no_space
- force_unwrapping
- identical_operands
- implicitly_unwrapped_optional
- indentation_width
- legacy_objc_type
- literal_expression_end_indentation
- local_doc_comment
- lower_acl_than_parent
- multiline_arguments
- multiline_function_chains
- multiline_literal_brackets
- multiline_parameters
- multiline_parameters_brackets
- no_grouping_extension
- number_separator
- operator_usage_whitespace
- overridden_super_call
- prefer_zero_over_explicit_init
- prohibited_super_call
- redundant_nil_coalescing
- static_operator
- unavailable_function
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- unused_declaration
- unused_import
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- yoda_condition
# Disable some rules that are turned on by default.
disabled_rules:
- reduce_boolean
- todo
- weak_delegate
# Prefer using AnyObject over class for class-only protocols.
anyobject_protocol: warning
# Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array.
array_init: warning
# Non-constant variables should not be listed in a closure’s capture list
# to avoid confusion about closures capturing variables at creation time.
capture_variable: warning
# Closure bodies should not span too many lines.
closure_body_length:
warning: 30
error: 50
# Closure end should have the same indentation as the line that started it.
closure_end_indentation: warning
# Closure expressions should have a single space inside each brace.
closure_spacing: warning
# All elements in a collection literal should be vertically aligned.
collection_alignment:
severity: warning
align_colons: false
# Use commas to separate types in inheritance lists.
comma_inheritance: warning
# if, for, guard, switch, while, and catch statements shouldn’t unnecessarily wrap their conditionals or arguments in parentheses.
control_statement: warning
# Limits the complexity of function bodies.
cyclomatic_complexity:
warning: 12
error: 20
ignores_case_statements: true
# Prefer initializers over object literals.
discouraged_object_literal:
severity: error
image_literal: true
color_literal: true
# Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal.
empty_collection_literal: warning
# Prefer checking `isEmpty` over comparing count to zero.
empty_count:
severity: warning
only_after_dot: true
# When using trailing closures, empty parentheses should be avoided after the method call.
empty_parentheses_with_trailing_closure: warning
# Prefer checking `isEmpty` over comparing string to an empty string literal.
empty_string: warning
# Number of associated values in an enum case should be low.
enum_case_associated_values_count:
warning: 5
error: 6
# A `fatalError` call should have a message.
fatal_error_message: error
# File name should not contain any whitespace.
file_name_no_space:
severity: error
# Force casts should be avoided.
force_cast: error
# Force tries should be avoided.
force_try: error
# Force unwrapping should be avoided.
force_unwrapping: error
# Functions bodies should not span too many lines.
function_body_length:
warning: 80
error: 100
# Comparing two identical operands is likely a mistake.
identical_operands: error
# Identifier names should only contain alphanumeric characters and start with a lowercase character or should only
# contain capital letters. In an exception to the above, variable names may start with a capital letter when they are
# declared static and immutable. Variable names should not be too long or too short.
identifier_name:
min_length: 1
max_length:
warning: 35
error: 50
validates_start_with_lowercase: true
# Ignore Sweet API components as they intentionally start with the uppercase letter.
allowed_symbols:
[
'_',
'AsyncFunction',
'Class',
'Constants',
'Constructor',
'Events',
'Function',
'Name',
'OnAppBecomesActive',
'OnAppContextDestroys',
'OnAppEntersBackground',
'OnAppEntersForeground',
'OnCreate',
'OnDestroy',
'OnStartObserving',
'OnStopObserving',
'Prop',
'Property',
'View',
'ViewManager',
]
# Implicitly unwrapped optionals should be avoided when possible.
implicitly_unwrapped_optional:
severity: error
# Indent code using either one tab or the configured amount of spaces,
# unindent to match previous indentations. Don’t indent the first line.
indentation_width:
severity: warning
indentation_width: 2
include_comments: false
# Tuples shouldn’t have too many members. Create a custom type instead.
large_tuple:
warning: 10
error: 10
# Files should not contain leading whitespace.
leading_whitespace: warning
# Struct-scoped constants are preferred over legacy global constants.
legacy_constant: warning
# Swift constructors are preferred over legacy convenience functions.
legacy_constructor: warning
# Prefer Swift value types to bridged Objective-C reference types.
legacy_objc_type: warning
# Lines should not span too many characters.
line_length:
warning: 160
error: 200
ignores_urls: true
ignores_function_declarations: false
ignores_comments: false
ignores_interpolated_strings: true
# Array and dictionary literal end should have the same indentation as the line that started it.
literal_expression_end_indentation: warning
# Doc comments shouldn’t be used in local scopes. Use regular comments.
local_doc_comment: warning
# Ensure declarations have a lower access control level than their enclosing parent.
lower_acl_than_parent: warning
# MARK comment should be in valid format. e.g. `// MARK: ...` or `// MARK: - ...`
mark: warning
# Arguments should be either on the same line, or one per line.
multiline_arguments:
severity: warning
# Chained function calls should be either on the same line, or one per line.
multiline_function_chains: warning
# Multiline literals should have their surrounding brackets in a new line.
multiline_literal_brackets: warning
# Functions and methods parameters should be either on the same line, or one per line.
multiline_parameters:
severity: warning
# Types should be nested at most 1 level deep, and functions should be nested at most 2 levels deep.
nesting:
type_level: 1
function_level: 2
# Multiline parameters should have their surrounding brackets in a new line.
multiline_parameters_brackets: warning
# Extensions shouldn’t be used to group code within the same source file.
no_grouping_extension: warning
# Underscores should be used as thousand separator in large decimal numbers.
number_separator:
severity: warning
minimum_length: 5
# Operators should be surrounded by a single whitespace when they are being used.
operator_usage_whitespace:
severity: warning
# A doc comment should be attached to a declaration.
orphaned_doc_comment: warning
# Some overridden methods should always call super.
overridden_super_call:
severity: warning
# Prefer `.zero` over explicit init with zero parameters (e.g. `CGPoint(x: 0, y: 0)`).
prefer_zero_over_explicit_init: warning
# Some methods should not call super.
prohibited_super_call:
severity: warning
# When declaring properties in protocols, the order of accessors should be `get set`.
protocol_property_accessors_order: warning
# nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant.
redundant_nil_coalescing: warning
# Initializing an optional variable with nil is redundant.
redundant_optional_initialization: warning
# Operators should be declared as static functions, not free functions.
static_operator: warning
# Files should have a single trailing newline.
trailing_newline: warning
# Lines should not have trailing semicolons.
trailing_semicolon: warning
# Lines should not have trailing whitespace.
trailing_whitespace:
severity: warning
ignores_empty_lines: false
ignores_comments: false
# Type bodies should not span too many lines.
type_body_length:
warning: 200
error: 350
# Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 35 characters in length.
type_name:
min_length: 3
max_length:
warning: 40
error: 50
# Unimplemented functions should be marked as unavailable.
unavailable_function: warning
# Parentheses are not needed when declaring closure arguments.
unneeded_parentheses_in_closure_argument: warning
# Prefer capturing references as weak to avoid potential crashes.
unowned_variable_capture: warning
# Unused reference in a capture list should be removed.
unused_capture_list: warning
# Unused parameter in a closure should be replaced with `_`.
unused_closure_parameter: warning
# Declarations should be referenced at least once within all files linted.
unused_declaration:
severity: warning
include_public_and_open: false
# When the index or the item is not used, `.enumerated()` can be removed.
unused_enumerated: warning
# All imported modules should be required to make the file compile.
unused_import:
severity: warning
# Prefer `!= nil` over `let _ =`
unused_optional_binding:
severity: warning
ignore_optional_try: false
# Setter value is not used.
unused_setter_value: warning
# Function parameters should be aligned vertically if they’re in multiple lines in a method call.
vertical_parameter_alignment_on_call: warning
# Limit vertical whitespace to a single empty line.
vertical_whitespace:
severity: warning
max_empty_lines: 1
# Don’t include vertical whitespace (empty line) before closing braces.
vertical_whitespace_closing_braces:
severity: warning
only_enforce_before_trivial_lines: false
# Don’t include vertical whitespace (empty line) after opening braces.
vertical_whitespace_opening_braces: warning
# Prefer `-> Void` over `-> ()`.
void_return: warning
# The variable should be placed on the left, the constant on the right of a comparison operator.
yoda_condition: warning