SwiftFormat
SwiftFormat copied to clipboard
Max number of arguments to also start wrapping them
In addition to wrap arguments when reaching a length in char count, it would be nice to have an option to also wrap them when reaching a limit on the arguments count.
In our company, we have some non-written rule where, for example, if a function declaration/call takes more than 2 params, we wrap all of the arguments. E.g.
func myFunc(param1: String, param2: Int, param3: Double) {
...
}
becomes something like this (in case of before-first
)
func myFunc(
param1: String,
param2: Int,
param3: Double
) {
...
}
+1 I'd like to have this feature as well. I can't find a way to enforce swiftFormat use multiline styling for func params. I guess this issue kinda relates to this https://github.com/nicklockwood/SwiftFormat/issues/379
Yeah, this and #379 would be a great addition to wraparguments
Coming from the javascript world, this seemed to be the most predictable way to format things, and I've just been manually doing it instead of relying on SwiftFormat for it, because I think of line-length as a last resort clamp on the width; if someone's hitting that, some other rule should be coming into effect long-before the max-width should actually be considered, or they're simply writing out too long of a comment. It would be great to have predictable line-breaks regardless of whether the line is long or not, and then if the number wrappable tokens doesn't exceed your preference, rely on the line-length to do it anyway.
It's been quite frustrating to not have this so far, so every so often I'll just go through each line and break the args/params/collection wherever it makes sense.