UnusedAssign
Identifies variable definitions that aren't used.
Anchor to ExamplesExamples
The following examples contain code snippets that either fail or pass this check.
Anchor to ✗ Fail✗ Fail
{% assign this_variable_is_not_used = 1 %}
Anchor to ✓ Pass✓ Pass
{% assign this_variable_is_used = 1 %}
{% if this_variable_is_used == 1 %}
<span>Hello!</span>
{% endif %}
{% assign _prefixed_ok = 1}
Anchor to OptionsOptions
UnusedAssign
enabledtrue
severity warning
Parameter | Description |
---|---|
enabled | Whether this check is enabled. |
severity | The severity of the check. |
Anchor to Disabling this checkDisabling this check
Variables that are known to be unused can be prefixed by a _
to disable the check. Example:
{% capture _ %}
{% form "cart", cart %}
{% assign posted_successfully = cart.posted_successfully? %}
{% endform %}
{% endcapture %}
{% assign _unused = 'some value' %}
This check is safe to disable.
Was this page helpful?