nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.67k stars 623 forks source link

add `length then alpha` option to `--sortImports` #1598

Open Saafo opened 7 months ago

Saafo commented 7 months ago

Add length then alpha option to sort imports with the same length in alphabets.

Saafo commented 7 months ago

Seems the related codes are at here: https://github.com/nicklockwood/SwiftFormat/blob/ad7707bd34a33fa64a2c593c53deaa7d7469e2f0/Sources/Rules.swift#L4494

I'd like to open a pr for this feature, if you wish. But I think the @testable import grouping rules need to be refactored too.

My propose is that sortImports's option import grouping should only contains alpha / length / length then alpha, we should add another option testable option, which contains none / testable fist / testable last, then the two options can work simultaneously.