-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.swiftformat
236 lines (189 loc) · 6.95 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
# ==============
# == Excludes ==
# ==============
# Generated:
--exclude Sources/Parser/Generated/*
--exclude Sources/Bytecode/Generated/*
--exclude Sources/Objects/Generated/*
--exclude Tests/CompilerTests/Helpers/EmittedInstruction.swift
# ==================
# == Control flow ==
# ==================
--disable andOperator # Use '&&' ot ',' wherever you want
--enable wrapEnumCases
--enable wrapSwitchCases
--disable sortedSwitchCases
--elseposition same-line # I hate it, but this is 'community choice' in Swift
--guardelse auto
--enable elseOnSameLine
# Our own rule: all patterns should start at the same column,
# otherwise reader has to 'zig-zag' to read which pattern is bound where.
# (in other words: if all patterns have binding -> hoist, otherwise per variable)
#
# For example, this is not allowed (or at least frowned upon):
# switch frozen {
# case .elsa
# case let .anna(x) <-- nope, both 'elsa' and 'anna' should start the same column
# }
--patternlet hoist
--disable hoistPatternLet
# ==================
# == Declarations ==
# ==================
--enable anyObjectProtocol
--funcattributes prev-line # Function @attributes: "preserve", "prev-line", or "same-line"
--typeattributes prev-line # Type @attributes: "preserve", "prev-line", or "same-line"
--varattributes prev-line # Property @attributes: "preserve", "prev-line", or "same-line"
--enable wrapAttributes
# --wraparguments # Wrap all arguments: "before-first", "after-first", "preserve"
# --wrapparameters # Wrap func params: "before-first", "after-first", "preserve"
# --wrapcollections # Wrap array/dict: "before-first", "after-first", "preserve"
# --closingparen # Closing paren position: "balanced" (default) or "same-line"
# --wrapreturntype # Wrap return type: "if-multiline", "preserve" (default)
# --wrapconditions # Wrap conditions: "before-first", "after-first", "preserve"
--disable wrapArguments
# --modifierorder # we will use default order
--enable modifierOrder
--extensionacl on-declarations
--enable extensionAccessControl
--stripunusedargs closure-only
--enable unusedArguments
# ============
# == Braces ==
# ============
--allman false
--enable braces
--disable wrapMultilineStatementBraces
# --emptybraces #Empty braces: "no-space" (default), "spaced" or "linebreak"
--enable emptyBraces
# =================
# == Whitespaces ==
# =================
--linebreaks lf
--enable linebreaks
--enable blankLinesAroundMark
--disable blankLinesAtStartOfScope # we sometimes want empty line after 'class' definition
--enable blankLinesBetweenScopes
--enable blankLinesAtEndOfScope
--enable consecutiveBlankLines
--enable spaceAroundBraces
--enable spaceAroundBrackets
--enable spaceAroundComments
--enable spaceAroundGenerics
--enable spaceAroundParens
--enable spaceInsideBraces
--enable spaceInsideBrackets
--enable spaceInsideComments
--enable spaceInsideGenerics
--enable spaceInsideParens
--ifdef indent #if indenting: "indent" (default), "no-indent" or "outdent"
--indent 2
--indentcase false # Indent cases inside a switch: "true" or "false" (default)
--smarttabs enabled # Align code independently of tab width. defaults to "enabled"
--tabwidth unspecified # Don't use tabs!
--xcodeindentation disabled
--disable indent # This breaks a lof of already written stuff.
--trimwhitespace always
--enable trailingSpace
--nospaceoperators ..<, ...
--operatorfunc spaced
--ranges spaced # Spacing for ranges: "spaced" (default) or "no-space"
--enable spaceAroundOperators
--enable consecutiveSpaces
--enable linebreakAtEndOfFile
# =======================
# == File organization ==
# =======================
# We have our own (see: './Scipts/sort_swift_imports')
# But it is not required to follow it.
# --importgrouping alphabetized
--disable sortedImports
--enable duplicateImports
--enable enumNamespaces
--enable initCoderUnavailable # we dont use 'init(coder:)', but whatever
--header ignore # We don't have a header. Headers are ugly.
--enable fileHeader
# --marktypes never
# --typemark "MARK: - %t"
# --markextensions "never"
# --extensionmark "MARK: - %t + %c"
# --groupedextension "MARK: %c"
--disable markTypes # we do this by hand
# --categorymark - Template for category mark comments. Defaults to "MARK: %c"
# --beforemarks - Declarations placed before first mark (e.g. typealias,struct)
# --lifecycle - Names of additional Lifecycle methods (e.g. viewDidLoad)
# --organizetypes - Declarations to organize (default: class,actor,struct,enum)
# --structthreshold - Minimum line count to organize struct body. Defaults to 0
# --classthreshold - Minimum line count to organize class body. Defaults to 0
# --enumthreshold - Minimum line count to organize enum body. Defaults to 0
# --extensionlength - Minimum line count to organize extension body. Defaults to 0
--disable organizeDeclarations # we do this by hand
# --nowrapoperators # Comma-delimited list of operators that shouldn't be wrapped
# --assetliterals # Color/image literal width. "actual-width" or "visual-width"
# --maxwidth none # 80 is preferred (but not required), don't go over 100
--disable wrap # Breaks already written code
# ===============
# == Redundant ==
# ===============
--enable strongifiedSelf
--enable redundantBackticks
--enable redundantBreak
--enable redundantExtensionACL
--enable redundantFileprivate
--enable redundantGet
--enable redundantInit
--enable redundantLet
--enable redundantLetError
--enable redundantNilInit
--enable redundantObjc
--enable redundantParens
--enable redundantPattern
--enable redundantVoidReturnType
--disable redundantRawValues # It is 'ok' to specify raw value (even if it is the same as value)
--disable redundantReturn # Implicit = bad
--self insert # Yes!
--selfrequired
--enable redundantSelf
# --redundanttype # - Keep "inferred" (default) or "explicit" type annotation
--enable redundantType
# =============
# == Numbers ==
# =============
# Arguments are
# - group - group size (count % group == 0)
# - threshold - min digit count to apply (number.count >= threshold)
--decimalgrouping 3,1
--binarygrouping 4,1
--octalgrouping 4,1
--hexgrouping 4,1
--fractiongrouping enabled
--exponentgrouping enabled
--hexliteralcase lowercase
--exponentcase lowercase
--enable numberFormatting
# ===========
# == Other ==
# ===========
--semicolons inline
--enable semicolons
--commas always
--disable trailingCommas
--enable isEmpty
--enable preferKeyPath
--enable leadingDelimiters
--enable strongOutlets # Only applies to iOS
--enable todos
--voidtype void # How Void types are represented: "void" (default) or "tuple"
--enable void
--shortoptionals always # Use ? for Optionals "always" (default) or "except-properties"
--enable typeSugar
# --trailingclosures # Comma-delimited list of functions that use trailing closures
# --nevertrailing # List of functions that should never use trailing closures
--enable trailingClosures
# '0 < x && x < 10' is better than ' x > 0 && x < 10'
# --yodaswap # Swap yoda values: "always" (default) or "literals-only"
--disable yodaConditions
# ================
# == Deprecated ==
# ================
--disable specifiers