Sha256: 1c67d84071fe8714e35ee55d82d5819f4025a4cab04508b66a081b66ccfee9dc
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require 'active_support/core_ext/string/strip' require 'colorize' module ESLintWebpacker class TextFormatter def initialize(warnings) @warnings = warnings end def format max_line_column_length = max_length_of_attribute(:location) max_rule_id_length = max_length_of_attribute(:rule_id) max_message_length = max_length_of_attribute(:message) @warnings.each do |warning| message = [ warning.location.ljust(max_line_column_length + 1), warning.severity.to_s.ljust(6), warning.rule_id.ljust(max_rule_id_length), warning.message.ljust(max_message_length) ].join(' ') colorized_message = case warning.severity when :low message.green when :high message.yellow else raise 'BULLSHIT' end puts colorized_message end puts "#{@warnings.size} warning(s) found." end private def max_length_of_attribute(attr_key) @warnings.map { |warning| warning.send(attr_key).size }.max end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eslint-webpacker-1.1.0 | lib/eslint-webpacker/text_formatter.rb |
eslint-webpacker-1.0.1 | lib/eslint-webpacker/text_formatter.rb |