Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit category ordering configuration for organizeDeclarations rule #280

Merged
merged 3 commits into from
Jul 22, 2024

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
5 checks passed
@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 !

@@ -27,6 +27,8 @@
--structthreshold 20 # organizeDeclarations
--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.

3 participants