diff --git a/Source/SwiftLintFramework/Rules/Lint/UnusedImportRule.swift b/Source/SwiftLintFramework/Rules/Lint/UnusedImportRule.swift index 17a8614ca5..dbe429bb84 100644 --- a/Source/SwiftLintFramework/Rules/Lint/UnusedImportRule.swift +++ b/Source/SwiftLintFramework/Rules/Lint/UnusedImportRule.swift @@ -183,7 +183,7 @@ private extension SwiftLintFile { func rangedAndSortedUnusedImports(of unusedImports: [String], contents: NSString) -> [(String, NSRange)] { return unusedImports .compactMap { module in - match(pattern: "^(@[\\w_]+ +)?import +\(module)\\b.*?\n").first.map { (module, $0.0) } + match(pattern: "^(@\\w+ +)?import +\(module)\\b.*?\n").first.map { (module, $0.0) } } .sorted(by: { $0.1.location < $1.1.location }) } diff --git a/Tests/SwiftLintFrameworkTests/LinterCacheTests.swift b/Tests/SwiftLintFrameworkTests/LinterCacheTests.swift index 5c487e201a..0d5e875e50 100644 --- a/Tests/SwiftLintFrameworkTests/LinterCacheTests.swift +++ b/Tests/SwiftLintFrameworkTests/LinterCacheTests.swift @@ -303,6 +303,8 @@ class LinterCacheTests: XCTestCase { func testDetectSwiftVersion() { #if compiler(>=5.2.0) let version = "5.2.0" + #elseif compiler(>=5.1.5) + let version = "5.1.5" #elseif compiler(>=5.1.4) let version = "5.1.4" #elseif compiler(>=5.1.3)