Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lowercase imports before sorting #1218

Merged
merged 1 commit into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
[Marcelo Fabri](https://github.com/marcelofabri)
[#663](https://github.com/realm/SwiftLint/issues/663)

* Fix `sorted_imports` rule to sort ignoring case.
[Keith Smiley](https://github.com/keith)
[#1185](https://github.com/realm/SwiftLint/issues/1185)

##### Enhancements

* Performance improvements to `generic_type_name`,
Expand Down
6 changes: 4 additions & 2 deletions Source/SwiftLintFramework/Rules/SortedImportsRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public struct SortedImportsRule: ConfigurationProviderRule, OptInRule {
name: "Sorted Imports",
description: "Imports should be sorted.",
nonTriggeringExamples: [
"import AAA\nimport BBB\nimport CCC\nimport DDD"
"import AAA\nimport BBB\nimport CCC\nimport DDD",
"import Alamofire\nimport API",
"import labc\nimport Ldef"
],
triggeringExamples: [
"import AAA\nimport ZZZ\nimport ↓BBB\nimport CCC"
Expand All @@ -35,7 +37,7 @@ public struct SortedImportsRule: ConfigurationProviderRule, OptInRule {
let moduleRange = NSRange(location: range.location + importLength,
length: range.length - importLength)
let moduleName = contents.substring(with: moduleRange)
.trimmingCharacters(in: .whitespacesAndNewlines)
.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
let offset = NSMaxRange(range) - moduleName.bridge().length
return (moduleName, offset)
}
Expand Down