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

Version Path
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/coffee_lint.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/coffee_lint.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/coffee_lint.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.46.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.45.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.44.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.43.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.42.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.41.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.40.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.39.1 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.39.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.38.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.37.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.36.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.35.0 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.34.2 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.34.1 lib/overcommit/hook/pre_commit/coffee_lint.rb
overcommit-0.34.0 lib/overcommit/hook/pre_commit/coffee_lint.rb