Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Do something about the UnusedAssign fixer and formatOnSave: true #597

Closed
jonXmack opened this issue Jun 24, 2022 · 3 comments
Closed

Do something about the UnusedAssign fixer and formatOnSave: true #597

jonXmack opened this issue Jun 24, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@jonXmack
Copy link

When running the auto correct flag on theme check it's stripping content from the final when. Two examples below:

Before

  {% case image_container_width %}
    {% when 'small' %}
      {%- assign product_image_width = 'medium-up--two-fifths' -%}
      {%- assign product_description_width = 'medium-up--three-fifths' -%}
      {%- assign product_image_size = '480x' -%}
    {% when 'medium' %}
      {%- assign product_image_width = 'medium-up--one-half' -%}
      {%- assign product_description_width = 'medium-up--one-half' -%}
      {%- assign product_image_size = '620x' -%}
    {% when 'large' %}
      {%- assign product_image_width = 'medium-up--three-fifths' -%}
      {%- assign product_description_width = 'medium-up--two-fifths' -%}
      {%- assign product_image_size = '740x' -%}
  {% endcase %}

After

  {% case image_container_width %}
    {% when 'small' %}
      {%- assign product_image_width = 'medium-up--two-fifths' -%}
      {%- assign product_description_width = 'medium-up--three-fifths' -%}
      {%- assign product_image_size = '480x' -%}
    {% when 'medium' %}
      {%- assign product_image_width = 'medium-up--one-half' -%}
      {%- assign product_description_width = 'medium-up--one-half' -%}
      {%- assign product_image_size = '620x' -%}
    {% when 'large' %}
      
      
      {%- assign product_image_size = '740x' -%}
  {% endcase %}

Before

  {% case section.settings.grid %}
    {% when '1' %}
      {%- assign grid_item_width = '' -%}
    {% when '2' %}
      {%- assign grid_item_width = 'medium-up--one-half' -%}
    {% when '3' %}
      {%- assign grid_item_width = 'small--one-half medium-up--one-third' -%}
    {% when '4' %}
      {%- assign grid_item_width = 'small--one-half medium-up--one-quarter' -%}
    {% when '5' %}
      {%- assign grid_item_width = 'small--one-half medium-up--one-fifth' -%}
  {% endcase %}

After

  {% case section.settings.grid %}
    {% when '1' %}
      {%- assign grid_item_width = '' -%}
    {% when '2' %}
      {%- assign grid_item_width = 'medium-up--one-half' -%}
    {% when '3' %}
      {%- assign grid_item_width = 'small--one-half medium-up--one-third' -%}
    {% when '4' %}
      {%- assign grid_item_width = 'small--one-half medium-up--one-quarter' -%}
    {% when '5' %}
      
  {% endcase %}

I can't see any reason for the variables to be removed, if I check the settings schema for the grid it has those options in, yet the variable is being removed?

    {
      "type": "select",
      "id": "grid",
      "label": "Collections per row",
      "default": "3",
      "options": [
        {
          "value": "1",
          "label": "1"
        },
        {
          "value": "2",
          "label": "2"
        },
        {
          "value": "3",
          "label": "3"
        },
        {
          "value": "4",
          "label": "4"
        },
        {
          "value": "5",
          "label": "5"
        }
      ]
    }
@charlespwd charlespwd added bug Something isn't working p:high Priority (or Impact): High labels Jul 11, 2022
@charlespwd charlespwd self-assigned this Jul 14, 2022
@charlespwd charlespwd added enhancement New feature or request and removed bug Something isn't working p:high Priority (or Impact): High labels Jul 18, 2022
@charlespwd charlespwd changed the title Final case/when tag being stripped of content during auto correct Do something about the UnusedAssign fixer and formatOnSave: true Jul 18, 2022
@charlespwd
Copy link
Contributor

Oh wow... What's happening here is that you have an UnusedAssign and that it's being corrected (but only on the last assign). If you rerun the corrector, it'll start happening in the other branches.

I don't know if that's still a bug or how we should fix it. But I kind of agree that you might not want this feature to run with the fixer setup with formatOnSave: true...

In the meantime, the proper course of action would be to disable the check:

{% comment %}theme-check-disable UnusedAssign{% endcomment %}

Or in your .theme-check.yml

UnusedAssign:
  enabled: false

@charlespwd charlespwd removed their assignment Jul 22, 2022
@lukeh-shopify
Copy link
Contributor

👋🏻 Hi @jonXmack! Thanks for reporting this. Unfortunately the Ruby version of theme check has been deprecated for some time. Would you be able to confirm you are still having issues when using our maintained version of theme check? This is done using either the latest version of the Shopify CLI, or via the Shopify Liquid Visual Studio Code extension.

If you are still having issues, please raise an issue over in the CLI or theme tools repositories. Thanks!

@jonXmack
Copy link
Author

@lukeh-shopify I raised this over 2 years ago and as such am no longer having the issue. Thanks for checking in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants