IBLinter
IBLinter copied to clipboard
Allow users to define valid UserRuntimeAttributes
At IBAnimatable we have a ton of UIKit subclasses with @IBInspectable
properties. Some of these are String
's and can be very error prone to work with.
Example:
The border property accepts a String
of either: solid
or dash
If the user writes something like dotted
, we should show an error
I think this is possible but the user has to tell us: a) All valid keys b) All classes/subclasses this property is used on
Probably in a .yml
file?
That may seem like a lot of work but if IBAnimatable
were to publish this .yml
file on their docs, it could be reusable.
The idea which validates runtime attributes looks good. But all valid keys and classes definitions make .iblinter.yml
too complex. So we extract the definitions to another file.
IBAnimatable
‘s valid key map .yml
file may be published as IBDecodable
plugin.
decoding UserRuntimeAttributes https://github.com/IBDecodable/IBDecodable/pull/5
I am interested with this feature. I am thinking about generating the file using sourcery if @IBInspectable annotation is accessible. Each framework must provide its own file.
How about having a rule, similar to custom_module_rule
which would take as a param list of files where each IBInspectable
will provide valid values in a comment.
Since IBLiner already has SourceKitten
as a dependency it (probably?) can be done.
...
user_runtime_attributes:
- path_to_file
...
// _blurEffectStyle: ExtraLight, Light, Dark
@IBInspectable var _blurEffectStyle: String? {
didSet {
...
// _borderType: solid, dash
@IBInspectable var _borderType: String? {
didSet {
...