Sha256: f982f2138fca16b304254b4c28f482c9d9837eaffcbe00703bbdd416980ff2c4

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true
require_relative "parsing_helpers"

module ThemeCheck
  class LiquidCheck < Check
    extend ChecksTracking
    include ParsingHelpers

    TAG = /#{Liquid::TagStart}.*?#{Liquid::TagEnd}/om
    VARIABLE = /#{Liquid::VariableStart}.*?#{Liquid::VariableEnd}/om
    START_OR_END_QUOTE = /(^['"])|(['"]$)/
    QUOTED_LIQUID_ATTRIBUTE = %r{
      '(?:#{TAG}|#{VARIABLE}|[^'])*'| # any combination of tag/variable or non straight quote inside straight quotes
      "(?:#{TAG}|#{VARIABLE}|[^"])*"  # any combination of tag/variable or non double quotes inside double quotes
    }omix
    ATTR = /[a-z0-9-]+/i
    HTML_ATTRIBUTE = /#{ATTR}(?:=#{QUOTED_LIQUID_ATTRIBUTE})?/omix
    HTML_ATTRIBUTES = /(?:#{HTML_ATTRIBUTE}|\s)*/omix

    def add_offense(message, node: nil, template: node&.template, markup: nil, line_number: nil, &block)
      offenses << Offense.new(check: self, message: message, template: template, node: node, markup: markup, line_number: line_number, correction: block)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
theme-check-0.8.3 lib/theme_check/liquid_check.rb
theme-check-0.8.2 lib/theme_check/liquid_check.rb
theme-check-0.8.1 lib/theme_check/liquid_check.rb
theme-check-0.8.0 lib/theme_check/liquid_check.rb
theme-check-0.7.3 lib/theme_check/liquid_check.rb
theme-check-0.7.2 lib/theme_check/liquid_check.rb
theme-check-0.7.1 lib/theme_check/liquid_check.rb
theme-check-0.7.0 lib/theme_check/liquid_check.rb
theme-check-0.6.0 lib/theme_check/liquid_check.rb