Sha256: 10854c8a2c59fb3aca7e784d4c589d911ec7b48d35442c2de2fa0e9fbf0808f2
Contents?: true
Size: 745 Bytes
Versions: 28
Compression:
Stored size: 745 Bytes
Contents
module Overcommit::Hook::PreCommit # Runs `jsl` against any modified JavaScript files. # # @see http://www.javascriptlint.com/ class Jsl < Base MESSAGE_REGEX = /(?<file>(?:\w:)?.+)\((?<line>\d+)\):(?<type>[^:]+)/ MESSAGE_TYPE_CATEGORIZER = lambda do |type| type =~ /warning/ ? :warning : :error end def run file_flags = applicable_files.map { |file| ['-process', file] } result = execute(command + file_flags.flatten) return :pass if result.success? # example message: # path/to/file.js(1): lint warning: Error message extract_messages( result.stdout.split("\n").grep(MESSAGE_REGEX), MESSAGE_REGEX, MESSAGE_TYPE_CATEGORIZER ) end end end
Version data entries
28 entries across 26 versions & 2 rubygems