nicklockwood / SwiftFormat

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

Fixes linting with stdin #1744

Closed jakenvac closed 3 days ago

jakenvac commented 4 days ago

closes #1741

This PR improves support for running --lint when providing input from stdin. The reporter.write is now invoked similarly to how it is when the file is read directly from disk.

There is still one issue I've not figured out. The indent rule is flagged for every single line of the input when supplied via stdin. Must be something to do with how it is read/how the rule detects newlines/indentation.

However, I think that could warrant its own issue and PR if this one is accepted.

As an aside, I don't use xcode, just the swift cli and swift package manager, so not sure if anything else is required for this change.