Sha256: 0401cbf1ed2636c3c1bc24a12f6397d061ca85c19294d1b70f46bc3b8ece53f2
Contents?: true
Size: 851 Bytes
Versions: 12
Compression:
Stored size: 851 Bytes
Contents
# frozen_string_literal: true module Overcommit::Hook::PreCommit # Runs `coffeelint` against any modified CoffeeScript files. # # @see http://www.coffeelint.org/ class CoffeeLint < Base MESSAGE_REGEX = / ^(?<file>.+) ,(?<line>\d*),\d* ,(?<type>\w+) ,(?<msg>.+)$ /x.freeze MESSAGE_TYPE_CATEGORIZER = lambda do |type| type.include?('w') ? :warning : :error end def run result = execute(command, args: applicable_files) parse_messages(result.stdout) end private def parse_messages(output) output.scan(MESSAGE_REGEX).map do |file, line, type, msg| line = line.to_i type = MESSAGE_TYPE_CATEGORIZER.call(type) text = "#{file}:#{line}:#{type} #{msg}" Overcommit::Hook::Message.new(type, file, line, text) end end end end
Version data entries
12 entries across 12 versions & 2 rubygems