Files
SwiftLint/Source/SwiftLintFramework/Rules/RuleConfigurations/ObjectLiteralConfiguration.swift
T
JP SimardandGitHub 4bd7da32ea Reduce visibility of rules to be internal (#4533)
There's no reason to expose these publicly and this will make it nicer
to move to a new module outside of the core SwiftLint functionality.
2022-11-09 11:01:26 -05:00

25 lines
939 B
Swift

struct ObjectLiteralConfiguration: SeverityBasedRuleConfiguration, Equatable {
private(set) var severityConfiguration = SeverityConfiguration(.warning)
private(set) var imageLiteral = true
private(set) var colorLiteral = true
var consoleDescription: String {
return severityConfiguration.consoleDescription
+ ", image_literal: \(imageLiteral)"
+ ", color_literal: \(colorLiteral)"
}
mutating func apply(configuration: Any) throws {
guard let configuration = configuration as? [String: Any] else {
throw ConfigurationError.unknownConfiguration
}
imageLiteral = configuration["image_literal"] as? Bool ?? true
colorLiteral = configuration["color_literal"] as? Bool ?? true
if let severityString = configuration["severity"] as? String {
try severityConfiguration.apply(configuration: severityString)
}
}
}