Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing .swiftlint.yml config(s) within a team across projects #1319

Closed
sundeepgupta opened this issue Feb 17, 2017 · 12 comments
Closed

Sharing .swiftlint.yml config(s) within a team across projects #1319

sundeepgupta opened this issue Feb 17, 2017 · 12 comments
Labels
enhancement Ideas for improvements of existing features and rules.

Comments

@sundeepgupta
Copy link

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.yml
  • test-config.yml

Each 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.

@marcelofabri marcelofabri added the enhancement Ideas for improvements of existing features and rules. label Feb 21, 2017
@jpsim
Copy link
Collaborator

jpsim commented Mar 10, 2017

I don't think this requires anything other than #676. Do you agree @sundeepgupta?

@sundeepgupta
Copy link
Author

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"
  },

@jpsim
Copy link
Collaborator

jpsim commented Mar 11, 2017

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.

@nigelflack
Copy link

I've proposed an alternative approach which may address this? #1352

@gretzki
Copy link

gretzki commented Mar 15, 2017

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

@sundeepgupta
Copy link
Author

@gretzki How does/would each project pull in the team config file and keep it updated?

@gretzki
Copy link

gretzki commented Mar 16, 2017

@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

@sundeepgupta
Copy link
Author

I see, thanks @gretzki

@jpsim
Copy link
Collaborator

jpsim commented May 23, 2017

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.

@sundeepgupta
Copy link
Author

Yes, the merging would be sufficient along with some mechanism (left up to the team) to distribute the shared config.

@zkyronex
Copy link

zkyronex commented Apr 3, 2018

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

@arielelkin
Copy link

For those of us integrating Swiftlint as a Cocoapod, you can:

  1. Place your swiftlint config file into a private pod
  2. Add the private pod to your Podfile
  3. Use the following run script build phase:
CONFIG_FILE="${PODS_ROOT}/My-SwiftLint-Config/swiftlint.yml"
"${PODS_ROOT}/SwiftLint/swiftlint" --config $CONFIG_FILE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas for improvements of existing features and rules.
Projects
None yet
Development

No branches or pull requests

7 participants