Sha256: 91c229c588d1c9246e4d921eacb15c2b10609d49b5db71f68a42388081f8b43a

Contents?: true

Size: 658 Bytes

Versions: 9

Compression:

Stored size: 658 Bytes

Contents

# frozen_string_literal: true

module Overcommit::Hook::PreCommit
  # Runs `semistandard` against any modified JavaScript files.
  #
  # @see https://github.com/Flet/semistandard
  class SemiStandard < Base
    MESSAGE_REGEX = /^\s*(?<file>(?:\w:)?[^:]+):(?<line>\d+)/.freeze

    def run
      result = execute(command, args: applicable_files)
      output = result.stdout.chomp
      return :pass if result.success? && output.empty?

      # example message:
      #   path/to/file.js:1:1: Error message (ruleName)
      extract_messages(
        output.split("\n").grep(MESSAGE_REGEX), # ignore header line
        MESSAGE_REGEX
      )
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
overcommit-0.64.1 lib/overcommit/hook/pre_commit/semi_standard.rb
overcommit-0.64.0 lib/overcommit/hook/pre_commit/semi_standard.rb
overcommit-0.63.0 lib/overcommit/hook/pre_commit/semi_standard.rb
overcommit-0.62.0 lib/overcommit/hook/pre_commit/semi_standard.rb
overcommit-0.61.0 lib/overcommit/hook/pre_commit/semi_standard.rb
overcommit-0.60.0 lib/overcommit/hook/pre_commit/semi_standard.rb
overcommit-0.59.1 lib/overcommit/hook/pre_commit/semi_standard.rb
overcommit-0.59.0 lib/overcommit/hook/pre_commit/semi_standard.rb
overcommit-jeygeethanmedia-0.58.0 lib/overcommit/hook/pre_commit/semi_standard.rb