--- /dev/null
+require 'pronto'
+require 'eslintrb'
+
+module Pronto
+ class ESLint < 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)
+ options = File.exist?('.eslintrc') ? :eslintrc : :defaults
+ offences = Eslintrb.lint(patch.new_file_full_path, options).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['message'])
+ end
+
+ def js_file?(path)
+ File.extname(path) == '.js'
+ end
+ end
+end
--- /dev/null
+module Pronto
+ module ESLintVersion
+ VERSION = '0.5.0'
+ end
+end
--- /dev/null
+ref: refs/heads/curly
--- /dev/null
+[core]
+ repositoryformatversion = 0
+ filemode = true
+ bare = false
+ logallrefupdates = true
+ ignorecase = true
+ precomposeunicode = true
--- /dev/null
+0000000000000000000000000000000000000000 f37efccc1cef20309de28bfbdd16d0c4afb9d550 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1433058807 +0300 commit (initial): Initial commit
+f37efccc1cef20309de28bfbdd16d0c4afb9d550 f37efccc1cef20309de28bfbdd16d0c4afb9d550 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1433058814 +0300 checkout: moving from master to semicolon
+f37efccc1cef20309de28bfbdd16d0c4afb9d550 f7eb73cae47464f2d235a1d014c4617ad2aa0cb0 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1433058820 +0300 commit: Remove semicolon
+f7eb73cae47464f2d235a1d014c4617ad2aa0cb0 f37efccc1cef20309de28bfbdd16d0c4afb9d550 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456673968 +0200 checkout: moving from semicolon to master
+f37efccc1cef20309de28bfbdd16d0c4afb9d550 85e04b1eb1a721d42db51d49e49dfeb8255a5741 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456673985 +0200 commit (amend): Initial commit
+85e04b1eb1a721d42db51d49e49dfeb8255a5741 f7eb73cae47464f2d235a1d014c4617ad2aa0cb0 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456673990 +0200 checkout: moving from master to semicolon
+f7eb73cae47464f2d235a1d014c4617ad2aa0cb0 85e04b1eb1a721d42db51d49e49dfeb8255a5741 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456673992 +0200 rebase: checkout master
+85e04b1eb1a721d42db51d49e49dfeb8255a5741 e438134aac40ce86789d552f1bdada6582a987f6 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456673992 +0200 rebase: Remove semicolon
+e438134aac40ce86789d552f1bdada6582a987f6 e438134aac40ce86789d552f1bdada6582a987f6 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456673992 +0200 rebase finished: returning to refs/heads/semicolon
+e438134aac40ce86789d552f1bdada6582a987f6 85e04b1eb1a721d42db51d49e49dfeb8255a5741 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456674159 +0200 checkout: moving from semicolon to master
+85e04b1eb1a721d42db51d49e49dfeb8255a5741 931004157205727e6a47586feaed0473c6ddbd66 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456674164 +0200 commit (amend): Initial commit
+931004157205727e6a47586feaed0473c6ddbd66 931004157205727e6a47586feaed0473c6ddbd66 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456674177 +0200 checkout: moving from master to curly
+931004157205727e6a47586feaed0473c6ddbd66 3a6237c5feacca9a37c36bec5110a1eeb9da703b Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456674189 +0200 commit: Add a line of code that does not have the correct curlies (eslint)
--- /dev/null
+0000000000000000000000000000000000000000 931004157205727e6a47586feaed0473c6ddbd66 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456674177 +0200 branch: Created from HEAD
+931004157205727e6a47586feaed0473c6ddbd66 3a6237c5feacca9a37c36bec5110a1eeb9da703b Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456674189 +0200 commit: Add a line of code that does not have the correct curlies (eslint)
--- /dev/null
+0000000000000000000000000000000000000000 f37efccc1cef20309de28bfbdd16d0c4afb9d550 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1433058807 +0300 commit (initial): Initial commit
+f37efccc1cef20309de28bfbdd16d0c4afb9d550 85e04b1eb1a721d42db51d49e49dfeb8255a5741 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456673985 +0200 commit (amend): Initial commit
+85e04b1eb1a721d42db51d49e49dfeb8255a5741 931004157205727e6a47586feaed0473c6ddbd66 Mindaugas Mozūras <mindaugas.mozuras@gmail.com> 1456674164 +0200 commit (amend): Initial commit
--- /dev/null
+x\ 1\9d\8eÍi\ 31\10FsV\15º\e\8c4\9aÑjÀ\187àK:ÐÏØY°VfWë\83[J\1dé+º¤\81Ü>\1e¼Ç\97[s×àíG_E4\83#á\1cB\ 6C¶xF¾I\12\80[f\ 4ç)\9a\ 4\84^=ã*K×\81Ä`²\92l\9cÀ\16\84\92\86\86,Èe\88\ 1\88"MhUÜûW[õu^JÜïqÓ×öþù^Ç8Õ?v¬í½\ ft¹×8?\8e¹Õ³¶è\9c¡\10Àè\83qƨAÇã.ÿj\91÷\93c\86Ñ\82ÑR\9fRÛKô&uÎíÑ\16õ\vß)V\9f
\ No newline at end of file
--- /dev/null
+x\ 1ÎK
+Â0\14\85aÇYÅ\9d\vå&iÒ\ 4D\9c:è"n\1e\81¦\81\9aNº%×á¾\f\88;pvø\ 6?Ç\97\9cS\ 5Áù©n1\82\9d¼ \17\ 2\1a«8¢SfÐÎË^\a
+Ú¹ÉI\e\14=£½>Ê\ 6cZ\ 3í3=a,ÇûµµqÉ?ër9öF·9SZ:_ò\15x/%*cp\803JDÖ´=¨ñ\1f-v_SM´À7Ê>»CHò
\ No newline at end of file
--- /dev/null
+3a6237c5feacca9a37c36bec5110a1eeb9da703b
--- /dev/null
+931004157205727e6a47586feaed0473c6ddbd66
--- /dev/null
+function HelloWorld(name)
+{
+ if (foo) foo++;
+ alert(name);
+}
--- /dev/null
+require 'spec_helper'
+
+module Pronto
+ describe ESLint do
+ let(:eslint) { ESLint.new }
+
+ describe '#run' do
+ subject { eslint.run(patches, nil) }
+
+ context 'patches are nil' do
+ let(:patches) { nil }
+ it { should == [] }
+ end
+
+ context 'no patches' do
+ let(:patches) { [] }
+ it { should == [] }
+ end
+
+ context 'patches with a four warnings' do
+ include_context 'test repo'
+
+ let(:patches) { repo.diff('master') }
+
+ its(:count) { should == 4 }
+ its(:'first.msg') { should == "Expected { after 'if' condition." }
+ end
+ end
+ end
+end