nicklockwood/SwiftFormat

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

Open

#426 创建于 2019年5月3日

在 GitHub 查看
 (11 评论) (4 反应) (0 负责人)Swift (686 fork)batch import
help wantedknown issue

仓库指标

Star
 (8,801 star)
PR 合并指标
 (平均合并 13小时 11分钟) (30 天内合并 25 个 PR)

描述

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

贡献者指南