CodeEditApp / CodeEdit

CodeEdit App for macOS – Elevate your code editing experience. Open source, free forever.
https://codeedit.app
MIT License
21.07k stars 1.02k forks source link

🧰 SwiftLint: Global Parent Config for all Repositories #1204

Open lukepistrol opened 1 year ago

lukepistrol commented 1 year ago

As discussed in our Discord we might use a global SwiftLint configuration across all our repos to have the styling guidelines applied everywhere.

This is already possible by SwiftLint itself: Reference

Proposed Solution

My suggestion is to add a new Repository in the organization called something similar to CodeStyle (open for suggestions though on the naming).

There we could host the .swiftlint.yml file which we can then include in each repo adding

parent_config: https://raw.githubusercontent.com/CodeEditApp/{REPO_NAME}/main/.swiftlint.yml

This would fetch the config automatically when running SwiftLint. It also caches the latest version for situations where no internet connection is available.

If there are special needs, for example excluding some file paths, on a per repo basis, this could be overridden in the project's .swiftlint.yml.

Attention Needed

When implementing this change it also is important to update the code on each repo to conform to this code style. The CodeEdit repo should be fine already since we already implemented the proper rules. The major task will be updating the relatively large codebase of CodeEditTextView.

Future Additions

In the future we could also investigate how to add other configurations to this repo which might be needed on all the different repos.

Wouter01 commented 1 year ago

That's a great idea! Would the CI also need to be updated for some repos so it fails on a swiftlint fail? Will all repos need to conform to the rules before they are applied?

lukepistrol commented 1 year ago

@Wouter01 I'll update them while implementing it. The CI should work out of the box once the changes are made. But of course I need to test it first and make adjustments as errors occur.

austincondiff commented 1 year ago

There are a few things that are shared including the linter config but also issue/pr templates, and some actions. It is a great thing to share this between repositories to keep things consistent. SwiftLint config is a great place to start.

lukepistrol commented 1 year ago

I have to put this on hold because for some reason when running SwiftLint through Xcode (either as build plugin or run phase) it cannot download the remote config. It does when running it from the terminal though. I need to investigate whether there is a flag I need to set in build settings to allow network access.