-
Notifications
You must be signed in to change notification settings - Fork 0
/
.swiftlint.yml
121 lines (105 loc) · 8.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
# All rules: https://github.com/realm/SwiftLint/blob/master/Rules.md#mark
disabled_rules: # rule identifiers to exclude from running
- shorthand_operator # Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning
- trailing_whitespace
- file_header
- trailing_newline
- discarded_notification_center_observer # Not needed since iOS 9. See https://developer.apple.com/documentation/foundation/notificationcenter/1413994-removeobserver
- trailing_closure
opt_in_rules: # some rules are only opt-in
- empty_count # Prefer checking isEmpty over comparing count to zero
- private_outlet # IBOutlets should be private to avoid leaking UIKit to higher layers.
- file_header
- modifier_order # Modifier order should be consistent.
- multiline_arguments # Arguments should be either on the same line, or one per line.
- number_separator # Underscores should be used as thousand separator in large decimal numbers
- operator_usage_whitespace # Operators should be surrounded by a single whitespace when they are being used.
- operator_whitespace # Operators should be surrounded by a single whitespace when defining them.
- prohibited_super_call # Some methods should not call super
- overridden_super_call # Some overridden methods should always call super
- vertical_parameter_alignment_on_call # Function parameters should be aligned vertically if they're in multiple lines in a method call.
- array_init # Prefer using Array(seq) over seq.map { $0 } to convert a sequence into an Array.
- attributes # Attributes should be on their own lines in functions and types, but on the same line as variables and imports.
- closure_end_indentation # Closure end should have the same indentation as the line that started it.
- closure_spacing # Closure expressions should have a single space inside each brace.
- contains_over_first_not_nil # Prefer contains over first(where:) != nil
- empty_string # Prefer checking isEmpty over comparing string to an empty string literal.
- explicit_init # Explicitly calling .init() should be avoided.
- extension_access_modifier # Prefer to use extension access modifiers
- fallthrough # Fallthrough should be avoided.
- fatal_error_message # A fatalError call should have a message.
- first_where # Prefer using .first(where:) over .filter { }.first in collections.
- force_unwrapping # Force unwrapping should be avoided.
- function_default_parameter_at_end # Prefer to locate parameters with defaults toward the end of the parameter list.
- implicit_return # Prefer implicit returns in closures.
- implicitly_unwrapped_optional # Implicitly unwrapped optionals should be avoided when possible.
- joined_default_parameter # Discouraged explicit usage of the default separator.
- literal_expression_end_indentation # Array and dictionary literal end should have the same indentation as the line that started it.
- lower_acl_than_parent # Ensure definitions have a lower access control level than their enclosing parent
- multiline_function_chains # Chained function calls should be either on the same line, or one per line.
- multiline_parameters # Functions and methods parameters should be either on the same line, or one per line.
- pattern_matching_keywords # Combine multiple pattern matching bindings by moving keywords out of tuples.
- prefixed_toplevel_constant # Top-level constants should be prefixed by k
- private_action # IBActions should be private.
- redundant_nil_coalescing # nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant
- sorted_first_last # Prefer using min() or max() over sorted().first or sorted().last
- unavailable_function # Unimplemented functions should be marked as unavailable.
- unneeded_parentheses_in_closure_argument # Parentheses are not needed when declaring closure arguments.
- yoda_condition # The variable should be placed on the left, the constant on the right of a comparison operator.
- nimble_operator # Prefer Nimble operator overloads over free matcher functions.
- quick_discouraged_call # Discouraged call inside 'describe' and/or 'context' block.
- quick_discouraged_focused_test # Discouraged focused test. Other tests won't run while this one is focused.
- quick_discouraged_pending_test # Discouraged pending test. This test won't run while it's marked as pending.
- required_enum_case # Enums conforming to a specified protocol must implement a specific case(s).
- single_test_class # Test files should contain a single QuickSpec or XCTestCase class.
- vertical_whitespace_closing_braces # When closing braces there should be no vertical space between the last line of code and the closing brace
- unused_private_declaration # Private declarations should be referenced in that file.
- unused_import # All imported modules should be required to make the file compile.
- toggle_bool # Prefer someBool.toggle() over someBool = !someBool.
- static_operator # Operators should be declared as static functions, not free functions.
- redundant_type_annotation # Variables should not have redundant type annotation
- object_literal # Prefer object literals over image and color inits.
- multiline_literal_brackets # Multiline literals should have their surrounding brackets in a new line.
- legacy_random # Prefer using type.random(in:) over legacy functions.
- last_where # Prefer using .last(where:) over .filter { }.last in collections.
- identical_operands # Comparing two identical operands is likely a mistake.
- convenience_type # Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation.
- collection_alignment # All elements in a collection literal should be vertically aligned
- closure_body_length # Closure bodies should not span too many lines.
- anyobject_protocol # Prefer using AnyObject over class for class-only protocols.
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Package.swift
- .build/
# configurable rules can be customized from this configuration file
line_length:
warning: 140
ignores_comments: true
nesting:
type_level: 2
vertical_whitespace:
max_empty_lines: 1
force_cast: error
force_try: error
force_unwrapping: error
file_length:
warning: 600
ignore_comment_only_lines: true
function_body_length: 40
function_parameter_count:
warning: 6
type_body_length: 600
identifier_name:
min_length: # only min_length
warning: 3 # only error
excluded: # excluded via string array
- id
type_name:
min_length: 1
max_length: 50
private_outlet:
allow_private_set: true
custom_rules:
more_than_one_variable_declaration:
regex: '^\s*(let|var|case)\s+\w+,[ ]*\w+'
message: "Don't put more than one declaration in the same line."
severity: error