-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.swiftformat
481 lines (358 loc) · 13.3 KB
/
.swiftformat
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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# Swift Version
--swiftversion 6.0
# SwiftFormat Version
--minversion 0.55.3
# Options
## Acronyms to auto-capitalize. Defaults to ID,URL,UUID.
--acronyms ID,URL,UUID,API
## Date format to use in file headers: system (default), iso, dmy, mdy, or custom.
--dateformat mdy
## Change type with only static members to enum: always (default) or structs-only.
--enumnamespaces structs-only
## Place ACL on-extension (default) or on-declarations.
--extensionacl on-declarations
## Function @attributes: preserve, prev-line, or same-line.
--funcattributes prev-line
## Mark for extension grouped with extended type: "MARK: %c" (default).
--groupedextension "MARK: - %c"
## Header comments: strip, ignore, or the text you wish use.
--header \n {file}\n\n Copyright © {year} Fetch.\n
## #if indenting: indent (default), no-indent, or outdent.
--ifdef no-indent
## testable-first/last, alpha (default), or length.
--importgrouping testable-last
## Number of spaces to indent, or tab to use tabs.
--indent 4
## Mark extensions always (default), never, if-not-empty
--markextensions never
## Mark types always (default), never, or if-not-empty
--marktypes never
## Maximum length of a line before wrapping or none (default).
--maxwidth 100
## Spacing for ranges: spaced (default) or no-space.
--ranges no-space
## Redundant type: inferred, explicit, or infer-locals-only (default).
--redundanttype inferred
## Explicit self: insert, remove (default), or init-only.
--self insert
## Allow semicolons: never or inline (default).
--semicolons never
## Mark unused function arguments with _: closure-only, unnamed-only, or always (default).
--stripunusedargs closure-only
## The width of a tab character. Defaults to unspecified.
--tabwidth 4
## Trim trailing space: always (default) or nonblank-lines.
--trimwhitespace always
## Type @attributes: preserve, prev-line, or same-line.
--typeattributes prev-line
## Blank lines from types: remove (default) or preserve.
--typeblanklines preserve
## Property @attributes: preserve, prev-line, or same-line.
--varattributes preserve
## Wrap all arguments: before-first, after-first, preserve.
--wraparguments before-first
## Wrap array/dict: before-first, after-first, preserve.
--wrapcollections before-first
## Wrap conditions: before-first, after-first, preserve.
--wrapconditions preserve
## Wrap effects: if-multiline, never, preserve.
--wrapeffects never
## Wrap func params: before-first, after-first, preserve
--wrapparameters before-first
## Wrap ternary operators: default, before-operators
--wrapternary before-operators
## Wrap typealiases: before-first, after-first, preserve
--wraptypealiases before-first
# Rules
## Capitalize acronyms when the first character is capitalized.
### Options:
### --acronyms (default: ID,URL,UUID)
--rules acronyms
## Prefer comma over && in if, guard or while conditions.
--rules andOperator
## Prefer AnyObject over class in protocol definitions.
--rules anyObjectProtocol
## Replace obsolete @UIApplicationMain and @NSApplicationMain attributes
## with @main for Swift 5.3 and above.
--rules applicationMain
## Changes all instances of assert(false, ...) to assertionFailure(...)
## and precondition(false, ...) to preconditionFailure(...).
--rules assertionFailures
## Insert blank line after import statements.
--rules blankLineAfterImports
## Insert blank line before and after MARK: comments.
### Options:
### --lineaftermarks (default: true)
--rules blankLinesAroundMark
## Remove trailing blank line at the end of a scope.
--rules blankLinesAtEndOfScope
## Remove leading blank line at the start of a scope.
### Options:
### --typeblanklines (default: remove)
--rules blankLinesAtStartOfScope
## Remove blank lines between chained functions but keep the linebreaks.
--rules blankLinesBetweenChainedFunctions
## Remove blank lines between import statements.
--rules blankLinesBetweenImports
## Insert blank line before class, struct, enum, extension, protocol or function declarations.
--rules blankLinesBetweenScopes
## Convert block comments to consecutive single line comments.
--rules blockComments
## Wrap braces in accordance with selected style (K&R or Allman).
### Options:
### --allman (default: false)
--rules braces
## Assign properties using if / switch expressions.
--rules conditionalAssignment
## Replace consecutive blank lines with a single blank line.
--rules consecutiveBlankLines
## Replace consecutive spaces with a single space.
--rules consecutiveSpaces
## Use doc comments for API declarations, otherwise use regular comments.
--rules docComments
## Remove duplicate import statements.
--rules duplicateImports
## Place else, catch, or while keyword in accordance with current style (same or next line).
### Options:
### --elseposition (default: same-line)
### --guardelse (default: auto)
--rules elseOnSameLine
## Remove whitespace inside empty braces.
### Options:
### --emptybraces (default: no-space)
--rules emptyBraces
## Convert types used for hosting only static members into enums
## (an empty enum is the canonical way to create a namespace in Swift as it can't be instantiated).
### Options:
### --enumnamespaces (default: always)
--rules enumNamespaces
## Configure the placement of an extension's access control keyword.
### Options:
### --extensionacl (default: on-extension)
--rules extensionAccessControl
## Use specified source file header template for all files.
### Options:
### --header
--rules fileHeader
## Use angle brackets (extension Array<Foo>) for generic type extensions
## instead of type constraints (extension Array where Element == Foo).
### Options:
### --generictypes
--rules genericExtensions
## Ensure file name in header comment matches the actual file name.
--rules headerFileName
## Reposition let or var bindings within pattern.
### Options:
### --patternlet (default: hoist)
--rules hoistPatternLet
## Indent code in accordance with the scope level.
### Options:
### --indent
### --tabwidth (default: unspecified)
### --smarttabs (default: enabled)
### --indentcase (default: false)
### --ifdef (default: indent)
### --xcodeindentation (default: disabled)
### --indentstrings (default: false)
--rules indent
## Add @available(*, unavailable) attribute to required init(coder:) when it hasn't been implemented.
--rules initCoderUnavailable
## Prefer isEmpty over comparing count against zero.
--rules isEmpty
## Move leading delimiters to the end of the previous line.
--rules leadingDelimiters
## Add empty blank line at end of file.
--rules linebreakAtEndOfFile
## Use specified linebreak character for all linebreaks (CR, LF or CRLF).
### Options:
### --linebreaks (default: lf)
--rules linebreaks
## Add a MARK comment before top-level types and extensions.
### Options:
### --marktypes (default: always)
### --typemark (default: MARK: - %t)
### --markextensions (default: always)
### --extensionmark (default: MARK: - %t + %c)
### --groupedextension (default: MARK: %c)
--rules markTypes
## Use consistent ordering for member modifiers.
### Options:
### --modifierorder
--rules modifierOrder
## Use consistent grouping for numeric literals.
## Groups will be separated by _ delimiters to improve readability.
## For each numeric type you can specify a group size (the number of digits in each group)
## and a threshold (the minimum number of digits in a number before grouping is applied).
### Options:
### --decimalgrouping (default: 3,6)
### --binarygrouping (default: 4,8)
### --octalgrouping (default: 4,8)
### --hexgrouping (default: 4,8)
### --fractiongrouping (default: disabled)
### --exponentgrouping (default: disabled)
### --hexliteralcase (default: uppercase)
### --exponentcase (default: uppercase)
--rules numberFormatting
## Use opaque generic parameters (some Protocol)
## instead of generic parameters with constraints (T where T: Protocol, etc) where equivalent.
## Also supports primary associated types for common standard library types,
## so definitions like T where T: Collection, T.Element == Foo are updated to some Collection<Foo>.
### Options:
### --someany (default: true)
--rules opaqueGenericParameters
## Convert trivial map { $0.foo } closures to keyPath-based syntax.
--rules preferKeyPath
## Remove redundant backticks around identifiers.
--rules redundantBackticks
## Remove redundant break in switch case.
--rules redundantBreak
## Removes redundant closures bodies, containing a single statement, which are called immediately.
--rules redundantClosure
## Remove redundant access control modifiers.
--rules redundantExtensionACL
## Prefer private over fileprivate where equivalent.
--rules redundantFileprivate
## Remove unneeded get clause inside computed properties.
--rules redundantGet
## Remove explicit init if not required.
--rules redundantInit
## Remove redundant internal access control.
--rules redundantInternal
## Remove redundant let/var from ignored variables.
--rules redundantLet
## Remove redundant let error from catch clause.
--rules redundantLetError
## Remove redundant nil default value (Optional vars are nil by default).
--rules redundantNilInit
## Remove redundant @objc annotations.
--rules redundantObjc
## Remove redundant identifiers in optional binding conditions.
--rules redundantOptionalBinding
## Remove redundant parentheses.
--rules redundantParens
## Remove redundant parentheses.
--rules redundantPattern
## Remove redundant raw string values for enum cases.
--rules redundantRawValues
## Remove unneeded return keyword.
--rules redundantReturn
## Insert/remove explicit self where applicable.
### Options:
### --self (default: remove)
### --selfrequired
--rules redundantSelf
## Remove redundant type from variable declarations.
--rules redundantType
## Remove explicit Void return type.
### Options:
### --closurevoid (default: remove)
--rules redundantVoidReturnType
## Remove semicolons.
### Options:
### --semicolons (default: inline).
--rules semicolons
## Sorts the body of declarations with // swiftformat:sort
## and declarations between // swiftformat:sort:begin
## and // swiftformat:sort:end comments.
--rules sortDeclarations
## Sort import statements alphabetically.
### Options:
### --importgrouping (default: alpha)
--rules sortImports
## Sort switch cases alphabetically.
--rules sortSwitchCases
## Sort protocol composition typealiases alphabetically.
--rules sortTypealiases
## Add or remove space around curly braces.
--rules spaceAroundBraces
## Add or remove space around square brackets.
--rules spaceAroundBrackets
## Add space before and/or after comments.
--rules spaceAroundComments
## Remove space around angle brackets.
--rules spaceAroundGenerics
## Add or remove space around operators or delimiters.
### Options:
### --operatorfunc (default: spaced)
### --nospaceoperators
### --ranges (default: spaced)
--rules spaceAroundOperators
## Add or remove space around parentheses.
--rules spaceAroundParens
## Add space inside curly braces.
--rules spaceInsideBraces
## Remove space inside square brackets.
--rules spaceInsideBrackets
## Add leading and/or trailing space inside comments.
--rules spaceInsideComments
## Remove space inside angle brackets.
--rules spaceInsideGenerics
## Remove space inside parentheses.
--rules spaceInsideParens
## Remove weak modifier from @IBOutlet properties.
--rules strongOutlets
## Remove backticks around self in Optional unwrap expressions.
--rules strongifiedSelf
## Use correct formatting for TODO:, MARK: or FIXME: comments.
--rules todos
## Use trailing closure syntax where applicable.
### Options:
### --trailingclosures
### --nevertrailing
--rules trailingClosures
## Add or remove trailing comma from the last item in a collection literal.
### Options:
### --commas (default: always)
--rules trailingCommas
## Remove trailing space at end of a line.
### Options:
### --trimwhitespace (default: always)
--rules trailingSpace
## Prefer shorthand syntax for Arrays, Dictionaries and Optionals.
### Options:
### --shortoptionals (default: always)
--rules typeSugar
## Mark unused function arguments with _.
### Options:
### --stripunusedargs (default: always).
--rules unusedArguments
## Use Void for type declarations and () for values.
### Options:
### --voidtype (default: void)
--rules void
## Wrap lines that exceed the specified maximum width.
### Options:
### --maxwidth (default: none)
### --nowrapoperators
### --assetliterals
### --wrapternary (default: default)
--rules wrap
## Align wrapped function arguments or collection elements.
### Options:
### --wraparguments
### --wrapparameters
### --wrapcollections
### --closingparen (default: balanced)
### --wrapreturntype (default: preserve)
### --wrapconditions
### --wraptypealiases
### --wrapeffects
--rules wrapArguments
## Wrap @attributes onto a separate line, or keep them on the same line.
### Options:
### --funcattributes
### --typeattributes
### --varattributes
--rules wrapAttributes
## Wrap the bodies of inline conditional statements onto a new line.
--rules wrapConditionalBodies
## Rewrite comma-delimited enum cases to one case per line.
### Options:
### --wrapenumcases (default: always)
--rules wrapEnumCases
## Wrap the opening brace of multiline statements.
--rules wrapMultilineStatementBraces
## Prefer constant values to be on the right-hand-side of expressions.
### Options:
### --yodaswap (default: always)
--rules yodaConditions