Class: ESLintWebpacker::Warning

Inherits:
Object
  • Object
show all
Defined in:
lib/eslint-webpacker/warning.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, warning_hash) ⇒ Warning

Returns a new instance of Warning.



10
11
12
13
14
15
16
17
18
# File 'lib/eslint-webpacker/warning.rb', line 10

def initialize(filename, warning_hash)
  @filename = filename
  @rule_id = warning_hash['ruleId'] || 'unexpected error'
  @severity = warning_hash['severity']
  @message = warning_hash['message']
  @line = warning_hash['line']
  @column = warning_hash['column']
  @node_type = warning_hash['nodeType']
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



5
6
7
# File 'lib/eslint-webpacker/warning.rb', line 5

def column
  @column
end

#filenameObject (readonly)

Returns the value of attribute filename.



5
6
7
# File 'lib/eslint-webpacker/warning.rb', line 5

def filename
  @filename
end

#lineObject (readonly)

Returns the value of attribute line.



5
6
7
# File 'lib/eslint-webpacker/warning.rb', line 5

def line
  @line
end

#node_typeObject (readonly)

Returns the value of attribute node_type.



5
6
7
# File 'lib/eslint-webpacker/warning.rb', line 5

def node_type
  @node_type
end

Instance Method Details

#locationObject



24
25
26
# File 'lib/eslint-webpacker/warning.rb', line 24

def location
  "#{filename}:#{line}:#{column}"
end

#messageObject



32
33
34
# File 'lib/eslint-webpacker/warning.rb', line 32

def message
  @message || 'N/A'
end

#rule_idObject



28
29
30
# File 'lib/eslint-webpacker/warning.rb', line 28

def rule_id
  @rule_id || 'N/A'
end

#severityObject



20
21
22
# File 'lib/eslint-webpacker/warning.rb', line 20

def severity
  SEVERITY[@severity - 1]
end