Sha256: b542493c4bda96500848f42346b52560e1e78b235991f39ad202fda4deb65401

Contents?: true

Size: 626 Bytes

Versions: 2

Compression:

Stored size: 626 Bytes

Contents

module Overcommit::Hook::PreCommit
  # Runs `jscs` (JavaScript Code Style Checker) against any modified JavaScript
  # files.
  class Jscs < Base
    def run
      result = execute(%W[#{executable} --reporter=inline --verbose] + applicable_files)
      return :pass if result.success?

      if result.status == 1
        # No configuration was found
        return :warn, result.stderr.chomp
      end

      # example message:
      #   path/to/file.js: line 7, col 0, ruleName: Error message
      extract_messages(
        result.stdout.split("\n"),
        /^(?<file>[^:]+):[^\d]+(?<line>\d+)/,
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
jawshooah-overcommit-0.22.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.21.0 lib/overcommit/hook/pre_commit/jscs.rb