Skip to content

Commit ce9dd11

Browse files
committed
Check for suppression file first.
1 parent 101e80e commit ce9dd11

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

README.md

+5-5
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,14 @@ public struct Configuration: Codable, Equatable {
451451
}
452452
repeat {
453453
candidateDirectory.deleteLastPathComponent()
454-
let candidateFile = candidateDirectory.appendingPathComponent(Self.configurationFileName)
455-
if FileManager.default.isReadableFile(atPath: candidateFile.path) {
456-
return candidateFile
457-
}
458454
let suppressingFile = candidateDirectory.appendingPathComponent(Self.suppressionFileName)
459455
if FileManager.default.isReadableFile(atPath: suppressingFile.path) {
460456
return suppressingFile
461457
}
458+
let candidateFile = candidateDirectory.appendingPathComponent(Self.configurationFileName)
459+
if FileManager.default.isReadableFile(atPath: candidateFile.path) {
460+
return candidateFile
461+
}
462462
} while !candidateDirectory.isRoot
463463

464464
return nil

0 commit comments

Comments
 (0)