mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
23 lines
800 B
Swift
23 lines
800 B
Swift
import SwiftLintCore
|
|
|
|
struct TrailingCommaConfiguration: SeverityBasedRuleConfiguration, Equatable {
|
|
typealias Parent = TrailingCommaRule
|
|
|
|
@ConfigurationElement
|
|
private(set) var severityConfiguration = SeverityConfiguration<Parent>(.warning)
|
|
@ConfigurationElement(key: "mandatory_comma")
|
|
private(set) var mandatoryComma = false
|
|
|
|
mutating func apply(configuration: Any) throws {
|
|
guard let configuration = configuration as? [String: Any] else {
|
|
throw Issue.unknownConfiguration(ruleID: Parent.identifier)
|
|
}
|
|
|
|
mandatoryComma = (configuration["mandatory_comma"] as? Bool == true)
|
|
|
|
if let severityString = configuration["severity"] as? String {
|
|
try severityConfiguration.apply(configuration: severityString)
|
|
}
|
|
}
|
|
}
|