Shopify / theme-check

The Ultimate Shopify Theme Linter
Other
337 stars 95 forks source link

Unused Snippets are not being detected in 1.10.2 #573

Closed wrainbird closed 2 years ago

wrainbird commented 2 years ago

I have installed Shopify CLI with Theme Check (version 1.10.2) - and am not getting errors for Unused Snippets.

I have been creating Snippets on purpose in the snippets directory that aren't being used - but when I run 'theme check' I am getting no errors:

0 offenses detected, 0 offenses auto-correctable

Am I doing something wrong? I have a .theme-check.yml file but it is pretty basic (I am enabling Unused Snippet here just to double check):

ignore:
  - _src
  - _schema
  - _sections
  - node_modules/*

# Enable a custom check
ClassPartials:
  enabled: false

UnusedSnippet:
  enabled: true
  severity: error

Let me know if there is any other information I can provide to assist with this.

charlespwd commented 2 years ago

Oh. So I just found out that we turn off the check (silently) when an expression is used in an render(or include) expression.

Which, I suspect, you do if you have an OS2 theme (since all it takes is one {% render block %} for this tripwire to be triggered).

I'll flag this as a bug and add it to our backlog as I don't have time to fix it right now.

wrainbird commented 2 years ago

@charlespwd thanks for responding to this.

The only dynamic snippet I render for OS2 themes is for app blocks, e.g.:

{% when '@app' %}
{% render block %}

I removed that code temporarily and was able to find unused snippets. Thanks!