diff --git a/CHANGELOG.md b/CHANGELOG.md index abb1c2af86..1136e2d385 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,11 @@ [Hossam Ghareeb](https://github.com/hossamghareeb) [#1763](https://github.com/realm/SwiftLint/issues/1763) +* Fix using wrong configuration when using `--path` and when there is + a configuration in a parent directory. + [Marcelo Fabri](https://github.com/marcelofabri) + [#1744](https://github.com/realm/SwiftLint/issues/1744) + ## 0.21.0: Vintage Washboard ##### Breaking diff --git a/Source/SwiftLintFramework/Extensions/Configuration+Merging.swift b/Source/SwiftLintFramework/Extensions/Configuration+Merging.swift index d2bf97ff1c..e07ebfc0de 100644 --- a/Source/SwiftLintFramework/Extensions/Configuration+Merging.swift +++ b/Source/SwiftLintFramework/Extensions/Configuration+Merging.swift @@ -25,6 +25,10 @@ extension Configuration { let pathNSString = path.bridge() let configurationSearchPath = pathNSString.appendingPathComponent(Configuration.fileName) + if configurationSearchPath == configurationPath { + return self + } + // If a configuration exists and it isn't us, load and merge the configurations if configurationSearchPath != configurationPath && FileManager.default.fileExists(atPath: configurationSearchPath) {