From 126fe1e2579c3fc33a410278c73dc6620d5d3110 Mon Sep 17 00:00:00 2001 From: Markus Doits Date: Thu, 11 Aug 2016 17:09:34 +0200 Subject: correct name according to recommended use of `_` and `-` http://guides.rubygems.org/name-your-gem/ --- README.md | 8 +++--- lib/pronto/eslint-npm.rb | 59 ---------------------------------------- lib/pronto/eslint-npm/version.rb | 5 ---- lib/pronto/eslint_npm.rb | 59 ++++++++++++++++++++++++++++++++++++++++ lib/pronto/eslint_npm/version.rb | 5 ++++ pronto-eslint-npm.gemspec | 31 --------------------- pronto-eslint_npm.gemspec | 31 +++++++++++++++++++++ spec/spec_helper.rb | 2 +- 8 files changed, 100 insertions(+), 100 deletions(-) delete mode 100644 lib/pronto/eslint-npm.rb delete mode 100644 lib/pronto/eslint-npm/version.rb create mode 100644 lib/pronto/eslint_npm.rb create mode 100644 lib/pronto/eslint_npm/version.rb delete mode 100644 pronto-eslint-npm.gemspec create mode 100644 pronto-eslint_npm.gemspec diff --git a/README.md b/README.md index 1660df7..4fb2cdc 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Pronto runner for ESLint (using eslint from npm) -[![Code Climate](https://codeclimate.com/github/doits/pronto-eslint-npm.svg)](https://codeclimate.com/github/doits/pronto-eslint-npm) -[![Build Status](https://travis-ci.org/doits/pronto-eslint-npm.svg?branch=master)](https://travis-ci.org/doits/pronto-eslint-npm) -[![Gem Version](https://badge.fury.io/rb/pronto-eslint-npm.svg)](http://badge.fury.io/rb/pronto-eslint-npm) -[![Dependency Status](https://gemnasium.com/doits/pronto-eslint-npm.svg)](https://gemnasium.com/doits/pronto-eslint-npm) +[![Code Climate](https://codeclimate.com/github/doits/pronto-eslint_npm.svg)](https://codeclimate.com/github/doits/pronto-eslint_npm) +[![Build Status](https://travis-ci.org/doits/pronto-eslint_npm.svg?branch=master)](https://travis-ci.org/doits/pronto-eslint_npm) +[![Gem Version](https://badge.fury.io/rb/pronto-eslint_npm.svg)](http://badge.fury.io/rb/pronto-eslint_npm) +[![Dependency Status](https://gemnasium.com/doits/pronto-eslint_npm.svg)](https://gemnasium.com/doits/pronto-eslint_npm) Pronto runner for [ESlint](http://eslint.org), pluggable linting utility for JavaScript and JSX. [What is Pronto?](https://github.com/mmozuras/pronto) diff --git a/lib/pronto/eslint-npm.rb b/lib/pronto/eslint-npm.rb deleted file mode 100644 index afbae59..0000000 --- a/lib/pronto/eslint-npm.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'pronto' - -module Pronto - class ESLintNpm < Runner - 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 - - def inspect(patch) - @_repo_path ||= @patches.first.repo.path - - offences = run_eslint(patch) - clean_up_eslint_output(offences) - .map do |offence| - patch - .added_lines - .select { |line| line.new_lineno == offence['line'] } - .map { |line| new_message(offence, line) } - end - end - - private - - def new_message(offence, line) - path = line.patch.delta.new_file[:path] - level = :warning - - Message.new(path, line, level, offence['message'], nil, self.class) - end - - def js_file?(path) - %w(.js .es6 .js.es6).include?(File.extname(path)) - end - - def run_eslint(patch) - Dir.chdir(@_repo_path) do - JSON.parse( - `eslint #{Shellwords.escape(patch.new_file_full_path.to_s)} -f json` - ) - end - end - - # rubocop:disable Metrics/LineLength - def clean_up_eslint_output(output) - # 1. Filter out offences without a warning or error - # 2. Get the messages for that file - # 3. Ignore errors without a line number for now - output - .select { |offence| offence['errorCount'] + offence['warningCount'] > 0 } - .map { |offence| offence['messages'] } - .flatten.select { |offence| offence['line'] } - end - end -end diff --git a/lib/pronto/eslint-npm/version.rb b/lib/pronto/eslint-npm/version.rb deleted file mode 100644 index 0f83484..0000000 --- a/lib/pronto/eslint-npm/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Pronto - module ESLintNpmVersion - VERSION = '0.7.1'.freeze - end -end diff --git a/lib/pronto/eslint_npm.rb b/lib/pronto/eslint_npm.rb new file mode 100644 index 0000000..afbae59 --- /dev/null +++ b/lib/pronto/eslint_npm.rb @@ -0,0 +1,59 @@ +require 'pronto' + +module Pronto + class ESLintNpm < Runner + 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 + + def inspect(patch) + @_repo_path ||= @patches.first.repo.path + + offences = run_eslint(patch) + clean_up_eslint_output(offences) + .map do |offence| + patch + .added_lines + .select { |line| line.new_lineno == offence['line'] } + .map { |line| new_message(offence, line) } + end + end + + private + + def new_message(offence, line) + path = line.patch.delta.new_file[:path] + level = :warning + + Message.new(path, line, level, offence['message'], nil, self.class) + end + + def js_file?(path) + %w(.js .es6 .js.es6).include?(File.extname(path)) + end + + def run_eslint(patch) + Dir.chdir(@_repo_path) do + JSON.parse( + `eslint #{Shellwords.escape(patch.new_file_full_path.to_s)} -f json` + ) + end + end + + # rubocop:disable Metrics/LineLength + def clean_up_eslint_output(output) + # 1. Filter out offences without a warning or error + # 2. Get the messages for that file + # 3. Ignore errors without a line number for now + output + .select { |offence| offence['errorCount'] + offence['warningCount'] > 0 } + .map { |offence| offence['messages'] } + .flatten.select { |offence| offence['line'] } + end + end +end diff --git a/lib/pronto/eslint_npm/version.rb b/lib/pronto/eslint_npm/version.rb new file mode 100644 index 0000000..0f83484 --- /dev/null +++ b/lib/pronto/eslint_npm/version.rb @@ -0,0 +1,5 @@ +module Pronto + module ESLintNpmVersion + VERSION = '0.7.1'.freeze + end +end diff --git a/pronto-eslint-npm.gemspec b/pronto-eslint-npm.gemspec deleted file mode 100644 index df94361..0000000 --- a/pronto-eslint-npm.gemspec +++ /dev/null @@ -1,31 +0,0 @@ -# -*- encoding: utf-8 -*- - -$LOAD_PATH.push File.expand_path('../lib', __FILE__) -require 'pronto/eslint-npm/version' -require 'rake' - -Gem::Specification.new do |s| - s.name = 'pronto-eslint-npm' - s.version = Pronto::ESLintNpmVersion::VERSION - s.platform = Gem::Platform::RUBY - s.authors = ['Markus Doits', 'Mindaugas Mozūras'] - s.email = 'markus.doits@gmail.com' - s.homepage = 'http://github.org/doits/pronto-eslint-npm' - s.summary = <<-EOF - Pronto runner for ESLint, pluggable linting utility for JavaScript and JSX - EOF - - s.licenses = ['MIT'] - s.required_ruby_version = '>= 2.0.0' - s.rubygems_version = '1.8.23' - - s.files = FileList['LICENSE', 'README.md', 'lib/**/*'] - s.extra_rdoc_files = ['LICENSE', 'README.md'] - s.require_paths = ['lib'] - s.requirements << 'eslint (in PATH)' - - s.add_dependency('pronto', '~> 0.7.0') - s.add_development_dependency('rake', '~> 11.0') - s.add_development_dependency('rspec', '~> 3.4') - s.add_development_dependency('rspec-its', '~> 1.2') -end diff --git a/pronto-eslint_npm.gemspec b/pronto-eslint_npm.gemspec new file mode 100644 index 0000000..f51cbbb --- /dev/null +++ b/pronto-eslint_npm.gemspec @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- + +$LOAD_PATH.push File.expand_path('../lib', __FILE__) +require 'pronto/eslint_npm/version' +require 'rake' + +Gem::Specification.new do |s| + s.name = 'pronto-eslint_npm' + s.version = Pronto::ESLintNpmVersion::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ['Markus Doits', 'Mindaugas Mozūras'] + s.email = 'markus.doits@gmail.com' + s.homepage = 'http://github.org/doits/pronto-eslint_npm' + s.summary = <<-EOF + Pronto runner for ESLint, pluggable linting utility for JavaScript and JSX + EOF + + s.licenses = ['MIT'] + s.required_ruby_version = '>= 2.0.0' + s.rubygems_version = '1.8.23' + + s.files = FileList['LICENSE', 'README.md', 'lib/**/*'] + s.extra_rdoc_files = ['LICENSE', 'README.md'] + s.require_paths = ['lib'] + s.requirements << 'eslint (in PATH)' + + s.add_dependency('pronto', '~> 0.7.0') + s.add_development_dependency('rake', '~> 11.0') + s.add_development_dependency('rspec', '~> 3.4') + s.add_development_dependency('rspec-its', '~> 1.2') +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 66266cc..23f22e8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ require 'rspec' require 'rspec/its' -require 'pronto/eslint-npm' +require 'pronto/eslint_npm' %w(test eslintignore).each do |repo_name| RSpec.shared_context "#{repo_name} repo" do -- cgit v1.2.3