forked from swiyu-admin-ch/eidch-ios-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.swiftlint.yml
More file actions
167 lines (145 loc) · 5.17 KB
/
.swiftlint.yml
File metadata and controls
167 lines (145 loc) · 5.17 KB
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
only_rules:
- closure_spacing
- colon
- comment_spacing
- closure_parameter_position
- custom_rules
- empty_enum_arguments
- explicit_init
- fatal_error_message
- force_cast
- force_try
- force_unwrapping
- implicitly_unwrapped_optional
- legacy_cggeometry_functions
- legacy_constant
- legacy_constructor
- legacy_nsgeometry_functions
- operator_usage_whitespace
- overriden_super_call
- redundant_string_enum_value
- redundant_void_return
- return_arrow_whitespace
- superfluous_else
- trailing_newline
- type_name
- unused_closure_parameter
- unused_optional_binding
- vertical_whitespace
- void_return
- weak_delegate
- yoda_condition
excluded:
- Carthage
- Pods
- Packages
- .build
- Modules/**/.build
- vendor # Remove some CI checks
colon:
apply_to_dictionaries: false
indentation: 2
type_name:
max_length:
warning: 90
error: 100
min_length:
warning: 3
custom_rules:
### Clean Architecture enforcements
viewmodel_in_presentation_folder:
name: "ViewModels must be in Presentation folder"
included: ".*/.*ViewModel\\.swift$"
excluded: ".*/Presentation/.*ViewModel\\.swift$"
regex: ".*"
message: "ViewModel files should be located in the Presentation directory or its subdirectories"
severity: error
repository_protocol_in_domain_folder:
name: "Repository protocol must be in Domain folder"
included: ".*RepositoryProtocol\\.swift$"
excluded: ".*/Domain/.*RepositoryProtocol\\.swift$"
regex: ".*"
message: "Repository protocols must be declared in the Domain layer"
severity: error
usecase_in_domain_folder:
name: "A UseCase must be in Domain folder"
included: ".*UseCase\\.swift$"
excluded: "(.*/Domain/.*UseCase\\.swift$|.*/swiyuUITests-App)"
regex: ".*"
message: "UseCase implementations must be located in the Domain layer"
severity: error
service_in_domain_folder:
name: "A Service must be in Domain folder"
included: ".*Service\\.swift$"
excluded: "(.*/Domain/.*Service\\.swift$|.*/Services|.*/BITNetworking|.*/swiyuUITests-App)"
regex: ".*"
message: "Service implementations must be declared in the Domain layer"
severity: error
views_must_not_reference_usecases:
name: "Views must not reference UseCases"
included: ".*View\\.swift$"
regex: '\\b(let|var)\\b[^\\n]*?(?i:usecase)'
message: "Views must not hold references to UseCases"
severity: error
views_must_not_reference_repositories:
name: "Views must not reference Repositories"
included: ".*View\\.swift$"
regex: '\\b(let|var)\\b[^\\n]*?(?i:repository)'
message: "Views must not hold references to Repositories"
severity: error
viewmodels_must_not_reference_repository:
included: ".*ViewModel\\.swift"
name: "ViewModels must not reference repositories"
regex: '\b(let|var)\b[^\n]*?(?i:repository)'
message: "ViewModels must not hold references to repositories"
severity: error
usecases_must_not_reference_viewmodels:
included: ".*UseCase\\.swift"
name: "UseCases must not reference ViewModels"
regex: '\b(let|var)\b[^\n]*?(?i:viewmodel)'
message: "UseCases must not hold references to ViewModels"
severity: error
### Modules (SPM)
module_platform_dependencies:
name: "Module Platform cannot contain feature dependencies"
included: ".*/Platforms/.*/Package\\.swift$"
regex: ".*/Features/"
message: "Platform modules must not import feature modules"
severity: error
swift_tool_version_in_spm:
name: "SPM Swift version must be aligned to project requirements"
included: ".*Package\\.swift$"
regex: "swift-tools-version: (?!5\\.10)"
message: "SPM Swift version must be aligned to project requirements"
match_kinds:
- comment
severity: error
### Miscellaneous
init_with_name:
name: "Init with full object name"
message: "Prefer let object = Class() instead of let object: Class = .init()"
included: ".*.swift"
regex: '(?<!self|super)\.init\('
match_kinds:
- identifier
- keyword
severity: warning
no_objcMembers:
name: "@objcMembers"
regex: "@objcMembers"
message: "Explicitly use @objc on each member you want to expose to Objective-C"
severity: error
no_direct_standard_out_logs:
name: "Writing log messages directly to standard out is disallowed"
regex: "(\\bprint|\\bdebugPrint|\\bdump|Swift\\.print|Swift\\.debugPrint|Swift\\.dump)\\s*\\("
match_kinds:
- identifier
message: "Don't commit `print(…)`, `debugPrint(…)`, or `dump(…)` as they write to standard out in release. Either log to a dedicated logging system or silence this warning in debug-only scenarios explicitly using `// swiftlint:disable:next no_direct_standard_out_logs`"
severity: warning
# avoid_service_locator_usage:
# name: "Avoid Service Locator (Container.shared)"
# included: ".*\\.swift"
# excluded: "(.*Container\\.swift$|.*Tests\\.swift$|AppDelegate.*\\.swift$|.*View\\.swift$|.*Module\\.swift$)"
# regex: "Container\\.shared\\."
# message: "Avoid using the Service Locator pattern (Container.shared). Prefer explicit dependency injection instead."
# severity: warning