Shopify / theme-check

The Ultimate Shopify Theme Linter
Other
333 stars 96 forks source link

Variables used *before* assign should throw an error. #752

Open ConduciveMammal opened 6 months ago

ConduciveMammal commented 6 months ago

Describe the bug

There's a check for undefined variables which works well, but all it seems to be doing is checking for the existence of an assignment, not the validity of the assignment.

Currently, I can attempt to access a variable before it's been assigned and it's considered valid.

If you look in ESLint, this would throw an undefined error.

Expected

{{ cool }}
{% assign cool = true %}
// Variable "cool" used before being assigned.

Actual

{{ cool }}
{% assign cool = true %}
// Totally cool 👍🏻 

Debugging information

CleanShot 2023-12-13 at 4  50 33@2x CleanShot 2023-12-13 at 4  51 31@2x