整合SwiftLint

zk1947發表於2024-04-23

1.pod整合程式碼

pod 'SwiftLint'

2.新增JS程式碼如下

同時保證將JS放在Sources之前

3.cd到專案根目錄下,建立yml檔案

touch .swiftlint.yml

4.將規則內容貼上到yml中

# Yaml doc reference:
#   https://github.com/realm/SwiftLint#disable-rules-in-code
#   https://github.com/realm/SwiftLint/issues/2180

disabled_rules: # rule identifiers to exclude from running
  - trailing_whitespace
  - identifier_name
  - type_name
  - shorthand_operator
  - function_body_length
  - nesting
  - type_body_length
  - cyclomatic_complexity
  - file_length
  - unused_closure_parameter
  - function_parameter_count
  - large_tuple
opt_in_rules: # some rules are only opt-in
excluded: # paths to ignore during linting. Takes precedence over `included`.
  - Pods
  - Vendor
analyzer_rules: # Rules run by `swiftlint analyze` (experimental)
  - explicit_self

# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning # implicitly
force_try:
  severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level implicitly
line_length: 500

相關文章