Feature request: lexicographic sorting options for `sorted_imports`
Open
Nobody has claimed this yet.
enhancement
good first issue
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Describe the bug
import AppTypes
import AVFoundation
import Base
import Logging
Will pass sorted_imports, but swift-format's equivalent of this rule wants lexicographic sorting, and expects
import AppTypes
import Base
import Logging
import AVFoundation
It would be nice if SwiftLint offered a configuration option that preferred a sort order compatible with swift-format
Complete output when running SwiftLint, including the stack trace and command used
N/A
Environment
- SwiftLint version (run
swiftlint versionto be sure)? 0.50.3 - Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
- Paste your configuration file:
none
- Are you using nested configurations?
If so, paste their relative paths and respective contents.
no
- Which Xcode version are you using (check
xcodebuild -version)?
Xcode 14.2
Build version 14C18
- Do you have a sample that shows the issue? Run
echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
to quickly test if your example is really demonstrating the issue. If your example is more
complex, you can useswiftlint lint --path [file here] --no-cache --enable-all-rules.
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the sorted_imports rule and reviewing how its current import ordering differs from swift-format. Use the provided import examples and the swiftlint lint --no-cache --use-stdin --enable-all-rules command to verify the configured ordering behavior; done means an option can produce the requested lexicographic order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100