-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy path.swiftlint.yml
More file actions
132 lines (116 loc) · 4.77 KB
/
Copy path.swiftlint.yml
File metadata and controls
132 lines (116 loc) · 4.77 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
excluded:
- Carthage
- Examples
- Tests/InstallationTests
- Tests/TestingApps
- Tests/APITesters
- Tuist
- vendor
- scan_derived_data
- .git
- build
- "**/DerivedSources/GeneratedAssetSymbols.swift"
- .build
- ./**/Project.swift
# Baseline of pre-existing violations. New violations are not allowed.
# To accept an intentional new violation, regenerate the baseline:
# swiftlint lint --write-baseline swiftlint-baseline.json
baseline: swiftlint-baseline.json
opt_in_rules:
- force_unwrapping
- sorted_imports
- missing_docs
- convenience_type
- multiline_parameters
- vertical_parameter_alignment
- vertical_parameter_alignment_on_call
- explicit_init
disabled_rules:
- orphaned_doc_comment
- blanket_disable_command
# Broken: https://github.com/realm/SwiftLint/issues/5153
- unneeded_synthesized_initializer
- non_optional_string_data_conversion
- static_over_final_class
custom_rules:
xctestcase_superclass:
included: ".*\\.swift"
excluded:
- Tests/ReceiptParserTests
- Tests/UnitTests/RulesEngine
- Tests/v3LoadShedderIntegration
- Tests/v4LoadShedderIntegration
- Tests/PurchasesUIServiceIntegrationTests
regex: "\\: XCTestCase \\{"
name: "XCTestCase Superclass"
message: "Test classes must inherit `TestCase` instead."
return_switch_forbidden:
included: ".*\\.swift"
name: "Forbidden 'return switch' usage"
regex: '\breturn\s+switch\b'
message: "Inline 'return switch' is not allowed."
severity: error
no_preview_macro:
name: "No Preview Macro"
regex: "#Preview"
message: "The '#Preview' macro will not compile in the CI pipeline during deployment, use a PreviewProvider instead."
severity: error
no_assignments_from_switch:
name: "No Assignments from Switch Statements"
regex: " = switch "
message: "In older versions of xcode build tools, this is not supported and will fail in CI"
severity: error
no_direct_state_assignment_in_init:
included: ".*\\.swift"
name: "No direct @State assignment in init"
regex: '(?s)@State(?:\s*\([^)]*\))?\s+(?:private\s+)?var\s+([A-Za-z_][A-Za-z0-9_]*)\b(?:[^{}]|\{[^{}]*\})*?init\s*\([^{}]*\)\s*\{(?:[^{}]|\{[^{}]*\})*?\bself\.\1\s*='
message: "Initialize @State in init using backing storage: self._property = .init(initialValue: ...)"
severity: error
no_direct_state_assignment_in_init_reverse_order:
included: ".*\\.swift"
name: "No direct @State assignment in init (reverse order)"
regex: '(?s)init\s*\([^{}]*\)\s*\{(?:[^{}]|\{[^{}]*\})*?\bself\.([A-Za-z_][A-Za-z0-9_]*)\s*=(?:[^{}]|\{[^{}]*\})*?\}(?:[^{}]|\{[^{}]*\})*?@State(?:\s*\([^)]*\))?\s+(?:private\s+)?var\s+\1\b'
message: "Initialize @State in init using backing storage: self._property = .init(initialValue: ...)"
severity: error
no_trailing_comma_multiline:
name: "No Trailing Commas"
regex: ',\s*\n\s*\)'
message: "Trailing commas are not allowed"
severity: error
avoid_using_directory_apis_directly:
name: "Avoid Using Directory APIs Directly"
regex: '\b(URL\.(cachesDirectory|applicationDirectory|libraryDirectory|userDirectory|documentsDirectory|desktopDirectory|applicationSupportDirectory|downloadsDirectory|moviesDirectory|musicDirectory|picturesDirectory|sharedPublicDirectory|trashDirectory|homeDirectory|temporaryDirectory)|URL\.(currentDirectory\(\)|homeDirectory\(forUser:)|FileManager\.default\.(urls?)\s*\(|(?<!FileManager\.)(?!default\.)[a-zA-Z_][a-zA-Z0-9_]*\.(urls?)\s*\(\s*for\s*:\s*\.)'
match_kinds:
- identifier
- keyword
message: "Use DirectoryHelper.baseUrl(for:) instead of FileManager or URL directory APIs."
severity: error
excluded:
- Sources/Caching/DirectoryHelper.swift
- Tests/
no_bundle_module:
included: "RevenueCatUI/.*\\.swift"
excluded:
- RevenueCatUI/Helpers/Bundle\+Extensions.swift
name: "No Bundle.module"
regex: '(Bundle\.module|bundle:\s*\.module)'
message: "Use Bundle.revenueCatUI instead of Bundle.module for Compose Resources compatibility"
severity: error
no_new_public_enums:
name: "No new public enums in consumer-facing APIs"
message: "Adding a new `public enum` to the SDK's consumer-facing surface (including `@_spi(Experimental)`) is not allowed. Adding a case to an existing `public enum` is a source-breaking change for any consumer with an exhaustive `switch`. Use a struct with static constants instead."
severity: error
included:
- "Sources/.*\\.swift"
- "RevenueCatUI/.*\\.swift"
- "AdapterSDKs/RevenueCatAdMob/Sources/.*\\.swift"
regex: '(?s)(?<!@_spi\(Internal\)\s)\bpublic\s+(?:indirect\s+)?enum\s+[A-Z]'
identifier_name:
max_length:
warning: 60
error: 80
large_tuple:
warning: 4
error: 5
missing_docs:
excludes_inherited_types: false