]>
git.immae.eu Git - github/fretlink/pronto-hlint.git/blob - lib/pronto/eslint-npm.rb
4 class ESLintNpm
< Runner
6 return [] unless @patches
8 @patches.select
{ |patch
| patch
.additions
> 0 }
9 .select
{ |patch
| js_file
?(patch
.new_file_full_path
) }
10 .map
{ |patch
| inspect(patch
) }
15 @_repo_path ||= @patches.first
.repo
.path
18 Dir
.chdir(@_repo_path) do
19 JSON
.parse(`eslint #{Shellwords.escape(patch.new_file_full_path.to_s)} -f json`)
24 .select
{ |offence
| offence
['errorCount'] > 0 || offence
['warningCount'] > 0 } # no warning or error, no problem
25 .map
{ |offence
| offence
['messages'] } # get error messages for that file
27 .select
{ |offence
| offence
['line'] } # for now ignore errors without a line number
29 offences
.map
do |offence
|
30 patch
.added_lines
.select
{ |line
| line
.new_lineno
== offence
['line'] }
31 .map
{ |line
| new_message(offence
, line
) }
35 def new_message(offence
, line
)
36 path
= line
.patch
.delta
.new_file
[:path]
39 Message
.new(path
, line
, level
, offence
['message'], nil, self.class)
43 %w(.js
.es6
.js
.es6
).include?(File
.extname(path
))