Images should not trigger a violation for layer-styles-prefer-shared rule
konki-vienna opened this issue · 4 comments
Layer type 'Image' should probably be added to IGNORE_CLASSES
.
https://github.com/sketch-hq/sketch-assistants/blob/main/assistants/core/src/rules/layer-styles-prefer-shared/index.ts#L14
Rather than completely ignore image layers, perhaps what we'd rather do is ignore image layers that have default styles?
Rather than completely ignore image layers, perhaps what we'd rather do is ignore image layers that have default styles?
Yes, that would be possibly preferred. What is the best way to check if an image layer has modified styles (=non-default styles)? 🤔
Is it like here (replacing "group" with "image"): https://github.com/sketch-hq/sketch-assistants/blob/main/assistants/core/src/rules/layer-styles-prefer-shared/index.ts#L26
@konki-vienna Yeah - exactly. I don't think we have a perfect/explicit way to identify whether a layer still has a default style, it'll just be a case of figuring out what the default style object Sketch gives image layers looks like and checking for it it with some sort of basic heuristic. Should be good enough to be useful in all but the most weird edge cases.
In other words: Is the layer an image layer, and does it have a style that looks as if its default? If so escape the loop with continue
.
Already merged, good to close.