SwiftFormat searching parent folders for .swiftformat (how to prevent?)
#426 opened on May 3, 2019
Description
Hi!
We have a project layout like this:
Project
.swiftformat # -> *note* this contains `--exclude **/Submodules`
Source/
Class.swift
Submodules/
SomeFramework/
.swiftformat # -> here we have another .swiftformat
Source/
Pods/
I'm seeing an issue here where running SwiftFormat from inside the submodule like:
cd Submodules/SomeFramework
Pods/SwiftFormat/CommandLineTool/swiftformat Source --config .swiftformat --verbose
we get:
Running SwiftFormat...
Skipping /Users/ian/AppsDev/VirtualAffairs/BankingRight/Bankingright-showcase-ios/Submodules
-- ignored
Skipping [path]/Submodules
-- ignored
error: No eligible files found at [path]/Submodules/SomeFramework/Source
So even though we run it from inside the submodule folder, being sure to pass in the .swiftformat found there, it seems SwiftFormat is searching up through several parent folders & finding a .swiftformat file which excludes the /Submodules directory tree, and so ends the execution there.
Is this intended behaviour? I think it's valid that a git submodule could have it's own .swiftformat config without the containing parent getting involved (particularly when swiftformat is itself ran from inside the submodule too).
I've tried re-enabling the Submodules tree from inside /Submodules/SomeFramework/.swiftformat by passing various things to the new --unexclude flag, but I can't get it to work.
All advice gratefully received :)