nicklockwood / SwiftFormat

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

Is there any way to order // MARK: Internal BEFORE // MARK: Lifecycle? #1381

Open thepost opened 1 year ago

thepost commented 1 year ago

Apologies if this is obvious. I can't for the life of me figure this out. Until then I've had to disable the organizeDeclarations rule, as I don't want the init function to be the first thing you see in a class or struct.

nicklockwood commented 1 year ago

Cc @calda

calda commented 1 year ago

This isn't currently possible, but would be reasonably straightforward to add support for. For example, we could add a --typeordering option where the default is lifecycle,open,public,internal,fileprivate,private and then allow consumers to customize the order.

I'd be curious to hear where exactly you'd like to order the lifecycle declarations, though. I personally don't really see the appeal of an ordering like open,public,internal,lifecycle,fileprivate,private, although I do see the appeal of removing the lifecycle category completely in favor of just placing inits in the corresponding ACL group.