class Overcommit::Hook::PreCommit::TsLint

Runs `tslint` against modified TypeScript files. @see palantir.github.io/tslint/

Constants

MESSAGE_REGEX

example message: “src/file/anotherfile.ts[298, 1]: exceeds maximum line length of 140” or “ERROR: src/AccountController.ts[4, 28]: expected call-signature to have a typedef”

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/ts_lint.rb, line 13
def run
  result = execute(command, args: applicable_files)
  output = result.stdout.chomp
  return :pass if result.success? && output.empty?

  output_lines = output.split("\n").map(&:strip).reject(&:empty?)
  type_categorizer = ->(type) { type.nil? || type.include?('ERROR') ? :error : :warning }

  extract_messages(
      output_lines,
      MESSAGE_REGEX,
      type_categorizer
  )
end