Closed masamichiueta closed 5 years ago
@kateinoigakukun Thank you for your quick review!
this rule can't work for inherited class because IB doesn't know about Swift type information
[Q] What do you mean about inherited class
?
@masamichiueta Oh, I misunderstood 😅. I mean PrimaryLabel
can be inherited.
Do you think that CustomizedPrimaryLabel
should be invalid? If so, it's my misunderstanding and you don't need to change README
class PrimaryLabel: UILabel {
...
}
class CustomizedPrimaryLabel: PrimaryLabel {
...
}
I understand! As you said, this rule does not work for inherited classes. A developer needs to add the inherited classes to base_classes
in yml.
I add caution on rule description👍
Updated. Please review again🙏
This PR is a proposal of a new rule,
UseBaseClass
.What is
UseBaseClass
rule?UseBaseClass
rule is a rule to check whether an UI element uses custom class which is set as base class in config.For example, if we have some base classes of
UILabel
likePrimaryLabel
andSecondaryLabel
that should be applied to all labels through the project, this rule checks whether labels in storyboards and xibs are set to base classes.Why is this rule required?
As I describe above, many apps commonly have their own base UI components. But we often forget to set the custom class to the base classes in storyboard or xib. And new members often overlook the base components.
This rule can prevent the problem and this is the reason why I developed this rule.
How does it work?
Set
element_class
andbase_classes
in config likeThis enables to check
UILabel
usesPrimaryLabel
orSecondaryLabel
. IfUILabel
does not use the base classes, Xcode shows warnings like below.