mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Use SourceKit to validate associatedtype and typealias in type_name rule when linting with Swift 4.1
Part of #2021
This commit is contained in:
@@ -36,6 +36,11 @@
|
||||
[Marcelo Fabri](https://github.com/marcelofabri)
|
||||
[#2021](https://github.com/realm/SwiftLint/issues/2021)
|
||||
|
||||
* Use SourceKit to validate `associatedtype` and `typealias` in `type_name` rule
|
||||
when linting with Swift 4.1.
|
||||
[Marcelo Fabri](https://github.com/marcelofabri)
|
||||
[#2021](https://github.com/realm/SwiftLint/issues/2021)
|
||||
|
||||
## 0.24.2: Dented Tumbler
|
||||
|
||||
#### Breaking
|
||||
|
||||
@@ -39,6 +39,7 @@ extension SwiftDeclarationKind {
|
||||
.`class`,
|
||||
.`struct`,
|
||||
.`typealias`,
|
||||
.`associatedtype`,
|
||||
.`enum`
|
||||
]
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@ public struct TypeNameRule: ASTRule, ConfigurationProviderRule {
|
||||
}
|
||||
|
||||
private func validateTypeAliasesAndAssociatedTypes(in file: File) -> [StyleViolation] {
|
||||
guard SwiftVersion.current < .fourDotOne else {
|
||||
return []
|
||||
}
|
||||
|
||||
let rangesAndTokens = file.rangesAndTokens(matching: "(typealias|associatedtype)\\s+.+?\\b")
|
||||
return rangesAndTokens.flatMap { _, tokens -> [StyleViolation] in
|
||||
guard tokens.count == 2,
|
||||
|
||||
Reference in New Issue
Block a user