This is a base SwiftLint configuration containing the most general rules I use in all my Swift projects.
By design, this config resides in a public GitHub repository so I can link directly to the raw file contents in my apps individual SwiftLint configuration files. SwiftLint has support for parent/child configurations, and can even fetch them from remote locations as described in the SwiftLint documentation.
I take advantage of this to establish a general configuration that is shared for all my Swift projects. These projects will also have a local SwiftLint configuration, which may enable additional opt-in rules, apply different configuration parameters or disable some rules. As a bonus, SwiftLint supports multiple layers of remote configs. As such, my parent config uses the standard Kodeco (Ray Wenderlich) Swift style configuration as a base, which I append to fit my preferences.
You can use this as a parent config by adding the below to your .swiftlint.yml
file in your project folder.
parent_config: https://raw.githubusercontent.com/christiankm/swiftlint-parent-config/main/dk.mitteldorf.swiftlint.yml
This will automatically fetch a copy of my shared config and effectively insert that at the top of your file. Any rules or configuration defined further down in your SwiftLint configuration file will override the parent config.
As mentioned, I use the Kodeco (Ray Wenderlich) Swift Style Guide and their base SwiftLint configuration as a higher-level parent config.
My SwiftLint configuration includes some custom SwiftLint rules created over the years. These are stored in the christiankm/Swiftlint-Custom-Rules repository for your inspiration. If you have any useful custom rules, I would love to see them added in a Pull Request.