From 6dc4b86f98380305c79858952222ef0df5ce0e03 Mon Sep 17 00:00:00 2001 From: uabyss <47887646+u-abyss@users.noreply.github.com> Date: Wed, 1 Nov 2023 21:48:49 +0900 Subject: [PATCH] Added viewIsAppearing in viewLifecycleMethodNames (#5316) --- CHANGELOG.md | 4 ++++ .../Rules/Style/TypeContentsOrderRule.swift | 1 + .../Rules/Style/TypeContentsOrderRuleExamples.swift | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a276c0dd7..876ea03743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,10 @@ * Rewrite `duplicate_imports` rule using SwiftSyntax. [JP Simard](https://github.com/jpsim) +* Handle `viewIsAppearing` in the `type_contents_order` rule. + [u-abyss](https://github.com/u-abyss) + [#5259](https://github.com/realm/SwiftLint/issues/5259) + #### Bug Fixes * Fix correction of `explicit_init` rule by keeping significant trivia. diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/TypeContentsOrderRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/TypeContentsOrderRule.swift index 2e3a0ab9f1..1f448ca8a7 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/TypeContentsOrderRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/TypeContentsOrderRule.swift @@ -110,6 +110,7 @@ struct TypeContentsOrderRule: OptInRule { let viewLifecycleMethodNames = [ "loadView(", "loadViewIfNeeded(", + "viewIsAppearing(", "viewDidLoad(", "viewWillAppear(", "viewWillLayoutSubviews(", diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/TypeContentsOrderRuleExamples.swift b/Source/SwiftLintBuiltInRules/Rules/Style/TypeContentsOrderRuleExamples.swift index 45ef5a3ee5..1ea70c3362 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/TypeContentsOrderRuleExamples.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/TypeContentsOrderRuleExamples.swift @@ -78,6 +78,10 @@ internal struct TypeContentsOrderRuleExamples { view2.layoutIfNeeded() hasLayoutedView2 = true } + + override func viewIsAppearing(_ animated: Bool) { + super.viewIsAppearing(animated) + } """, """ // IBActions