SwiftLint 是什么?!?!
A tool to enforce Swift style and conventions, loosely based on GitHub’s Swift Style Guide .
安装
|
|
Xcode
SwiftLintXcode
插件自动在保存文件时运行 swiftlint
SwiftLintXcode
Run Script Phase
|
|
git hook
git commit
时自动格式化加入stage的代码
- 将下面代码写入git仓库根目录
pre-commit.sh
文件
|
|
- 生成link
|
|
- 修改权限
-1chmod ug+x .git/hooks/pre-commit
修改规则
swiftlint rules
查看所有规则swiftlint rules rule_name
查看规则详情
在git仓库根目录新建文件 .swiftlint.yml
作用于整个项目
- disabled_rules: Disable rules from the default enabled set.
- opt_in_rules: Some rules are opt-in.
- whitelist_rules: Can not be specified alongside disabled_rules or opt_in_rules. Acts as a whitelist, only the rules specified in this list will be enabled.
官方sample