-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy path.swiftlint.yml
More file actions
114 lines (102 loc) · 2.95 KB
/
Copy path.swiftlint.yml
File metadata and controls
114 lines (102 loc) · 2.95 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
# SwiftLint configuration for SwiftStreamingMarkdown.
# Adapted from the upstream microsoft/app-ios .swiftlint.yml; rules that
# depend on app-ios-only types (ViewModelWithModals, presentationCornerRadiusIfAvailable,
# ImageResource code-generation) are intentionally omitted here.
disabled_rules:
- todo
- line_length
- nesting
- cyclomatic_complexity
- non_optional_string_data_conversion
- type_body_length
- blanket_disable_command
- superfluous_disable_command
opt_in_rules:
- empty_count
- force_unwrapping
- force_try
- file_header
file_header:
required_pattern: |
\/\/
\/\/ Copyright \(c\) Microsoft Corporation\. All rights reserved\.
\/\/ Licensed under the MIT License\. See LICENSE in the project root for license information\.
\/\/
analyzer_rules:
- explicit_self
included:
- Sources
- Tests
- Examples
excluded:
- "**/.build/**"
- "**/.swiftpm/**"
- "**/Generated/**"
- "**/*.xcassets"
- "**/*.bundle"
allow_zero_lintable_files: false
strict: true
force_cast:
severity: error
force_try:
severity: error
function_body_length: 200
file_length:
- 900 # error
type_name:
min_length: 3 # error
max_length: 50 # error
excluded: iPhone
allowed_symbols: ["_"]
identifier_name:
min_length: 1 # error
reporter: emoji
force_unwrapping: error
function_parameter_count:
warning: 8
error: 8
custom_rules:
no_any:
name: "Disallow Any"
regex: "\\bAny(?!])\\b"
message: "freestanding 'Any' is not allowed, please use as? (optional downcasting) to an explicit type"
severity: error
no_empty_else:
name: "No Empty Else"
regex: 'else\s*\{\s*\}'
message: "Empty else block is not allowed, please handle the else case or remove the else block"
severity: error
no_anyview:
name: "No AnyView"
regex: "\\bAnyView(?!])\\b"
excluded:
- ".*Previews\\.swift"
- ".*Test\\.swift"
- ".*Tests\\.swift"
message: "Use of AnyView is discouraged. Here's a good explanatory article on it: https://www.swiftbysundell.com/articles/avoiding-anyview-in-swiftui/"
severity: error
no_print:
name: "No print"
regex: "\\bprint(?!])\\b"
excluded:
- ".*View\\.swift"
- ".*Previews\\.swift"
- ".*Mocks\\.swift"
- ".*Mock\\.swift"
- ".*Mock.*\\.swift"
- ".*Test\\.swift"
- ".*Tests\\.swift"
- ".*Listener\\.swift"
message: "Prefer logDebug() over print() to obtain structured messages sent to Apple's unified logging system. Mocks, Preview and Tests are not subject to this rule."
severity: error
no_thread_sleep_in_tests:
included: ".*Tests.swift"
name: "No Thread.sleep"
regex: "\\b(Thread|Foundation\\.Thread)\\s*\\.\\s*sleep\\s*\\("
message: "Avoid using Thread.sleep in tests."
severity: error
no_swiftuicore_import:
name: "No SwiftUICore Import"
regex: 'import SwiftUICore'
message: "Importing SwiftUICore is not allowed. Please use SwiftUI instead."
severity: error