Class: Eslintrb::Reporter::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/eslintrb/reporter/default.rb

Instance Method Summary collapse

Instance Method Details

#format(errors, file = nil) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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