nicklockwood / SwiftFormat

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

Alphabetically sort organized declarations by name pattern #1720

Closed oiuhr closed 3 weeks ago

oiuhr commented 3 weeks ago

Added an ability to sort declarations alphabetically within organizeDeclaration by their name pattern instead of // swiftformat:sort marks.

Motivation: in our project we have 1000+ enums named Constants with static properties which we wanted to see sorted alphabetically — and marking all of them with sorting comments is a bit tedious, if not straight up rude 🥹

New option sortedpatterns can (and should?) be shared with existing sortDeclaration rule.

nicklockwood commented 3 weeks ago

@oiuhr oops, sorry - I tried to fix the conflicts in your PR after rebasing develop and somehow borked the PR so it got closed. I've landed your feature on the develop branch so it doesn't get lost - if you were planning on making any further changes please open a new PR.