Sha256: 14a61ccbc465481a30bf4c56d1df9aa18d2479cac9149aa81c0be7ff6398691f

Contents?: true

Size: 546 Bytes

Versions: 2

Compression:

Stored size: 546 Bytes

Contents

module Overcommit::Hook::PreCommit
  # Runs `slim-lint` against any modified Slim templates.
  #
  # @see https://github.com/sds/slim-lint
  class SlimLint < Base
    MESSAGE_TYPE_CATEGORIZER = lambda do |type|
      type.include?('W') ? :warning : :error
    end

    def run
      result = execute(command + applicable_files)
      return :pass if result.success?

      extract_messages(
        result.stdout.split("\n"),
        /^(?<file>[^:]+):(?<line>\d+)[^ ]* (?<type>[^ ]+)/,
        MESSAGE_TYPE_CATEGORIZER,
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
overcommit-0.27.0 lib/overcommit/hook/pre_commit/slim_lint.rb
overcommit-0.26.0 lib/overcommit/hook/pre_commit/slim_lint.rb