Sha256: 4b97c75c70922e0c638760bf42b1eb35509d834fd24ce36f6b06aa20cfe3ac10
Contents?: true
Size: 813 Bytes
Versions: 20
Compression:
Stored size: 813 Bytes
Contents
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 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
20 entries across 18 versions & 2 rubygems