theme-tools icon indicating copy to clipboard operation
theme-tools copied to clipboard

Theme Check rule to warn against using hard coded block id

Open bahar-p opened this issue 1 year ago • 1 comments

We've updated the docs to warn against relying on hard coded block ids. In additional to that it'd still be very valuable to have a theme check rule to warn against this usage as people author liquid code. See this document for examples of this.

bahar-p avatar Jul 25 '24 12:07 bahar-p

👋🏻 @bahar-p Moving this to theme-tools, where the current version of theme check lives. This ruby version is being archived

lukeh-shopify avatar Jul 27 '24 00:07 lukeh-shopify

Bahar: Keep in mind though the pattern goes beyond just {% if block.id %} - It could be with case/when statement or {% unless % or even with assign {%- assign block_id = block.id -%} ... The comparison logic here that uses block_id ... The assign could get complicated to detect. Check with @charlespwd on that These are the ways that comes to my mind. Check with @datamatt too because he used these patterns to find the hard coded id usages for app blocks to see if there's any other way aside from ^^ that he might have checked for if unless case/when assign with var

miazbikowski avatar Nov 13 '24 20:11 miazbikowski

Will ship with next release.

miazbikowski avatar Nov 18 '24 21:11 miazbikowski