Sha256: d517dfd1f95819cc5efa507c40b8a66a5cf7baee2211f40f8ba374211166912d

Contents?: true

Size: 762 Bytes

Versions: 2

Compression:

Stored size: 762 Bytes

Contents

module ESLintRails
  class Warning
    attr_reader :filename, :line, :column, :node_type

    SEVERITY = [ :low, :high ].freeze
    private_constant :SEVERITY

    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

    def severity
      SEVERITY[@severity-1]
    end

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eslint-rails-ee-1.0.1 lib/eslint-rails-ee/warning.rb
eslint-rails-ee-1.0 lib/eslint-rails-ee/warning.rb