【问题标题】:swift-lint custom warning for UIWebview useUIWebview 使用的 swift-lint 自定义警告
【发布时间】:2020-06-30 05:33:57
【问题描述】:

由于苹果不再支持 UIWebview,是否可以为此设置 swift-lint 警告。

如何使自定义 UIWebview 使用 swift-lint 警告或错误。

【问题讨论】:

    标签: ios swift uiwebview wkwebview swiftlint


    【解决方案1】:

    定义自定义规则的示例在这里(没有自己测试,可能正则表达式需要一些返工)。您可以在页面 https://github.com/realm/SwiftLint 的定义自定义规则部分下查看 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-05
      • 2014-08-23
      • 2010-11-11
      相关资源
      最近更新 更多