-
Notifications
You must be signed in to change notification settings - Fork 11
/
swiftlint.yml
179 lines (159 loc) · 4.88 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
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Pods
disabled_rules: # rule identifiers to exclude from running
- type_name
- nesting
- missing_docs
- function_parameter_count
- large_tuple
- legacy_constant
- shorthand_operator
- line_length
- file_length
- identifier_name
- cyclomatic_complexity
- todo # disable for pre-release development
- closure_parameter_position
- multiple_closures_with_trailing_closure
- block_based_kvo
- class_delegate_protocol
#temporarily
- operator_usage_whitespace
- force_cast
- force_try
opt_in_rules:
- closure_end_indentation
- closure_spacing
- first_where
# - force_unwrapping
- empty_count
- mark
# - force_cast
# - force_try
# - operator_usage_whitespace
# - private_outlet
closing_brace: error
closure_end_indentation: error
closure_spacing: error
comma: error
# colon:
# severity: error
control_statement: error
empty_count: error
empty_parameters: error
empty_parentheses_with_trailing_closure: error
first_where: error
force_cast: error
force_try: error
force_unwrapping: error
implicit_getter: error
leading_whitespace: error
legacy_cggeometry_functions: error
legacy_constant: error
legacy_constructor: error
mark: error
opening_brace: error
operator_usage_whitespace: error
operator_whitespace: error
redundant_string_enum_value: error
return_arrow_whitespace: error
statement_position:
statement_mode: default
severity: error
syntactic_sugar: error
trailing_comma:
severity: error
trailing_newline: error
trailing_semicolon: error
trailing_whitespace:
ignores_empty_lines: true
severity: error
unused_closure_parameter: error
unused_enumerated: error
vertical_whitespace: error
void_return: error
cyclomatic_complexity:
warning: 10
todo: warning
private_outlet:
allow_private_set: true
severity: warning
trailing_comma:
severity: warning
type_name:
min_length:
warning: 2
identifier_name:
min_length:
warning: 1
line_length:
warning: 300
function_body_length:
warning: 200
type_body_length:
warning: 1000
file_length:
warning: 2000
custom_rules:
nslog_check:
regex: 'NSLog\('
message: "Use log instead"
severity: error
print_check:
regex: 'print\('
message: "Use log instead"
severity: error
# bounds_protection:
# regex: '[A-Z0-9a-z]+\[[A-Z0-9a-z]+\]'
# message: "Use [safe: index] instead"
# severity: warning
# first_element_access:
# regex: '\[0\]'
# message: "Use array.first instead of array[0]"
# severity: warning
# assert_protection:
# excluded: ".*Tests.swift" # regex that defines paths to exclude during linting. optional
# regex: '((assert\()|(assertionFailure\()|(precondition\()|(preconditionFailure\())'
# message: "Use Utility.assertOrAlert instead"
# severity: error
excessive_void_identifier:
regex: '\(\)[\s]*->[\s]*\(\) in' # matching pattern
message: "no need to write out \"() -> () in\""
severity: error
opacity_with_variable:
regex: 'opacity\([\D]'
message: "should always use opacity() with a literal constant number, ex. opacity(0.7)"
severity: error
localizable_strings:
regex: 'NSLocalizedString\(\"'
message: "use localize(L10n enum) instead of hardcoded strings, ex. localize(.Error)"
severity: warning
# todo_formatting:
# regex: '((\/\/TODO)|(\/\/\sTODO[^:])|(\/\/\sTODO:[^\s]))'
# message: "TODO should be formatted as '// TODO: <comment> to work properly and be consistent"
# severity: error
# excessive_import:
# regex: 'import (Foundation|UIKit)'
# message: "Foundation and UIKit has been imported for the entire project, please remove excessive import statements"
# severity: error
internal_access_modifier:
included: '.*.swift'
regex: "internal ((static|override) )?(class |let |var |func )"
message: "Internal is a default access modifier and can be omitted"
severity: error
unused_placeholder_parameters:
regex: '\((_,\s*)*_\)'
message: "use \"_\" in place of (_), (_, _), etc."
severity: error
swift_3_error:
regex: 'caseInsensitiveCompare|NSIndexPath|Foundation\.|UIControlState\(\)|\!\!|JASON\.JSON|NSMutableURLRequest|as\sURL|NSNotification|as\sNotification|localize\(\.[A-Z]|AtIndex|NSURL|NSURLRequest'
message: "use new Swift 3 syntax"
severity: error
# swift_3_warning:
# regex: 'NSDate|NSError|NSData'
# message: "please confirm if legacy type actually needed, especially in delegate methods, the signature might have changed"
# severity: warning
# settings_nsuserdefaults:
# regex: 'UserDefaults\.'
# message: "please confirm if using UserDefaults is needed, Settings should be used instead"
# severity: error