Sha256: 1ccb5616005668c2c48dec8188a2331477d82c57fec246db516e6231cb1206b8

Contents?: true

Size: 764 Bytes

Versions: 27

Compression:

Stored size: 764 Bytes

Contents

module Overcommit::Hook::PreCommit
  # Runs `jscs` (JavaScript Code Style Checker) against any modified JavaScript
  # files.
  #
  # @see http://jscs.info/
  class Jscs < Base
    def run
      result = execute(command, args: applicable_files)
      return :pass if result.success?

      # Exit status 2 = Code style errors; everything else we don't know how to
      # parse. https://github.com/jscs-dev/node-jscs/wiki/Exit-codes
      unless result.status == 2
        return :fail, result.stdout + result.stderr.chomp
      end

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

Version data entries

27 entries across 25 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/jscs.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/jscs.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/jscs.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/jscs.rb
overcommit-0.46.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.45.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.44.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.43.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.42.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.41.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.40.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.39.1 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.39.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.38.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.37.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.36.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.35.0 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.34.2 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.34.1 lib/overcommit/hook/pre_commit/jscs.rb
overcommit-0.34.0 lib/overcommit/hook/pre_commit/jscs.rb