Module: ThemeCheck

Defined in:
lib/theme_check/disabled_check.rb,
lib/theme_check.rb,
lib/theme_check/bug.rb,
lib/theme_check/cli.rb,
lib/theme_check/node.rb,
lib/theme_check/tags.rb,
lib/theme_check/check.rb,
lib/theme_check/theme.rb,
lib/theme_check/checks.rb,
lib/theme_check/config.rb,
lib/theme_check/offense.rb,
lib/theme_check/printer.rb,
lib/theme_check/storage.rb,
lib/theme_check/version.rb,
lib/theme_check/visitor.rb,
lib/theme_check/analyzer.rb,
lib/theme_check/packager.rb,
lib/theme_check/position.rb,
lib/theme_check/releaser.rb,
lib/theme_check/template.rb,
lib/theme_check/corrector.rb,
lib/theme_check/html_node.rb,
lib/theme_check/json_file.rb,
lib/theme_check/asset_file.rb,
lib/theme_check/exceptions.rb,
lib/theme_check/html_check.rb,
lib/theme_check/json_check.rb,
lib/theme_check/theme_file.rb,
lib/theme_check/locale_diff.rb,
lib/theme_check/html_visitor.rb,
lib/theme_check/json_helpers.rb,
lib/theme_check/liquid_check.rb,
lib/theme_check/regex_helpers.rb,
lib/theme_check/string_helpers.rb,
lib/theme_check/checks_tracking.rb,
lib/theme_check/disabled_checks.rb,
lib/theme_check/language_server.rb,
lib/theme_check/parsing_helpers.rb,
lib/theme_check/position_helper.rb,
lib/theme_check/checks/liquid_tag.rb,
lib/theme_check/checks/valid_json.rb,
lib/theme_check/in_memory_storage.rb,
lib/theme_check/remote_asset_file.rb,
lib/theme_check/shopify_liquid/tag.rb,
lib/theme_check/checks/remote_asset.rb,
lib/theme_check/checks/syntax_error.rb,
lib/theme_check/checks/valid_schema.rb,
lib/theme_check/file_system_storage.rb,
lib/theme_check/checks/unused_assign.rb,
lib/theme_check/checks/asset_size_css.rb,
lib/theme_check/checks/default_locale.rb,
lib/theme_check/checks/nested_snippet.rb,
lib/theme_check/checks/unknown_filter.rb,
lib/theme_check/checks/unused_snippet.rb,
lib/theme_check/shopify_liquid/filter.rb,
lib/theme_check/shopify_liquid/object.rb,
lib/theme_check/checks/template_length.rb,
lib/theme_check/language_server/server.rb,
lib/theme_check/language_server/tokens.rb,
lib/theme_check/checks/img_lazy_loading.rb,
lib/theme_check/checks/missing_template.rb,
lib/theme_check/checks/undefined_object.rb,
lib/theme_check/language_server/handler.rb,
lib/theme_check/checks/asset_url_filters.rb,
lib/theme_check/checks/deprecate_bgsizes.rb,
lib/theme_check/checks/deprecated_filter.rb,
lib/theme_check/language_server/protocol.rb,
lib/theme_check/checks/html_parsing_error.rb,
lib/theme_check/language_server/constants.rb,
lib/theme_check/checks/deprecate_lazysizes.rb,
lib/theme_check/checks/space_inside_braces.rb,
lib/theme_check/checks/img_width_and_height.rb,
lib/theme_check/checks/required_directories.rb,
lib/theme_check/checks/asset_size_javascript.rb,
lib/theme_check/checks/matching_translations.rb,
lib/theme_check/checks/missing_enable_comment.rb,
lib/theme_check/checks/translation_key_exists.rb,
lib/theme_check/checks/valid_html_translation.rb,
lib/theme_check/checks/asset_size_app_block_css.rb,
lib/theme_check/checks/convert_include_to_render.rb,
lib/theme_check/shopify_liquid/deprecated_filter.rb,
lib/theme_check/checks/parser_blocking_javascript.rb,
lib/theme_check/checks/parser_blocking_script_tag.rb,
lib/theme_check/language_server/completion_engine.rb,
lib/theme_check/language_server/completion_helper.rb,
lib/theme_check/checks/matching_schema_translations.rb,
lib/theme_check/checks/required_layout_theme_object.rb,
lib/theme_check/language_server/completion_provider.rb,
lib/theme_check/language_server/diagnostics_tracker.rb,
lib/theme_check/checks/asset_size_css_stylesheet_tag.rb,
lib/theme_check/language_server/document_link_engine.rb,
lib/theme_check/checks/asset_size_app_block_javascript.rb,
lib/theme_check/checks/content_for_header_modification.rb,
lib/theme_check/checks/missing_required_template_files.rb,
lib/theme_check/language_server/variable_lookup_finder.rb,
lib/theme_check/language_server/completion_providers/tag_completion_provider.rb,
lib/theme_check/language_server/completion_providers/filter_completion_provider.rb,
lib/theme_check/language_server/completion_providers/object_completion_provider.rb,
lib/theme_check/language_server/completion_providers/render_snippet_completion_provider.rb

Overview

Here we define the Language Server Protocol Constants we’re using. For complete docs, see the following: microsoft.github.io/language-server-protocol/specifications/specification-current

Defined Under Namespace

Modules: ChecksTracking, JsonHelpers, LanguageServer, ParsingHelpers, PositionHelper, RegexHelpers, ShopifyLiquid, StringHelpers, SystemTranslations, Tags Classes: Analyzer, AssetFile, AssetSizeAppBlockCSS, AssetSizeAppBlockJavaScript, AssetSizeCSS, AssetSizeCSSStylesheetTag, AssetSizeJavaScript, AssetUrlFilters, Check, Checks, Cli, Config, ContentForHeaderModification, ConvertIncludeToRender, Corrector, DefaultLocale, DeprecateBgsizes, DeprecateLazysizes, DeprecatedFilter, DisabledCheck, DisabledChecks, FileSystemStorage, HtmlCheck, HtmlNode, HtmlParsingError, HtmlVisitor, ImgLazyLoading, ImgWidthAndHeight, InMemoryStorage, JsonCheck, JsonFile, LiquidCheck, LiquidTag, LocaleDiff, MatchingSchemaTranslations, MatchingTranslations, MissingEnableComment, MissingRequiredTemplateFiles, MissingTemplate, NestedSnippet, Node, Offense, Packager, ParserBlockingJavaScript, ParserBlockingScriptTag, Position, Printer, Releaser, RemoteAsset, RemoteAssetFile, RequiredDirectories, RequiredLayoutThemeObject, SpaceInsideBraces, Storage, SyntaxError, Template, TemplateLength, Theme, ThemeCheckError, ThemeFile, Token, Tokens, TranslationKeyExists, UndefinedObject, UnknownFilter, UnusedAssign, UnusedSnippet, ValidHTMLTranslation, ValidJson, ValidSchema, Visitor

Constant Summary collapse

BUG_POSTAMBLE =
<<~EOS
  Theme Check Version: #{VERSION}
  Ruby Version: #{RUBY_VERSION}
  Platform: #{RUBY_PLATFORM}
  Muffin mode: activated

  ------------------------
  Whoops! It looks like you found a bug in Theme Check.
  Please report it at https://github.com/Shopify/theme-check/issues, and include the message above.
  Or cross your fingers real hard, and try again.
EOS
VERSION =
"1.2.0"
TIMEOUT_EXCEPTIONS =
[
  Net::ReadTimeout,
  Net::OpenTimeout,
  Net::WriteTimeout,
  Errno::ETIMEDOUT,
  Timeout::Error,
]
CONNECTION_EXCEPTIONS =
[
  IOError,
  EOFError,
  SocketError,
  Errno::EINVAL,
  Errno::ECONNRESET,
  Errno::ECONNABORTED,
  Errno::EPIPE,
  Errno::ECONNREFUSED,
  Errno::EAGAIN,
  Errno::EHOSTUNREACH,
  Errno::ENETUNREACH,
]
NET_HTTP_EXCEPTIONS =
[
  Net::HTTPBadResponse,
  Net::HTTPHeaderSyntaxError,
  Net::ProtocolError,
  *TIMEOUT_EXCEPTIONS,
  *CONNECTION_EXCEPTIONS,
]
TAG_START =
Liquid::TagStart
TAG_END =
Liquid::TagEnd
VARIABLE_START =
Liquid::VariableStart
VARIABLE_END =
Liquid::VariableEnd
SPLITTER =
%r{
  (?=(?:#{TAG_START}|#{VARIABLE_START}))| # positive lookahead on tag/variable start
  (?<=(?:#{TAG_END}|#{VARIABLE_END}))     # positive lookbehind on tag/variable end
}xom

Class Method Summary collapse

Class Method Details

.bug(message) ⇒ Object

Raises:



19
20
21
# File 'lib/theme_check/bug.rb', line 19

def self.bug(message)
  raise ThemeCheckError, message + BUG_POSTAMBLE
end

.with_liquid_c_disabledObject



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/theme_check.rb', line 51

def self.with_liquid_c_disabled
  if defined?(Liquid::C)
    was_enabled = Liquid::C.enabled
    Liquid::C.enabled = false if was_enabled
  end
  yield
ensure
  if defined?(Liquid::C) && was_enabled
    Liquid::C.enabled = true
  end
end