forked from microsoft/fluentui-apple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.swiftlint.yml
200 lines (143 loc) · 6.42 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
only_rules:
# Delegate protocols should be class-only so they can be weakly referenced.
- class_delegate_protocol
# Closing brace with closing parenthesis should not have any whitespaces in the middle.
- closing_brace
# Closure end should have the same indentation as the line that started it.
- closure_end_indentation
# Colons should be next to the identifier when specifying a type and next to the key in dictionary literals.
- colon
# There should be no space before and one after any comma.
- comma
# Conditional statements should always return on the next line.
- conditional_returns_on_newline
# Prefer contains over first(where:) != nil
- contains_over_first_not_nil
# if, for, guard, switch, while, and catch statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses.
- control_statement
# Discouraged direct initialization of types that can be harmful (UIDevice, Bundle, etc)
- discouraged_direct_init
# Prefer () -> over Void ->.
- empty_parameters
# When using trailing closures, empty parentheses should be avoided after the method call.
- empty_parentheses_with_trailing_closure
# Properties should have a type interface
- explicit_type_interface
# Prefer to use extension access modifiers.
- extension_access_modifier
# A fatalError call should have a message.
- fatal_error_message
# Header comments should be consistent with project patterns.
- file_header
# Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters.
- identifier_name
# Computed read-only properties and subscripts should avoid using the get keyword.
- implicit_getter
# Files should not contain leading whitespace.
- leading_whitespace
# Struct-scoped constants are preferred over legacy global constants.
- legacy_constant
# Swift constructors are preferred over legacy convenience functions.
- legacy_constructor
# MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...'
- mark
# Modifier order should be consistent.
- modifier_order
# Functions and methods parameters should be either on the same line, or one per line.
- multiline_parameters
# Trailing closure syntax should not be used when passing more than one closure argument.
- multiple_closures_with_trailing_closure
# Opening braces should be preceded by a single space and on the same line as the declaration.
- opening_brace
# Operators should be surrounded by a single whitespace when they are being used.
- operator_usage_whitespace
# Some overridden methods should always call super
- overridden_super_call
# Prefer private over fileprivate declarations.
- private_over_fileprivate
# When declaring properties in protocols, the order of accessors should be get set.
- protocol_property_accessors_order
# Prefer _ = foo() over let _ = foo() when discarding a result from a function.
- redundant_discardable_let
# Initializing an optional variable with nil is redundant.
- redundant_optional_initialization
# Property setter access level shouldn't be explicit if it's the same as the variable access level.
- redundant_set_access_control
# String enum values can be omitted when they are equal to the enumcase name.
- redundant_string_enum_value
# Properties, variables, and constants should not have redundant type annotation
# This rule is currently disabled because it invokes false warnings for Bool
# Github issue tracked on swift lint https://github.com/realm/SwiftLint/issues/3578
# - redundant_type_annotation
# Returning Void in a function declaration is redundant.
- redundant_void_return
# Return arrow and return type should be separated by a single space or on a separate line.
- return_arrow_whitespace
# Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning.
- shorthand_operator
# Else and catch should be on the same line, one space after the previous declaration.
- statement_position
# SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation in the disabled region.
- superfluous_disable_command
# Case statements should vertically align with their enclosing switch statement, or indented if configured otherwise.
- switch_case_alignment
# Cases inside a switch should always be on a newline.
- switch_case_on_newline
# Shorthand syntactic sugar should be used, i.e. [Int] instead of Array.
- syntactic_sugar
# Trailing commas in arrays and dictionaries should be avoided/enforced.
- trailing_comma
# 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
# Type name should only contain alphanumeric characters, start with an uppercase character, and span between 3 and 50 characters in length.
- type_name
# Avoid using unneeded break statements.
- unneeded_break_in_switch
# Unused parameter in a closure should be replaced with _.
- unused_closure_parameter
# When the index or the item is not used, .enumerated() can be removed.
- unused_enumerated
# Prefer != nil over let _ =.
- unused_optional_binding
# Function parameters should be aligned vertically if they're in multiple lines in a declaration.
- vertical_parameter_alignment
# Limit vertical whitespace to a single empty line.
- vertical_whitespace
# Prefer -> Void over -> ().
- void_return
# Delegates should be weak to avoid reference cycles.
- weak_delegate
included: # paths to include during linting. `--path` is ignored if present.
- ${LINTPATH}
- Demos
- Sources
- Tests
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Pods
- tools
explicit_type_interface: # requires type annotation on everything but local variables and constants
excluded:
- local
allow_redundancy: true # Ignores rule if it would result in redundancy
file_header:
required_pattern: |
\/\/
\/\/ Copyright \(c\) Microsoft Corporation\. All rights reserved\.
\/\/ Licensed under the MIT License\.
\/\/
identifier_name:
min_length: 1
max_length: 60
modifier_order:
preferred_modifier_order:
- acl
- setterACL
- override
- typeMethods
type_name:
min_length: 3
max_length: 50