Sha256: 1fe3ef00bee4ab06f33919099e5e4cefc27215543b8762b7ac3c8514baac770e

Contents?: true

Size: 706 Bytes

Versions: 37

Compression:

Stored size: 706 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 if lint.linter
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 3 rubygems

Version Path
scss_lint-0.55.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.54.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.53.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.52.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.51.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.50.3 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.50.2 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.50.1 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.50.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.49.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.48.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.47.1 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.47.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.46.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.45.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.44.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.43.2 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.43.1 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.43.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.42.2 lib/scss_lint/reporter/json_reporter.rb