Skip to content

Commit bb4382e

Browse files
committed
Check for suppression file first.
1 parent 3046d92 commit bb4382e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ configuration, by redirecting it to a file and editing it.
201201
### Configuring the Command Line Tool
202202

203203
For any source file being checked or formatted, `swift-format` looks for a
204-
JSON-formatted file named `.swift-format` in the same directory. If one is
205-
found, then that file is loaded to determine the tool's configuration.
204+
JSON-formatted file named `.no-swift-format` in the same directory.
205+
The presence of this file will disable all formatting and linting.
206+
The contents of `.no-swift-format` are ignored - it can be an empty file.
206207

207208
If the file is not found, then it looks in the same directory for a file
208-
called `.no-swift-format`. The presence of this file will
209-
disable all formatting and linting. The contents of `.no-swift-format`
210-
are ignored - it can be an empty file.
209+
called `.swift-format`. If one is found, then that file is loaded to
210+
determine the tool's configuration.
211211

212212
If neither configuration file is found, the search for files continues
213213
in the parent directory, and so on.

Sources/SwiftFormat/API/Configuration.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,14 @@ public struct Configuration: Codable, Equatable {
465465
}
466466
repeat {
467467
candidateDirectory.deleteLastPathComponent()
468-
let candidateFile = candidateDirectory.appendingPathComponent(Self.configurationFileName)
469-
if FileManager.default.isReadableFile(atPath: candidateFile.path) {
470-
return candidateFile
471-
}
472468
let suppressingFile = candidateDirectory.appendingPathComponent(Self.suppressionFileName)
473469
if FileManager.default.isReadableFile(atPath: suppressingFile.path) {
474470
return suppressingFile
475471
}
472+
let candidateFile = candidateDirectory.appendingPathComponent(Self.configurationFileName)
473+
if FileManager.default.isReadableFile(atPath: candidateFile.path) {
474+
return candidateFile
475+
}
476476
} while !candidateDirectory.isRoot
477477

478478
return nil

0 commit comments

Comments
 (0)