Has anyone implemented anything to accomplish this?
My initial thoughts are to create a centralized repo, configs which would contain all team-wide rules. For example:
app-config.ymltest-config.ymlEach project would include the configs repo as a submodule and create symlinks named .swiftlint.yml in their app and test directories that would point to the respective config file. When the team decides to update rules, each project could update their submodule to keep in sync.
The problem I see with that though is how would a project be able to override/append project specific rules? If inheriting rules was supported, perhaps the symlink lives at a higher directory level thereby allowing the project to override/append rules.
I don't think this requires anything other than #676. Do you agree @sundeepgupta?
Yes, that would definitely make this possible. I was more curious about the approach in general (like using submodules or if there is a better way).
In ESLint this can be done via NPM. Here is a snippet of the package.json which uses Google's base config:
"devDependencies": {
"eslint": "3.6.1",
"eslint-config-google": "0.6.0"
},
I suppose it could be possible to do something similar with CocoaPods, but if we had some sort of configuration registry, I'd rather it work with all installation methods for SwiftLint.
I've proposed an alternative approach which may address this? #1352
Hi @sundeepgupta, I live the idea of a team across config.
We've already team-wide configs for other tools in a shared repo.
With SwiftLint it's currently possible to specify such a shared config file via the --config option.
Alas, the project-specific __.swiftlint.yml__ is ignored.
It should be merged into the main configuration as it is proposed here: #676
Alas, the global one is ignored due to the missing merge function described here: #676
@gretzki How does/would each project pull in the team config file and keep it updated?
@sundeepgupta As said, we've got one repo with shared config of all tools like oclint, provisioning profiles, etc. It's checked out in the same location on every developer's machine and on the CI machine. As it doesn't change daily or even weekly it is enough to update it occasionally. On the CI machines, we've got jobs updating the repo daily. That way, it stays updated.
As I debugged SwiftLint I realized, that the project's config file is already been merged with the global one, that is being specified via the config option.
Since the merge function is not implemented yet, the global config is simply being replaced by the project's one. So solving #676 will solve my issue too :)
I did some more research and found another related issue. I explain it in some more detail in #1357 1357
I see, thanks @gretzki
I'm still not following fully, I think merging of configurations should be sufficient to enable this workflow. Am I missing something? If not, let's close this as a duplicate of #676.
Yes, the merging would be sufficient along with some mechanism (left up to the team) to distribute the shared config.
Good day all,
Visiting this thread because of the exact intentions.
My team achieved this via having a separate repo for the Swiftlint file & pointing to it via git submodule in all team projects. Then we point the project to it in Xcode build via --config as @gretzki said.
That way as we can safely clone repos in any environment and reliably have Swiftlint set up with the same paths
For those of us integrating Swiftlint as a Cocoapod, you can:
CONFIG_FILE="${PODS_ROOT}/My-SwiftLint-Config/swiftlint.yml"
"${PODS_ROOT}/SwiftLint/swiftlint" --config $CONFIG_FILE
Most helpful comment
Good day all,
Visiting this thread because of the exact intentions.
My team achieved this via having a separate repo for the Swiftlint file & pointing to it via git submodule in all team projects. Then we point the project to it in Xcode build via
--configas @gretzki said.That way as we can safely clone repos in any environment and reliably have Swiftlint set up with the same paths