nicklockwood / SwiftFormat

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

Rule for "remove blank line in multi-line code chaining"? #954

Open pfurbacher opened 3 years ago

pfurbacher commented 3 years ago

SwiftFormat does not seem to have a rule to deal with the following untidiness:

Text("Hello, world")

    .font(.footnote)
    .foregroundColor(Color.gray)

I would expect to be able to remove the extra blank line, yielding:

Text("Hello, world")
    .font(.footnote)
    .foregroundColor(Color.gray)

Neither "Format Selection" nor "Format File" resolves this.

nicklockwood commented 3 years ago

@pfurbacher you're right - I tend to assume that blank lines to break up code should be at the developer's discretion. I think it would make sense to make an exception for lines inserted inside a chained expression though.

calda commented 1 year ago

Looks like this was just implemented! https://github.com/nicklockwood/SwiftFormat/pull/1480