nicklockwood/SwiftFormat

SwiftFormat searching parent folders for .swiftformat (how to prevent?)

Open

#426 opened on 2019年5月3日

GitHub で見る
 (11 comments) (4 reactions) (0 assignees)Swift (686 forks)batch import
help wantedknown issue

Repository metrics

Stars
 (8,801 stars)
PR merge metrics
 (平均マージ 13h 11m) (30d で 25 merged PRs)

説明

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 :)

コントリビューターガイド