Enable the ordered imports rule in swift-format
Closed this issue · 9 comments
AFAIK swift-format has a rule to force import statements to be ordered lexicographically. But that rule doesn’t appear to be enabled in this repository. W should enable it.
Mind if I use this one as a reason to read more about swift-format rules and set it up?
Sure, go ahead.
I recall that in one of the PRs with @kimdv and @ahoppen , we discussed how sometimes we skip the return
keyword in the codebase, and sometimes we don't. At that time, swift-format
didn't have a rule for this, but that's changed. There's now a rule to omit the return
keyword whenever possible.
So the question is, do we want to adopt this rule?
Tracked in Apple’s issue tracker as rdar://114841762
It would definitely be interesting to see what the code looks like with the implicit return rule enabled. I think I commented somewhere that I‘m personally not a fan of omitting the return but consistency is more important than my personal preference.
#2145 adds OrderedImports
, but I'll push up another commit to it with implicit returns so we can take a look at the code and see if we like it.
Interesting finds:
swift-format
will not complain if you make a typo in a rule name. I made a typoOrderedImpora
and ran./format.py
and it didnt' output anything, and didn't change any files, of course — would be nice to have a warning formswift-format
. I'll file an issue and make a PR.swift-format dump-configuration
dumps the default json config, but does not explain what each rule does. It would be nice to have a comment with each of the config settings that summarizes how it works. Again, easy PR probably.
Follow-up swift-format issues:
- Comments in dump-configuration: swiftlang/swift-format#606
- Detect mistakes in the Rules configuration: swiftlang/swift-format#607
Thanks @natikgadzhi 😁
Resolved by #2145
You can btw write things in PR like "Fixes #issueNumber" or "Resolves #issueNumber". When then merging a PR it will automatically close the issue