考虑project.includeFilters:
配置应在此项目中格式化哪些源文件。
# manually include files to format.
project.includeFilters = [
regex1
regex2
]
例如,假设我们有带有foo
, bar
,baz
等包的项目结构,像这样
someProject/src/main/scala/com/example/foo/*.scala
someProject/src/main/scala/com/example/bar/*.scala
someProject/src/main/scala/com/example/baz/qux/*.scala
...
那么以下.scalafmt.conf
project.includeFilters = [
"foo/.*"
]
continuationIndent.callSite = 2
...
将仅格式化foo
包中的文件。现在我们可以开始逐步将格式化引入到代码库中一个包一个包
project.includeFilters = [
"foo/.*"
"bar/.*"
]
continuationIndent.callSite = 2
...
甚至逐个文件
project.includeFilters = [
"foo/FooA\.scala"
"foo/FooB\.scala"
]
continuationIndent.callSite = 2
...