Class: Pronto::ESLint
- Inherits:
-
Runner
- Object
- Runner
- Pronto::ESLint
- Defined in:
- lib/pronto/eslint.rb
Instance Method Summary collapse
- #inspect(patch) ⇒ Object
- #js_file?(path) ⇒ Boolean
- #new_message(offence, line) ⇒ Object
- #run ⇒ Object
Instance Method Details
#inspect(patch) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/pronto/eslint.rb', line 15 def inspect(patch) = File.exist?('.eslintrc') ? :eslintrc : :defaults offences = Eslintrb.lint(patch.new_file_full_path, ).compact offences.map do |offence| patch.added_lines.select { |line| line.new_lineno == offence['line'] } .map { |line| (offence, line) } end end |
#js_file?(path) ⇒ Boolean
32 33 34 |
# File 'lib/pronto/eslint.rb', line 32 def js_file?(path) %w(.js .es6 .js.es6).include? File.extname(path) end |
#new_message(offence, line) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/pronto/eslint.rb', line 25 def (offence, line) path = line.patch.delta.new_file[:path] level = :warning Message.new(path, line, level, offence['message'], nil, self.class) end |
#run ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/pronto/eslint.rb', line 6 def run 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 |