Sha256: 3d54dfbd183b1077f975b40f68829503252ae0695a2f2ca246eacc2a820fe48a
Contents?: true
Size: 1.19 KB
Versions: 5
Compression:
Stored size: 1.19 KB
Contents
require 'active_support/core_ext/string/strip' require 'colorize' module ESLintRails class TextFormatter WARNING_TEMPLATE = <<-TEXT.strip_heredoc <%= line %>,<%= column %> <%= severity %>! [<%= rule_id %>] <%= message %> TEXT def initialize(warnings) @warnings = warnings end def format max_line_column_length = @warnings.map { |warning| (warning.line + warning.column).size }.max max_rule_id_length = @warnings.map { |warning| warning.rule_id.size }.max max_message_length = @warnings.map { |warning| warning.message.size }.max @warnings.each do |warning| message = [ "#{warning.line}:#{warning.column}".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 end end
Version data entries
5 entries across 5 versions & 1 rubygems