Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False Positive "Variable Assigned but Not Used" in Style Tags #465

Open
thagxt opened this issue Aug 4, 2024 · 1 comment
Open

False Positive "Variable Assigned but Not Used" in Style Tags #465

thagxt opened this issue Aug 4, 2024 · 1 comment
Labels
Bug Something isn't working moderate lowest severity for theme related bug

Comments

@thagxt
Copy link

thagxt commented Aug 4, 2024

Description:

Theme check is incorrectly identifying variables assigned or captured within a {% liquid %} tag as assigned but not used. This occurs even though the variables are then used with echo withinstyle .

Steps to Reproduce:

  1. Create a Liquid template file.
  2. Inside a style {% liquid %} tag:
    • Assign a variable using {% assign shopName = shop.name %}.
    • Capture content using {% capture example %} and echo 'Shopify' {% endcapture %}.
    • Use echo to output the captured content (echo example) and the assigned variable (echo shopName).
  3. Run the linter or theme check.

Expected Behavior:

The linter should not report any errors for the assigned or captured variables since they are used within the style tag.

Actual Behavior:

The linter flags an error message stating "The variable is assigned but not used."

Source Code:

{%- liquid
                              
assign shopName = shop.name

capture example
  echo 'Shopify'
endcapture
                            
 style
  echo example
  echo shopName
endstyle
-%}

Additional Information:

  • OS: Mac
  • OS Version: Latest
  • Theme Check Version: Latest

Additional context
Screenshot 2024-08-04 at 12 49 56

@mgmanzella mgmanzella added Bug Something isn't working moderate lowest severity for theme related bug labels Aug 9, 2024
@mgmanzella
Copy link
Contributor

mgmanzella commented Aug 9, 2024

👋 thanks for reporting, im able to repro and it seems related to style/endstyle being used around the variable example. when i remove that liquid, the linter stops returning that error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working moderate lowest severity for theme related bug
Projects
None yet
Development

No branches or pull requests

2 participants