Skip to content

Conversation

@calda
Copy link
Member

@calda calda commented Jul 22, 2024

As of nicklockwood/SwiftFormat#1736, the organizeDeclarations rule is now fully configurable, and lets you specify the sort order of declarations. The default behavior of the organizeDeclarations is now different from the behavior defined in our style guide. To keep the behavior we want, we can provide our own configuration explicitly.

The corresponding configuration that matches our style guide is:

--visibilityorder beforeMarks,instanceLifecycle,open,public,package,internal,fileprivate,private # organizeDeclarations
--typeorder nestedType,staticProperty,staticPropertyWithBody,classPropertyWithBody,instanceProperty,instancePropertyWithBody,staticMethod,classMethod,instanceMethod # organizeDeclarations

Copy link
Contributor

@mannylopez mannylopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for keeping this up to date.

@calda calda merged commit c2b4614 into master Jul 22, 2024
@calda calda deleted the cal--udpate-organizeDeclarations-options branch July 22, 2024 17:54
Copy link
Contributor

@bachand bachand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @calda !

--enumthreshold 20 # organizeDeclarations
--organizetypes class,struct,enum,extension,actor # organizeDeclarations
--visibilityorder beforeMarks,instanceLifecycle,open,public,package,internal,fileprivate,private # organizeDeclarations
--typeorder nestedType,staticProperty,staticPropertyWithBody,classPropertyWithBody,instanceProperty,instancePropertyWithBody,staticMethod,classMethod,instanceMethod # organizeDeclarations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calda is it expected that there is no classProperty?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no such thing as a stored class property (aka a class property without a body)! Found this out when I was first working on the organizeDeclarations rule: https://forums.swift.org/t/class-properties/16539

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Good to know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants