Skip to content

Commit 5e62d56

Browse files
committed
Handle ignore-unparsable-files option in LintFrontend.
The LintFrontend was ignoring the option to ignore unparsable files and reporting a diagnostic. This option is meant to prevent diagnostics and formatting changes to occur in files with unparsable syntax. The LintFrontend now silently ignores unparsable files, not raising any diagnostics.
1 parent dd87cc2 commit 5e62d56

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/swift-format/Frontend/LintFrontend.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class LintFrontend: Frontend {
3939
.error, "Unable to lint \(path): file is not readable or does not exist."))
4040
return
4141
} catch SwiftFormatError.fileContainsInvalidSyntax(let position) {
42+
guard !lintFormatOptions.ignoreUnparsableFiles else {
43+
// The caller wants to silently ignore this error.
44+
return
45+
}
4246
let location = SourceLocationConverter(file: path, source: source).location(for: position)
4347
diagnosticEngine.diagnose(
4448
Diagnostic.Message(.error, "file contains invalid or unrecognized Swift syntax."),

0 commit comments

Comments
 (0)