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.42.1 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.42.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.41.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.40.1 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.40.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.39.0 lib/scss_lint/reporter/json_reporter.rb
scss_lint-0.38.0 lib/scss_lint/reporter/json_reporter.rb
scss-lint-0.38.0 lib/scss_lint/reporter/json_reporter.rb
scss-lint-bliss-1.0.0 lib/scss_lint/reporter/json_reporter.rb
scss-lint-0.37.0 lib/scss_lint/reporter/json_reporter.rb
scss-lint-0.36.1 lib/scss_lint/reporter/json_reporter.rb
scss-lint-0.36.0 lib/scss_lint/reporter/json_reporter.rb
scss-lint-0.35.0 lib/scss_lint/reporter/json_reporter.rb
scss-lint-0.34.0 lib/scss_lint/reporter/json_reporter.rb
scss-lint-0.33.0 lib/scss_lint/reporter/json_reporter.rb
scss-lint-0.32.0 lib/scss_lint/reporter/json_reporter.rb
scss-lint-0.31.0 lib/scss_lint/reporter/json_reporter.rb