nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.92k stars 639 forks source link

New line after } but not in the end of scope #1406

Open Vaberer opened 1 year ago

Vaberer commented 1 year ago

I'm using blankLinesAtEndOfScope to remove uncecessary new lines which is very helpful. However our codebase has a rule of adding a new line after two commands when the first command ends with }

For example

if let value {
  print("")
}

print("")

How to add such this rule?

Vaberer commented 1 year ago

Meanwhile is it possible to achieve this via a custom rule?

nicklockwood commented 1 year ago

There's no way to do it currently AFAIK

Vaberer commented 1 year ago

All right, can you advise what would be the fastest way how to support it? I don't want to create a fork and maintain it, it adds a lot of burden around it.

I mean, should be this implemented as a new rule or what are the ways to support such this behavior?

Thank Nick.

nicklockwood commented 1 year ago

It would need to be a new rule. Code-wise it's not especially difficult to do - the main consideration is designing it in such a way that it follows existing configuration conventions and does not conflict with existing rules.