mirror of
https://github.com/Dimillian/Skills.git
synced 2026-03-25 08:55:54 +00:00
Add SwiftLint integration for code style enforcement
This commit is contained in:
parent
6969ee59cb
commit
742616663b
2 changed files with 97 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
opt_in_rules:
|
||||
- empty_count
|
||||
- explicit_init
|
||||
- sorted_imports
|
||||
- redundant_nil_coalescing
|
||||
- private_outlet
|
||||
- overridden_super_call
|
||||
- prohibited_super_call
|
||||
|
||||
disabled_rules:
|
||||
- trailing_whitespace
|
||||
|
||||
analyzer_rules:
|
||||
- explicit_self
|
||||
- unused_import
|
||||
|
||||
included:
|
||||
- Sources
|
||||
|
||||
excluded:
|
||||
- .build
|
||||
- build
|
||||
- DerivedData
|
||||
- Pods
|
||||
|
||||
force_cast: warning
|
||||
force_try: error
|
||||
line_length:
|
||||
warning: 120
|
||||
error: 150
|
||||
type_body_length:
|
||||
warning: 300
|
||||
error: 500
|
||||
file_length:
|
||||
warning: 500
|
||||
error: 1000
|
||||
function_body_length:
|
||||
warning: 40
|
||||
error: 100
|
||||
|
||||
reporter: "xcode"
|
||||
56
ios-spm-app-packaging/references/swiftlint.md
Normal file
56
ios-spm-app-packaging/references/swiftlint.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# SwiftLint integration
|
||||
|
||||
Enforces Swift code style. The bootstrap template includes a pre-configured `.swiftlint.yml`.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
brew install swiftlint
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The included `.swiftlint.yml` enforces:
|
||||
|
||||
- Opt-in rules: `sorted_imports`, `empty_count`, `explicit_init`, `redundant_nil_coalescing`
|
||||
- Analyzer rules: `explicit_self`, `unused_import`
|
||||
- Line length: warning at 120, error at 150
|
||||
- Type/function body limits
|
||||
- `force_cast`: warning, `force_try`: error
|
||||
|
||||
Customize by editing `.swiftlint.yml`.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
swiftlint lint
|
||||
swiftlint lint --strict
|
||||
swiftlint autocorrect
|
||||
```
|
||||
|
||||
## Xcode integration
|
||||
|
||||
Add a Run Script Phase:
|
||||
|
||||
```bash
|
||||
if which swiftlint >/dev/null; then
|
||||
swiftlint
|
||||
else
|
||||
echo "warning: SwiftLint not installed"
|
||||
fi
|
||||
```
|
||||
|
||||
## Fastlane integration
|
||||
|
||||
```ruby
|
||||
lane :lint do
|
||||
swiftlint(mode: :lint, strict: true, reporter: "xcode")
|
||||
end
|
||||
```
|
||||
|
||||
## CI integration
|
||||
|
||||
```yaml
|
||||
- name: Lint
|
||||
run: swiftlint lint --strict
|
||||
```
|
||||
Loading…
Reference in a new issue