Is it possible to apply filters to specific rules?
For instance I would like my --header rule to have a different exclude list than for the rest of my rules. Is is possible? I could not find anything about it so I would assume it's not.
My current workaround is to have separate rule files, each with their own exclude list, and that cach to different locations.
@gsabran yes, this is the recommended solution.
I'm curious about the "cach to different locations" comment though - this shouldn't be necessary as the cache keys include the rule settings. Were you finding that if you didn't do this the cache wasn't working properly?
Interesting. Yes I noticed that linting was much slower if I didn't use different caches.
# 0.7s
mkdir -p .build/caches/swiftformat &&
swiftformat --config rules-header.swiftformat . &&
swiftformat --config rules.swiftformat . --cache .build/caches/swiftformat
# 3.7s
swiftformat --config rules-header.swiftformat . &&
swiftformat --config rules.swiftformat .
My header rule is
# Exclude checkout directories for common package managers
--exclude Carthage,Pods,.build,**/Module.swift,**/Package.swift,build
# options
--header Copyright ...
# rules
--rules fileHeader
The other one is similar to https://github.com/airbnb/swift/blob/master/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat