Class: ThemeCheck::ParserBlockingJavaScript

Inherits:
LiquidCheck show all
Includes:
RegexHelpers
Defined in:
lib/theme_check/checks/parser_blocking_javascript.rb

Overview

Reports errors when trying to use parser-blocking script tags

Constant Summary collapse

PARSER_BLOCKING_SCRIPT_TAG =
%r{
  <script                                    # Find the start of a script tag
  (?=[^>]+?src=)                             # Make sure src= is in the script with a lookahead
  (?:(?!defer|async|type=["']module['"]).)*? # Find tags that don't have defer|async|type="module"
  /?>
}xim
SCRIPT_TAG_FILTER =
/\{\{[^}]+script_tag\s+\}\}/

Constants inherited from LiquidCheck

LiquidCheck::ATTR, LiquidCheck::HTML_ATTRIBUTE, LiquidCheck::HTML_ATTRIBUTES, LiquidCheck::QUOTED_LIQUID_ATTRIBUTE, LiquidCheck::START_OR_END_QUOTE, LiquidCheck::TAG, LiquidCheck::VARIABLE

Constants inherited from Check

Check::CATEGORIES, Check::SEVERITIES

Instance Attribute Summary

Attributes inherited from Check

#offenses, #options, #theme

Instance Method Summary collapse

Methods included from RegexHelpers

#matches

Methods inherited from LiquidCheck

#add_offense

Methods included from ChecksTracking

#inherited

Methods included from ParsingHelpers

#outside_of_strings

Methods inherited from Check

all, can_disable, #can_disable?, categories, #categories, category, #code_name, #doc, doc, docs_url, #ignore!, #ignored?, #severity, severity, #to_s, #unignore!

Methods included from JsonHelpers

#format_json_parse_error

Instance Method Details

#on_document(node) ⇒ Object



18
19
20
21
22
# File 'lib/theme_check/checks/parser_blocking_javascript.rb', line 18

def on_document(node)
  @source = node.template.source
  @node = node
  record_offenses
end