pronto-eslint_npm 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 70ee17c24d2de82f6324109da2f7f020249bd060
4
+ data.tar.gz: 183e13d563090e0effde44519400af9139debe46
5
+ SHA512:
6
+ metadata.gz: 7b4a13dce0e0181a1ec5bfc88d9c52c72e5bd181fa0df719dcaa2c2e10202aac3c047c3ce983a9a51a36ebb8156076109e7261a0e8ae1a27a4db8273b1621663
7
+ data.tar.gz: acd24953accc803f2606fbb11baa2636840176cba344d6c945adb9887aeeb6907592373a6f0346a0779282f6fa9555693953f26774aad5e4961f8dcc36499980
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2016 Mindaugas Mozūras
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Pronto runner for ESLint (using eslint from npm)
2
+
3
+ [![Code Climate](https://codeclimate.com/github/doits/pronto-eslint_npm.svg)](https://codeclimate.com/github/doits/pronto-eslint_npm)
4
+ [![Build Status](https://travis-ci.org/doits/pronto-eslint_npm.svg?branch=master)](https://travis-ci.org/doits/pronto-eslint_npm)
5
+ [![Gem Version](https://badge.fury.io/rb/pronto-eslint_npm.svg)](http://badge.fury.io/rb/pronto-eslint_npm)
6
+ [![Dependency Status](https://gemnasium.com/doits/pronto-eslint_npm.svg)](https://gemnasium.com/doits/pronto-eslint_npm)
7
+
8
+ Pronto runner for [ESlint](http://eslint.org), pluggable linting utility for JavaScript and JSX. [What is Pronto?](https://github.com/mmozuras/pronto)
9
+
10
+ Uses system wide installed eslint in contrast to [pronto-eslint][pronto-eslint].
11
+
12
+ [pronto-eslint]: https://github.com/mmozuras/pronto-eslint
13
+
14
+ ## Prerequisites
15
+
16
+ You'll need to install [eslint by yourself with npm][eslint-install].
17
+
18
+ [eslint-install]: http://eslint.org/docs/user-guide/getting-started
19
+
20
+ ## Configuration
21
+
22
+ Configuring ESLint via [.eslintrc and consorts][eslintrc] and excludes via [.eslintignore][eslintignore] will work just fine with pronto-eslint.
23
+
24
+ [eslintrc]: http://eslint.org/docs/user-guide/configuring#configuration-file-formats
25
+ [eslintignore]: http://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories
@@ -0,0 +1,59 @@
1
+ require 'pronto'
2
+
3
+ module Pronto
4
+ class ESLintNpm < Runner
5
+ def run
6
+ return [] unless @patches
7
+
8
+ @patches.select { |patch| patch.additions > 0 }
9
+ .select { |patch| js_file?(patch.new_file_full_path) }
10
+ .map { |patch| inspect(patch) }
11
+ .flatten.compact
12
+ end
13
+
14
+ def inspect(patch)
15
+ @_repo_path ||= @patches.first.repo.path
16
+
17
+ offences = run_eslint(patch)
18
+ clean_up_eslint_output(offences)
19
+ .map do |offence|
20
+ patch
21
+ .added_lines
22
+ .select { |line| line.new_lineno == offence['line'] }
23
+ .map { |line| new_message(offence, line) }
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def new_message(offence, line)
30
+ path = line.patch.delta.new_file[:path]
31
+ level = :warning
32
+
33
+ Message.new(path, line, level, offence['message'], nil, self.class)
34
+ end
35
+
36
+ def js_file?(path)
37
+ %w(.js .es6 .js.es6).include?(File.extname(path))
38
+ end
39
+
40
+ def run_eslint(patch)
41
+ Dir.chdir(@_repo_path) do
42
+ JSON.parse(
43
+ `eslint #{Shellwords.escape(patch.new_file_full_path.to_s)} -f json`
44
+ )
45
+ end
46
+ end
47
+
48
+ # rubocop:disable Metrics/LineLength
49
+ def clean_up_eslint_output(output)
50
+ # 1. Filter out offences without a warning or error
51
+ # 2. Get the messages for that file
52
+ # 3. Ignore errors without a line number for now
53
+ output
54
+ .select { |offence| offence['errorCount'] + offence['warningCount'] > 0 }
55
+ .map { |offence| offence['messages'] }
56
+ .flatten.select { |offence| offence['line'] }
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module ESLintNpmVersion
3
+ VERSION = '0.7.0'.freeze
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-eslint_npm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
+ platform: ruby
6
+ authors:
7
+ - Markus Doits
8
+ - Mindaugas Mozūras
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-08-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pronto
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.7.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.7.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '11.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '11.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.4'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.4'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec-its
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.2'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.2'
70
+ description:
71
+ email: markus.doits@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - LICENSE
76
+ - README.md
77
+ files:
78
+ - LICENSE
79
+ - README.md
80
+ - lib/pronto/eslint_npm.rb
81
+ - lib/pronto/eslint_npm/version.rb
82
+ homepage: http://github.org/doits/pronto-eslint_npm
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 2.0.0
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements:
101
+ - eslint (in PATH)
102
+ rubyforge_project:
103
+ rubygems_version: 2.6.4
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Pronto runner for ESLint, pluggable linting utility for JavaScript and JSX
107
+ test_files: []