-
Notifications
You must be signed in to change notification settings - Fork 320
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 SwiftUI properties sort #289
Conversation
@@ -25,6 +25,7 @@ | |||
--typeattributes prev-line # wrapAttributes | |||
--wrapternary before-operators # wrap | |||
--structthreshold 20 # organizeDeclarations | |||
--sortswiftuiprops first-appearance-sort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@calda I noticed there is a #something
at the end of each, not sure what to add here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the name of the rule that uses the argument, so:
--sortswiftuiprops first-appearance-sort | |
--sortswiftuiprops first-appearance-sort #organizeDeclarations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put this lower down below the --typeorder
option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Why not have a standardized order for property types? |
@jqsilver we don't want to have a strong opinion on how folks define their modifiers but at the same time we want some consistency. This rule feels like a good balance between allowing you to define the order you want but ensuring a consistent order. |
Summary
This PR adds the SwiftUI property declaration sort rule to the style guide.
Reasoning
its preferred that SwiftUI properties are sorted by their dynamic property type. The order is determined by the first time a type appears: