mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
82cad0bfff
This allows to infer names of options from their names in a configuration. CamelCase is translated into snake_case automatically when `apply` is triggered. * Don't have all `RuleConfiguration`s conform to `InlinableOptionType`. Mark types that must have this capability explicitly. Same for `AcceptableByConfigurationElement`. * A type being an `InlinableOptionType` doesn't mean it's automatically inlined. This also doesn't depend on the fact of having a name for its key configured any longer. Instead, an `inline` attribute must explicitly be set to `true` in `@ConfigurationElement`. * Key name inference is optional and can be overwritten by specifying a key name in the attribute. * Inlined configurations only fail in `apply` when they are really sure that something is odd. Otherwise, they accept to not being updated.
24 lines
876 B
Swift
24 lines
876 B
Swift
import SwiftLintCore
|
|
|
|
@AutoApply
|
|
struct LineLengthConfiguration: RuleConfiguration {
|
|
typealias Parent = LineLengthRule
|
|
|
|
@ConfigurationElement(inline: true)
|
|
private(set) var length = SeverityLevelsConfiguration<Parent>(warning: 120, error: 200)
|
|
@ConfigurationElement(key: "ignores_urls")
|
|
private(set) var ignoresURLs = false
|
|
@ConfigurationElement(key: "ignores_function_declarations")
|
|
private(set) var ignoresFunctionDeclarations = false
|
|
@ConfigurationElement(key: "ignores_comments")
|
|
private(set) var ignoresComments = false
|
|
@ConfigurationElement(key: "ignores_interpolated_strings")
|
|
private(set) var ignoresInterpolatedStrings = false
|
|
@ConfigurationElement(key: "excluded_lines_patterns")
|
|
private(set) var excludedLinesPatterns: Set<String> = []
|
|
|
|
var params: [RuleParameter<Int>] {
|
|
return length.params
|
|
}
|
|
}
|