class Eslintrb::Reporter::Default

Public Instance Methods

format(errors, file = nil) click to toggle source
# File lib/eslintrb/reporter/default.rb, line 5
def format(errors, file = nil)
  result = ''
  indent = ''
  if file then
    indent = '  '
  end

  errors.each do |error|
    if error.nil? then
      result += indent + 'fatal error'
    else
      result += indent + 'line ' + error["line"].to_s + ', col ' +
        error["column"].to_s + ', ' + error["message"].to_s + "\n"
    end
  end

  if file && result.size > 0 then
    result = 'file: ' + file + "\n" + result
  end

  result
end