check: ParserBlockingScript
severity: error
cases:
- name: should report the correct offense for the Liquid filter
files:
code.liquid: "{{ 'asset' | script_tag }}"
offenses:
- file: code.liquid
message: The script_tag filter is parser-blocking. Use a "
- message: Use an HTML script tag with the async attribute instead
result: ""
- name: should report the correct offense when using the script tag
files:
code.liquid: |
offenses:
- file: code.liquid
message: "Avoid parser blocking scripts by adding `defer` or `async` on this tag"
start: [0, 0]
highlight: ''
suggest:
- message: Use an HTML script tag with the defer attribute instead
result: |
- message: Use an HTML script tag with the async attribute instead
result: |
- name: should suggest to replace a LiquidVariableOutput with a script tag that has the expression as URL
files:
code.liquid: "{{ 'asset' | script_tag }}"
offenses:
- file: code.liquid
message: The script_tag filter is parser-blocking. Use a "
- message: Use an HTML script tag with the async attribute instead
result: ""
- name: should suggest to replace a LiquidVariableOutput with a script tag that has the expression and previous filters as URL
files:
code.liquid: "{{ 'asset' | asset_url | script_tag }}"
offenses:
- file: code.liquid
message: The script_tag filter is parser-blocking. Use a "
- message: Use an HTML script tag with the async attribute instead
result: ""
- name: should not suggest anything if the script_tag appears in an echo tag
files:
code.liquid: "{% echo 'asset' | asset_url | script_tag %}"
offenses:
- file: code.liquid
message: The script_tag filter is parser-blocking. Use a '
offenses:
- file: code.liquid
message: "Avoid parser blocking scripts by adding `defer` or `async` on this tag"
start: [0, 0]
highlight: ''
suggest:
- message: Use an HTML script tag with the defer attribute instead
result: ''
- message: Use an HTML script tag with the async attribute instead
result: ''
- name: should not report any offense when async is set on a script tag
files:
code.liquid: |
- name: should not report any offense when defer is set on a script tag
files:
code.liquid: |
- name: should not report any offense when async and defer are set on a script tag
files:
code.liquid: |
- name: should not report any offense when using scripts of type module
files:
code.liquid: |