Sha256: c061d7c3a84b64b768d7936c04af7f83d074002333619967b9087f693e89ba7b
Contents?: true
Size: 998 Bytes
Versions: 2
Compression:
Stored size: 998 Bytes
Contents
require 'pronto' require 'jshintrb' module Pronto class JSHint < Runner def run(patches, _) return [] unless patches patches.select { |patch| patch.additions > 0 } .select { |patch| js_file?(patch.new_file_full_path) } .map { |patch| inspect(patch) } .flatten.compact end def inspect(patch) offences = if File.exist?('.jshintrc') Jshintrb.lint(patch.new_file_full_path, :jshintrc) else Jshintrb.lint(patch.new_file_full_path) end.compact offences.map do |offence| patch.added_lines.select { |line| line.new_lineno == offence['line'] } .map { |line| new_message(offence, line) } end end def new_message(offence, line) path = line.patch.delta.new_file[:path] level = :warning Message.new(path, line, level, offence['reason']) end def js_file?(path) File.extname(path) == '.js' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pronto-jshint-0.5.0 | lib/pronto/jshint.rb |
pronto-jshint-0.4.2 | lib/pronto/jshint.rb |