Sha256: 5eb49a34fe7d065c67caa83546b47f16a44b222a7cccab29e863bc5cf896cbbd

Contents?: true

Size: 691 Bytes

Versions: 6

Compression:

Stored size: 691 Bytes

Contents

require 'json'

module SCSSLint
  # Reports lints in a JSON format.
  class Reporter::JSONReporter < Reporter
    def report_lints
      output = {}
      lints.group_by(&:filename).each do |filename, file_lints|
        output[filename] = file_lints.map do |lint|
          issue_hash(lint)
        end
      end
      JSON.pretty_generate(output)
    end

  private

    def issue_hash(lint)
      {
        'line' => lint.location.line,
        'column' => lint.location.column,
        'length' => lint.location.length,
        'severity' => lint.severity,
        'reason' => lint.description,
      }.tap do |hash|
        hash['linter'] = lint.linter.name
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
scss_lint-0.60.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.59.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.58.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.57.1 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.57.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.56.0 lib/scss_lint/reporter/json_reporter.rb