用于UIWebview的swift lint自定义警告



由于苹果不再支持UIWebview,是否可以对此进行快速lint警告。

如何使自定义UIWebview使用快速lint警告或错误。

定义自定义规则的示例在这里(我没有自己测试,regex可能需要一些返工(。您可以查看页面上提供的swiftlint样品https://github.com/realm/SwiftLint,位于"定义自定义规则"一节下。

custom_rules:
uiwebview_deprecated: # rule identifier
included: ".*\.swift" # regex that defines paths to include during linting. optional.
excluded: ".*Test\.swift" # regex that defines paths to exclude during linting. optional
name: "UIWebView deprecated" # rule name. optional.
regex: "(UIWebView)" # matching pattern
capture_group: 0 # number of regex capture group to highlight the rule violation at. optional.
match_kinds: # SyntaxKinds to match. optional.
- comment
- identifier
message: "UIWebView are deprecated, use WKWebView instead." # violation message. optional.
severity: error # violation severity. optional.
no_hiding_in_strings:
regex: "(UIWebView)"
match_kinds: string

最新更新