mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
Apply Markdown auto-formatting (#5960)
Used https://github.com/DavidAnson/markdownlint-cli2.
This commit is contained in:
+156
-166
@@ -44,7 +44,7 @@
|
||||
* The command plugin now requires write permissions so that it works with the `--fix` option without an error.
|
||||
[SimplyDanny](https://github.com/SimplyDanny)
|
||||
|
||||
* The artifact bundle name has changed. `SwiftLintBinary-macos.artifactbundle.zip` is now called
|
||||
* The artifact bundle name has changed. `SwiftLintBinary-macos.artifactbundle.zip` is now called
|
||||
`SwiftLintBinary.artifactbundle.zip`. It now includes an AMD64 Linux binary.
|
||||
[Bradley Mackey](https://github.com/bradleymackey)
|
||||
[#5514](https://github.com/realm/SwiftLint/issues/5514)
|
||||
@@ -223,7 +223,7 @@
|
||||
[#5711](https://github.com/realm/SwiftLint/issues/5711)
|
||||
|
||||
* Fixes `file_name` rule to match fully-qualified names of nested types.
|
||||
Additionally adds a `require_fully_qualified_names` boolean option to enforce
|
||||
Additionally adds a `require_fully_qualified_names` boolean option to enforce
|
||||
that file names match nested types only using their fully-qualified name.
|
||||
[fraioli](https://github.com/fraioli)
|
||||
[#5840](https://github.com/realm/SwiftLint/issues/5840)
|
||||
@@ -682,7 +682,7 @@
|
||||
* Refine violation position of `trailing_closure` rule.
|
||||
[SimplyDanny](https://github.com/SimplyDanny)
|
||||
|
||||
* Trigger on the declaration keyword (i.e. `let`, `var`, `func`, `subscript`)
|
||||
* Trigger on the declaration keyword (i.e. `let`, `var`, `func`, `subscript`)
|
||||
instead of the `static` or `class` keywords in the `explicit_acl` rule.
|
||||
[SimplyDanny](https://github.com/SimplyDanny)
|
||||
|
||||
@@ -1376,7 +1376,7 @@
|
||||
[AndrewDMontgomery](https://github.com/andrewdmontgomery)
|
||||
[#4875](https://github.com/realm/SwiftLint/pull/4875)
|
||||
|
||||
* Prepend `warning: ` to error messages so that they show in Xcode.
|
||||
* Prepend `warning:` to error messages so that they show in Xcode.
|
||||
[whiteio](https://github.com/whiteio)
|
||||
[#4923](https://github.com/realm/SwiftLint/issues/4923)
|
||||
|
||||
@@ -1773,149 +1773,149 @@
|
||||
|
||||
* Rewrite some rules with SwiftSyntax, fixing some false positives and catching
|
||||
more violations:
|
||||
- `anonymous_argument_in_multiline_closure`
|
||||
- `array_init`
|
||||
- `attributes`
|
||||
- `balanced_xctest_lifecycle`
|
||||
- `block_based_kvo`
|
||||
- `class_delegate_protocol`
|
||||
- `closing_brace`
|
||||
- `closure_body_length`
|
||||
- `closure_parameter_position`
|
||||
- `collection_alignment`
|
||||
- `comment_spacing`
|
||||
- `computed_accessors_order`
|
||||
- `conditional_returns_on_newline`
|
||||
- `contains_over_filter_count`
|
||||
- `contains_over_filter_is_empty`
|
||||
- `contains_over_first_not_nil`
|
||||
- `contains_over_range_nil_comparison`
|
||||
- `convenience_type`
|
||||
- `deployment_target`
|
||||
- `discarded_notification_center_observer`
|
||||
- `discouraged_assert`
|
||||
- `discouraged_direct_init`
|
||||
- `discouraged_none_name`
|
||||
- `discouraged_object_literal`
|
||||
- `discouraged_optional_boolean`
|
||||
- `duplicate_enum_cases`
|
||||
- `duplicated_key_in_dictionary_literal`
|
||||
- `dynamic_inline`
|
||||
- `empty_collection_literal`
|
||||
- `empty_count`
|
||||
- `empty_enum_arguments`
|
||||
- `empty_parameters`
|
||||
- `empty_parentheses_with_trailing_closure`
|
||||
- `empty_string`
|
||||
- `enum_case_associated_values_count`
|
||||
- `explicit_enum_raw_value`
|
||||
- `explicit_init`
|
||||
- `explicit_top_level_acl`
|
||||
- `fallthrough`
|
||||
- `file_name`
|
||||
- `first_where`
|
||||
- `flatmap_over_map_reduce`
|
||||
- `for_where`
|
||||
- `force_try`
|
||||
- `force_unwrapping`
|
||||
- `function_body_length`
|
||||
- `function_default_parameter_at_end`
|
||||
- `function_parameter_count`
|
||||
- `generic_type_name`
|
||||
- `ibinspectable_in_extension`
|
||||
- `identical_operands`
|
||||
- `implicit_getter`
|
||||
- `implicitly_unwrapped_optional`
|
||||
- `inclusive_language`
|
||||
- `inert_defer`
|
||||
- `is_disjoint`
|
||||
- `joined_default_parameter`
|
||||
- `large_tuple`
|
||||
- `last_where`
|
||||
- `legacy_cggeometry_functions`
|
||||
- `legacy_constant`
|
||||
- `legacy_constructor`
|
||||
- `legacy_hashing`
|
||||
- `legacy_multiple`
|
||||
- `legacy_nsgeometry_functions`
|
||||
- `legacy_objc_type`
|
||||
- `legacy_random`
|
||||
- `lower_acl_than_parent`
|
||||
- `multiline_arguments_brackets`
|
||||
- `multiline_parameters`
|
||||
- `multiple_closures_with_trailing_closure`
|
||||
- `no_extension_access_modifier`
|
||||
- `no_fallthrough_only`
|
||||
- `no_space_in_method_call`
|
||||
- `notification_center_detachment`
|
||||
- `nslocalizedstring_key`
|
||||
- `nslocalizedstring_require_bundle`
|
||||
- `nsobject_prefer_isequal`
|
||||
- `number_separator`
|
||||
- `object_literal`
|
||||
- `operator_whitespace`
|
||||
- `optional_enum_case_matching`
|
||||
- `orphaned_doc_comment`
|
||||
- `overridden_super_call`
|
||||
- `override_in_extension`
|
||||
- `pattern_matching_keywords`
|
||||
- `prefer_nimble`
|
||||
- `prefer_self_in_static_references`
|
||||
- `prefer_self_type_over_type_of_self`
|
||||
- `prefer_zero_over_explicit_init`
|
||||
- `prefixed_toplevel_constant`
|
||||
- `private_action`
|
||||
- `private_outlet`
|
||||
- `private_over_fileprivate`
|
||||
- `private_subject`
|
||||
- `private_unit_test`
|
||||
- `prohibited_interface_builder`
|
||||
- `prohibited_super_call`
|
||||
- `protocol_property_accessors_order`
|
||||
- `quick_discouraged_focused_test`
|
||||
- `quick_discouraged_pending_test`
|
||||
- `raw_value_for_camel_cased_codable_enum`
|
||||
- `reduce_boolean`
|
||||
- `reduce_into`
|
||||
- `redundant_discardable_let`
|
||||
- `redundant_nil_coalescing`
|
||||
- `redundant_objc_attribute`
|
||||
- `redundant_optional_initialization`
|
||||
- `redundant_set_access_control`
|
||||
- `redundant_string_enum_value`
|
||||
- `required_deinit`
|
||||
- `required_enum_case`
|
||||
- `return_arrow_whitespace`
|
||||
- `self_in_property_initialization`
|
||||
- `shorthand_operator`
|
||||
- `single_test_class`
|
||||
- `sorted_first_last`
|
||||
- `static_operator`
|
||||
- `strict_fileprivate`
|
||||
- `strong_iboutlet`
|
||||
- `switch_case_alignment`
|
||||
- `switch_case_on_newline`
|
||||
- `test_case_accessibility`
|
||||
- `toggle_bool`
|
||||
- `trailing_comma`
|
||||
- `trailing_semicolon`
|
||||
- `type_body_length`
|
||||
- `type_name`
|
||||
- `unneeded_break_in_switch`
|
||||
- `unneeded_parentheses_in_closure_argument`
|
||||
- `unowned_variable_capture`
|
||||
- `untyped_error_in_catch`
|
||||
- `unused_capture_list`
|
||||
- `unused_closure_parameter`
|
||||
- `unused_control_flow_label`
|
||||
- `unused_enumerated`
|
||||
- `unused_optional_binding`
|
||||
- `unused_setter_value`
|
||||
- `valid_ibinspectable`
|
||||
- `vertical_parameter_alignment`
|
||||
- `weak_delegate`
|
||||
- `xct_specific_matcher`
|
||||
- `xctfail_message`
|
||||
* `anonymous_argument_in_multiline_closure`
|
||||
* `array_init`
|
||||
* `attributes`
|
||||
* `balanced_xctest_lifecycle`
|
||||
* `block_based_kvo`
|
||||
* `class_delegate_protocol`
|
||||
* `closing_brace`
|
||||
* `closure_body_length`
|
||||
* `closure_parameter_position`
|
||||
* `collection_alignment`
|
||||
* `comment_spacing`
|
||||
* `computed_accessors_order`
|
||||
* `conditional_returns_on_newline`
|
||||
* `contains_over_filter_count`
|
||||
* `contains_over_filter_is_empty`
|
||||
* `contains_over_first_not_nil`
|
||||
* `contains_over_range_nil_comparison`
|
||||
* `convenience_type`
|
||||
* `deployment_target`
|
||||
* `discarded_notification_center_observer`
|
||||
* `discouraged_assert`
|
||||
* `discouraged_direct_init`
|
||||
* `discouraged_none_name`
|
||||
* `discouraged_object_literal`
|
||||
* `discouraged_optional_boolean`
|
||||
* `duplicate_enum_cases`
|
||||
* `duplicated_key_in_dictionary_literal`
|
||||
* `dynamic_inline`
|
||||
* `empty_collection_literal`
|
||||
* `empty_count`
|
||||
* `empty_enum_arguments`
|
||||
* `empty_parameters`
|
||||
* `empty_parentheses_with_trailing_closure`
|
||||
* `empty_string`
|
||||
* `enum_case_associated_values_count`
|
||||
* `explicit_enum_raw_value`
|
||||
* `explicit_init`
|
||||
* `explicit_top_level_acl`
|
||||
* `fallthrough`
|
||||
* `file_name`
|
||||
* `first_where`
|
||||
* `flatmap_over_map_reduce`
|
||||
* `for_where`
|
||||
* `force_try`
|
||||
* `force_unwrapping`
|
||||
* `function_body_length`
|
||||
* `function_default_parameter_at_end`
|
||||
* `function_parameter_count`
|
||||
* `generic_type_name`
|
||||
* `ibinspectable_in_extension`
|
||||
* `identical_operands`
|
||||
* `implicit_getter`
|
||||
* `implicitly_unwrapped_optional`
|
||||
* `inclusive_language`
|
||||
* `inert_defer`
|
||||
* `is_disjoint`
|
||||
* `joined_default_parameter`
|
||||
* `large_tuple`
|
||||
* `last_where`
|
||||
* `legacy_cggeometry_functions`
|
||||
* `legacy_constant`
|
||||
* `legacy_constructor`
|
||||
* `legacy_hashing`
|
||||
* `legacy_multiple`
|
||||
* `legacy_nsgeometry_functions`
|
||||
* `legacy_objc_type`
|
||||
* `legacy_random`
|
||||
* `lower_acl_than_parent`
|
||||
* `multiline_arguments_brackets`
|
||||
* `multiline_parameters`
|
||||
* `multiple_closures_with_trailing_closure`
|
||||
* `no_extension_access_modifier`
|
||||
* `no_fallthrough_only`
|
||||
* `no_space_in_method_call`
|
||||
* `notification_center_detachment`
|
||||
* `nslocalizedstring_key`
|
||||
* `nslocalizedstring_require_bundle`
|
||||
* `nsobject_prefer_isequal`
|
||||
* `number_separator`
|
||||
* `object_literal`
|
||||
* `operator_whitespace`
|
||||
* `optional_enum_case_matching`
|
||||
* `orphaned_doc_comment`
|
||||
* `overridden_super_call`
|
||||
* `override_in_extension`
|
||||
* `pattern_matching_keywords`
|
||||
* `prefer_nimble`
|
||||
* `prefer_self_in_static_references`
|
||||
* `prefer_self_type_over_type_of_self`
|
||||
* `prefer_zero_over_explicit_init`
|
||||
* `prefixed_toplevel_constant`
|
||||
* `private_action`
|
||||
* `private_outlet`
|
||||
* `private_over_fileprivate`
|
||||
* `private_subject`
|
||||
* `private_unit_test`
|
||||
* `prohibited_interface_builder`
|
||||
* `prohibited_super_call`
|
||||
* `protocol_property_accessors_order`
|
||||
* `quick_discouraged_focused_test`
|
||||
* `quick_discouraged_pending_test`
|
||||
* `raw_value_for_camel_cased_codable_enum`
|
||||
* `reduce_boolean`
|
||||
* `reduce_into`
|
||||
* `redundant_discardable_let`
|
||||
* `redundant_nil_coalescing`
|
||||
* `redundant_objc_attribute`
|
||||
* `redundant_optional_initialization`
|
||||
* `redundant_set_access_control`
|
||||
* `redundant_string_enum_value`
|
||||
* `required_deinit`
|
||||
* `required_enum_case`
|
||||
* `return_arrow_whitespace`
|
||||
* `self_in_property_initialization`
|
||||
* `shorthand_operator`
|
||||
* `single_test_class`
|
||||
* `sorted_first_last`
|
||||
* `static_operator`
|
||||
* `strict_fileprivate`
|
||||
* `strong_iboutlet`
|
||||
* `switch_case_alignment`
|
||||
* `switch_case_on_newline`
|
||||
* `test_case_accessibility`
|
||||
* `toggle_bool`
|
||||
* `trailing_comma`
|
||||
* `trailing_semicolon`
|
||||
* `type_body_length`
|
||||
* `type_name`
|
||||
* `unneeded_break_in_switch`
|
||||
* `unneeded_parentheses_in_closure_argument`
|
||||
* `unowned_variable_capture`
|
||||
* `untyped_error_in_catch`
|
||||
* `unused_capture_list`
|
||||
* `unused_closure_parameter`
|
||||
* `unused_control_flow_label`
|
||||
* `unused_enumerated`
|
||||
* `unused_optional_binding`
|
||||
* `unused_setter_value`
|
||||
* `valid_ibinspectable`
|
||||
* `vertical_parameter_alignment`
|
||||
* `weak_delegate`
|
||||
* `xct_specific_matcher`
|
||||
* `xctfail_message`
|
||||
|
||||
[Marcelo Fabri](https://github.com/marcelofabri)
|
||||
[SimplyDanny](https://github.com/SimplyDanny)
|
||||
@@ -1958,7 +1958,7 @@
|
||||
`if let self {}`) when using a `bind_identifier` different than `self`.
|
||||
[Marcelo Fabri](https://github.com/marcelofabri)
|
||||
|
||||
* Add `library_content_provider` file type to `file_types_order` rule
|
||||
* Add `library_content_provider` file type to `file_types_order` rule
|
||||
to allow `LibraryContentProvider` to be ordered independent from `main_type`.
|
||||
[dahlborn](https://github.com/dahlborn)
|
||||
|
||||
@@ -6673,14 +6673,14 @@ The next release will require Swift 4.0 or higher to build.
|
||||
|
||||
* Add `attributes` opt-in rule which validates if an attribute (`@objc`,
|
||||
`@IBOutlet`, `@discardableResult`, etc) is in the right position:
|
||||
- If the attribute is `@IBAction` or `@NSManaged`, it should always be on
|
||||
* If the attribute is `@IBAction` or `@NSManaged`, it should always be on
|
||||
the same line as the declaration
|
||||
- If the attribute has parameters, it should always be on the line above
|
||||
* If the attribute has parameters, it should always be on the line above
|
||||
the declaration
|
||||
- Otherwise:
|
||||
- if the attribute is applied to a variable, it should be on the same line
|
||||
- if it's applied to a type or function, it should be on the line above
|
||||
- if it's applied to an import (the only option is `@testable import`),
|
||||
* Otherwise:
|
||||
* if the attribute is applied to a variable, it should be on the same line
|
||||
* if it's applied to a type or function, it should be on the line above
|
||||
* if it's applied to an import (the only option is `@testable import`),
|
||||
it should be on the same line.
|
||||
You can also configure what attributes should be always on a new line or on
|
||||
the same line as the declaration with the `always_on_same_line` and
|
||||
@@ -6715,8 +6715,8 @@ The next release will require Swift 4.0 or higher to build.
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
[#964](https://github.com/realm/SwiftLint/issues/964)
|
||||
|
||||
* Add correctable `empty_parameters` rule to validate usage of `() -> `
|
||||
over `Void -> `.
|
||||
* Add correctable `empty_parameters` rule to validate usage of `() ->`
|
||||
over `Void ->`.
|
||||
[Marcelo Fabri](https://github.com/marcelofabri)
|
||||
[#573](https://github.com/realm/SwiftLint/issues/573)
|
||||
|
||||
@@ -7608,7 +7608,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
[#316](https://github.com/realm/SwiftLint/issues/316)
|
||||
|
||||
|
||||
## 0.5.4: Bounce™
|
||||
|
||||
#### Breaking
|
||||
@@ -7647,7 +7646,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
[Norio Nomura](https://github.com/norio-nomura)
|
||||
[#295](https://github.com/realm/SwiftLint/issues/295)
|
||||
|
||||
|
||||
## 0.5.3: Mountain Scent
|
||||
|
||||
#### Breaking
|
||||
@@ -7689,7 +7687,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
[diogoguimaraes](https://github.com/diogoguimaraes)
|
||||
[#267](https://github.com/realm/SwiftLint/issues/267)
|
||||
|
||||
|
||||
## 0.5.1: Lint Tray Malfunction
|
||||
|
||||
#### Breaking
|
||||
@@ -7712,7 +7709,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
[#264](https://github.com/realm/SwiftLint/issues/264)
|
||||
|
||||
|
||||
## 0.5.0: Downy™
|
||||
|
||||
#### Breaking
|
||||
@@ -7752,7 +7748,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
[#234](https://github.com/realm/SwiftLint/issues/234)
|
||||
|
||||
|
||||
## 0.4.0: Wrinkle Release
|
||||
|
||||
#### Breaking
|
||||
@@ -7812,7 +7807,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
[#200](https://github.com/realm/SwiftLint/issues/200)
|
||||
|
||||
|
||||
## 0.3.0: Wrinkly Rules
|
||||
|
||||
#### Breaking
|
||||
@@ -7865,7 +7859,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
[#154](https://github.com/realm/SwiftLint/issues/154)
|
||||
|
||||
|
||||
## 0.2.0: Tumble Dry
|
||||
|
||||
#### Breaking
|
||||
@@ -7921,7 +7914,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
* Allow newlines in function return arrow.
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
|
||||
|
||||
## 0.1.2: FabricSoftenerRule
|
||||
|
||||
#### Breaking
|
||||
@@ -7953,7 +7945,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
|
||||
* None.
|
||||
|
||||
|
||||
## 0.1.1: Top Loading
|
||||
|
||||
#### Breaking
|
||||
@@ -8001,7 +7992,6 @@ This release has seen a phenomenal uptake in community contributions!
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
[#43](https://github.com/realm/SwiftLint/issues/43)
|
||||
|
||||
|
||||
## 0.1.0: Fresh Out Of The Dryer
|
||||
|
||||
First Version!
|
||||
|
||||
@@ -860,7 +860,7 @@ All syntax kinds used in a snippet of Swift code can be extracted asking
|
||||
|
||||
which match to `keyword` and `identifier` in the above list.
|
||||
|
||||
If using custom rules in combination with `only_rules`, you must include the
|
||||
If using custom rules in combination with `only_rules`, you must include the
|
||||
literal string `custom_rules` in the `only_rules` list:
|
||||
|
||||
```yaml
|
||||
|
||||
+15
-12
@@ -13,6 +13,7 @@ SwiftLint Hook 了 [Clang](http://clang.llvm.org) 和 [SourceKit](http://www.jps
|
||||
不可接受的行为报告给 [info@realm.io](mailto:info@realm.io)。
|
||||
|
||||
## 安装
|
||||
|
||||
### 使用[Swift Package Manager](https://github.com/apple/swift-package-manager)
|
||||
|
||||
SwiftLint 可以用作[命令插件](#swift-package-command-plugin)或[构建工具插件](#build-tool-plugins)
|
||||
@@ -31,7 +32,6 @@ SwiftLint 可以用作[命令插件](#swift-package-command-plugin)或[构建工
|
||||
|
||||
其中,用所需的最低版本或精确版本替换 `<version>`。
|
||||
|
||||
|
||||
### [Xcode Package Dependency](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app)
|
||||
|
||||
使用以下链接将 SwiftLint 作为包依赖添加到 Xcode 项目中:
|
||||
@@ -40,14 +40,13 @@ SwiftLint 可以用作[命令插件](#swift-package-command-plugin)或[构建工
|
||||
https://github.com/SimplyDanny/SwiftLintPlugins
|
||||
```
|
||||
|
||||
|
||||
### 使用 [Homebrew](http://brew.sh/):
|
||||
### 使用 [Homebrew](http://brew.sh/)
|
||||
|
||||
```
|
||||
brew install swiftlint
|
||||
```
|
||||
|
||||
### 使用 [CocoaPods](https://cocoapods.org):
|
||||
### 使用 [CocoaPods](https://cocoapods.org)
|
||||
|
||||
将如下代码添加到你的 Podfile 即可:
|
||||
|
||||
@@ -61,16 +60,17 @@ pod 'SwiftLint'
|
||||
|
||||
请注意这会将 SwiftLint 二进制文件、所依赖的二进制文件和 Swift 二进制库安装到 `Pods/` 目录下,所以不推荐将此目录添加到版本控制系统(如 git)中进行跟踪。
|
||||
|
||||
### 使用 [Mint](https://github.com/yonaskolb/mint):
|
||||
### 使用 [Mint](https://github.com/yonaskolb/mint)
|
||||
|
||||
```
|
||||
$ mint install realm/SwiftLint
|
||||
mint install realm/SwiftLint
|
||||
```
|
||||
|
||||
### 使用安装包:
|
||||
### 使用安装包
|
||||
|
||||
你也可以通过从[最新的 GitHub 发布地址](https://github.com/realm/SwiftLint/releases/latest)下载 `SwiftLint.pkg` 然后执行的方式安装 SwiftLint。
|
||||
|
||||
### 编译源代码:
|
||||
### 编译源代码
|
||||
|
||||
你也可以通过 clone SwiftLint 的 Git 仓库到本地然后执行
|
||||
`make install` (Xcode 15.0+) 以从源代码构建及安装。
|
||||
@@ -142,7 +142,6 @@ swiftlint_deps()
|
||||
bazel run -c opt @SwiftLint//:swiftlint
|
||||
```
|
||||
|
||||
|
||||
## 用法
|
||||
|
||||
### 报告
|
||||
@@ -164,7 +163,7 @@ Xcode 15 对 Build Settings 进行了重大更改,它将 `ENABLE_USER_SCRIPT_S
|
||||
|
||||
如果你是在搭载 Apple 芯片的 Mac 上通过 Homebrew 安装的 SwiftLint,你可能会遇到这个警告:
|
||||
|
||||
> warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint
|
||||
> warning: SwiftLint not installed, download from <https://github.com/realm/SwiftLint>
|
||||
|
||||
这是因为 Homebrew 在搭载 Apple 芯片的 Mac 上将二进制文件默认安装到了 `/opt/homebrew/bin`
|
||||
下。如果要让 Xcode 知道 SwiftLint 在哪,你可以在 Build Phase 中将
|
||||
@@ -227,7 +226,7 @@ Xcode 构建工具插件。
|
||||
对于无人值守的使用场景(例如在 CI 上),可以通过以下方式禁用软件包和宏的验证对话框
|
||||
|
||||
* 单独将 `-skipPackagePluginValidation` 和 `-skipMacroValidation` 传递到 `xcodebuild` 或者
|
||||
* 为那个用户使用 `defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES` 进行全局设置,然后写入 `defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES`
|
||||
* 为那个用户使用 `defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES` 进行全局设置,然后写入 `defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES`
|
||||
|
||||
_注意:这将隐含地信任所有的Xcode软件包插件,并绕过Xcode的软件包验证对话框。
|
||||
这对安全有影响。_
|
||||
@@ -278,16 +277,19 @@ swiftlint(
|
||||
|
||||
`swiftlint` 也可以在 [Docker](https://www.docker.com/) 上使用 `Ubuntu` 作为一个镜像使用。
|
||||
因此,第一次你需要使用下面的命令调用 docker 镜像:
|
||||
|
||||
```bash
|
||||
docker pull ghcr.io/realm/swiftlint:latest
|
||||
```
|
||||
|
||||
接下来,你只需在 docker 中运行`swiftlint`:
|
||||
|
||||
```bash
|
||||
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:latest
|
||||
```
|
||||
|
||||
这将在你现在所在的文件夹(`pwd`)中执行`swiftlint`,显示类似的输出:
|
||||
|
||||
```bash
|
||||
$ docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:latest
|
||||
Linting Swift files in current working directory
|
||||
@@ -344,7 +346,7 @@ SwiftLint 工作于 SourceKit 这一层,所以 Swift 版本发生变化时它
|
||||
你可能也给反向 DNS 符号设置了 `TOOLCHAINS` 环境变量来标记一个特定的 Swift 工具集版本:
|
||||
|
||||
```shell
|
||||
$ TOOLCHAINS=com.apple.dt.toolchain.Swift_2_3 swiftlint autocorrect
|
||||
TOOLCHAINS=com.apple.dt.toolchain.Swift_2_3 swiftlint autocorrect
|
||||
```
|
||||
|
||||
在 Linux 上,SourceKit 默认需要位于 `/usr/lib/libsourcekitdInProc.so` 或者通过 `LINUX_SOURCEKIT_LIB_PATH` 环境变量进行指定。
|
||||
@@ -366,6 +368,7 @@ repos:
|
||||
将 `rev` 调整为您选择的 SwiftLint 版本。可以使用 `pre-commit autoupdate` 来更新到当前版本。
|
||||
|
||||
SwiftLint 可以使用 `entry` 进行配置以应用修复和报错:
|
||||
|
||||
```yaml
|
||||
- repo: https://github.com/realm/SwiftLint
|
||||
rev: 0.50.3
|
||||
|
||||
+10
-9
@@ -13,13 +13,13 @@ SwiftLint는 좀 더 정확한 결과를 위해 [Clang](http://clang.llvm.org)
|
||||
|
||||
## 설치 방법
|
||||
|
||||
### [Homebrew](http://brew.sh/)를 사용하는 경우:
|
||||
### [Homebrew](http://brew.sh/)를 사용하는 경우
|
||||
|
||||
```
|
||||
brew install swiftlint
|
||||
```
|
||||
|
||||
### [CocoaPods](https://cocoapods.org)를 사용하는 경우:
|
||||
### [CocoaPods](https://cocoapods.org)를 사용하는 경우
|
||||
|
||||
Podfile에 아래 라인을 추가하기만 하면 됩니다.
|
||||
|
||||
@@ -33,16 +33,17 @@ CocoaPods를 사용하면 최신 버전 외에도 SwiftLint의 특정 버전을
|
||||
|
||||
이렇게 했을 때 SwiftLint 바이너리 및 그에 종속된 바이너리들과 스위프트 바이너리까지 `Pods/` 디렉터리에 추가되기 때문에, git 등의 SCM에 이런 디렉터리들을 체크인하는 것은 권장하지 않습니다.
|
||||
|
||||
### [Mint](https://github.com/yonaskolb/mint)를 사용하는 경우:
|
||||
### [Mint](https://github.com/yonaskolb/mint)를 사용하는 경우
|
||||
|
||||
```
|
||||
$ mint install realm/SwiftLint
|
||||
mint install realm/SwiftLint
|
||||
```
|
||||
|
||||
### 빌드된 패키지를 사용하는 경우:
|
||||
### 빌드된 패키지를 사용하는 경우
|
||||
|
||||
[최신 깃허브 릴리즈](https://github.com/realm/SwiftLint/releases/latest)에서 `SwiftLint.pkg`를 다운로드해서 설치하고 실행할 수 있습니다.
|
||||
|
||||
### 소스를 직접 컴파일하는 경우:
|
||||
### 소스를 직접 컴파일하는 경우
|
||||
|
||||
본 프로젝트를 클론해서 빌드할 수도 있습니다. `make install` 명령을 사용합니다. (Xcode 12.5 이후 버전)
|
||||
|
||||
@@ -70,7 +71,7 @@ fi
|
||||
|
||||
만약, 애플 실리콘 환경에서 Homebrew를 통해 SwiftLint를 설치했다면, 아마도 다음과 같은 경고를 겪었을 것입니다.
|
||||
|
||||
> warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint
|
||||
> warning: SwiftLint not installed, download from <https://github.com/realm/SwiftLint>
|
||||
|
||||
그 이유는, 애플 실리콘 기반 맥에서 Homebrew는 기본적으로 바이너리들을 `/opt/homebrew/bin`에 저장하기 때문입니다. SwiftLint가 어디 있는지 찾는 것을 Xcode에 알려주기 위해, build phase에서 `/opt/homebrew/bin`를 `PATH` 환경 변수에 동시에 추가하여야 합니다.
|
||||
|
||||
@@ -159,7 +160,7 @@ SwiftLint는 SourceKit에 연결되어 있으므로 스위프트 언어가 변
|
||||
|
||||
SwiftLint를 실행할 때는 항상 스위프트 파일을 컴파일하는 동일한 툴체인을 사용해야 합니다.
|
||||
|
||||
설치된 툴체인이나 Xcode가 여러 개인 경우 혹은 스위프트 구 버전을 사용해야 하는 경우(Xcode 8에서 스위프트 2.3 버전을 사용하는 경우)에는 SwiftLint의 기본 스위프트 툴체인을 변경해야 할 수도 있습니다.
|
||||
설치된 툴체인이나 Xcode가 여러 개인 경우 혹은 스위프트 구 버전을 사용해야 하는 경우(Xcode 8에서 스위프트 2.3 버전을 사용하는 경우)에는 SwiftLint의 기본 스위프트 툴체인을 변경해야 할 수도 있습니다.
|
||||
|
||||
SwiftLint가 어느 스위프트 툴체인을 사용할지 결정하는 순서는 다음과 같습니다.
|
||||
|
||||
@@ -176,7 +177,7 @@ SwiftLint가 어느 스위프트 툴체인을 사용할지 결정하는 순서
|
||||
`TOOLCHAINS` 환경 변수에 스위프트 툴체인 버전을 식별할 수 있는 값을 리버스 DNS 형식으로 지정할 수도 있습니다.
|
||||
|
||||
```shell
|
||||
$ TOOLCHAINS=com.apple.dt.toolchain.Swift_2_3 swiftlint autocorrect
|
||||
TOOLCHAINS=com.apple.dt.toolchain.Swift_2_3 swiftlint autocorrect
|
||||
```
|
||||
|
||||
리눅스에서는 SourceKit이 `/usr/lib/libsourcekitdInProc.so` 혹은 `LINUX_SOURCEKIT_LIB_PATH` 환경변수로 지정된 경로에 존재해야 합니다.
|
||||
|
||||
Reference in New Issue
Block a user