SourceKitten icon indicating copy to clipboard operation
SourceKitten copied to clipboard

Add an option for trimmingTrailingWhitespace to ignore whitespace only lines

Open CraigSiemens opened this issue 3 years ago • 6 comments

I recently tried running SwiftLint with --fix --format and saw that it removed thousands of whitespace only lines. It'd be great if the options could mirror the options available in Xcode. Particularly an option to ignore whitespace only lines.

Padded Screen Shot 2022-06-14 at 12 27 11 PM

CraigSiemens avatar Jun 14 '22 18:06 CraigSiemens

That's not implemented here, it's implemented in SourceKit and SwiftLint.

jpsim avatar Aug 22 '22 17:08 jpsim

Isn't it implemented here?

https://github.com/jpsim/SourceKitten/blob/main/Source/SourceKittenFramework/File.swift#L119-L123

CraigSiemens avatar Aug 22 '22 17:08 CraigSiemens

Huh, yes you're right. Sorry for closing then, I'm surprised I hooked it up this way.

jpsim avatar Aug 22 '22 17:08 jpsim

Would really love the option to make SwiftLint --fix --format mimic the default behavior of Xcode format (⌃ + I)

OmranK avatar Sep 21 '23 18:09 OmranK

Going to tackle this. Should the implementation add an additional function parameter:

public func format(trimmingTrailingWhitespace: Bool, ignoringEmptyLines: Bool, useTabs: Bool, indentWidth: Int)

or should it be the default behavior?

OmranK avatar Dec 05 '23 17:12 OmranK

@jpsim can you let me know if there is any concerns with my implementation so I can fix them and get it merged in.

OmranK avatar Feb 26 '24 20:02 OmranK