pronto-eslint_npm 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +2 -1
- data/lib/pronto/eslint_npm.rb +27 -16
- data/lib/pronto/eslint_npm/version.rb +3 -1
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 39cf234d371887280b38a137321b0473b88edcf32d0449f149a9db4ccd4dd713
|
4
|
+
data.tar.gz: e422f551e0a8f49378c93c47ee35af0981377bdc18e01dc58821d644b6756e30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b268886a3b6021cc2c7b39c12ce398ec9da79ce771a02fb5fd6263968982664723fae8a9aa74ccbc2b5e04c2ba8ad597fefd96f52517d75d11e68a5eda9bf43e
|
7
|
+
data.tar.gz: 51c7ee25eb574feb3dfd92a75f897b736bf67c15142ce60576d56d603943ba34561b139479f7e2473113904251396f629c94f75dd05398c5462ff2f4b73af842
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[](https://codeclimate.com/github/doits/pronto-eslint_npm)
|
4
4
|
[](https://travis-ci.org/doits/pronto-eslint_npm)
|
5
5
|
[](http://badge.fury.io/rb/pronto-eslint_npm)
|
6
|
-
[](https://gemnasium.com/doits/pronto-eslint_npm)
|
7
6
|
|
8
7
|
Pronto runner for [ESlint](http://eslint.org), pluggable linting utility for JavaScript and JSX. [What is Pronto?](https://github.com/mmozuras/pronto)
|
9
8
|
|
@@ -35,6 +34,7 @@ Following options are available:
|
|
35
34
|
| ----------------- | ---------------------------------------------------------------------------------------- | ----------------------------------- |
|
36
35
|
| eslint_executable | ESLint executable to call. | `eslint` (calls `eslint` in `PATH`) |
|
37
36
|
| files_to_lint | What files to lint. Absolute path of offending file will be matched against this Regexp. | `(\.js|\.es6)$` |
|
37
|
+
| cmd_line_opts | Command line options to pass to eslint when running | '' |
|
38
38
|
|
39
39
|
Example configuration to call custom eslint executable and only lint files ending with `.my_custom_extension`:
|
40
40
|
|
@@ -42,4 +42,5 @@ Example configuration to call custom eslint executable and only lint files endin
|
|
42
42
|
# .pronto_eslint_npm.yml
|
43
43
|
eslint_executable: '/my/custom/node/path/.bin/eslint'
|
44
44
|
files_to_lint: '\.my_custom_extension$'
|
45
|
+
cmd_line_opts: '--ext .html,.js,.es6'
|
45
46
|
```
|
data/lib/pronto/eslint_npm.rb
CHANGED
@@ -1,33 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pronto'
|
2
4
|
require 'shellwords'
|
3
5
|
|
4
6
|
module Pronto
|
5
7
|
class ESLintNpm < Runner
|
6
8
|
CONFIG_FILE = '.pronto_eslint_npm.yml'.freeze
|
7
|
-
CONFIG_KEYS = %w
|
9
|
+
CONFIG_KEYS = %w[eslint_executable files_to_lint cmd_line_opts].freeze
|
8
10
|
|
9
|
-
attr_writer :eslint_executable
|
11
|
+
attr_writer :eslint_executable, :cmd_line_opts
|
10
12
|
|
11
13
|
def eslint_executable
|
12
|
-
@eslint_executable || 'eslint'
|
14
|
+
@eslint_executable || 'eslint'
|
13
15
|
end
|
14
16
|
|
15
17
|
def files_to_lint
|
16
18
|
@files_to_lint || /(\.js|\.es6)$/
|
17
19
|
end
|
18
20
|
|
21
|
+
def cmd_line_opts
|
22
|
+
@cmd_line_opts || ''
|
23
|
+
end
|
24
|
+
|
19
25
|
def files_to_lint=(regexp)
|
20
26
|
@files_to_lint = regexp.is_a?(Regexp) && regexp || Regexp.new(regexp)
|
21
27
|
end
|
22
28
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
29
|
+
def config_options
|
30
|
+
@config_options ||=
|
31
|
+
begin
|
32
|
+
config_file = File.join(repo_path, CONFIG_FILE)
|
33
|
+
File.exist?(config_file) && YAML.load_file(config_file) || {}
|
34
|
+
end
|
35
|
+
end
|
27
36
|
|
28
|
-
|
29
|
-
|
30
|
-
|
37
|
+
def read_config
|
38
|
+
config_options.each do |key, val|
|
39
|
+
next unless CONFIG_KEYS.include?(key.to_s)
|
40
|
+
send("#{key}=", val)
|
31
41
|
end
|
32
42
|
end
|
33
43
|
|
@@ -46,7 +56,7 @@ module Pronto
|
|
46
56
|
private
|
47
57
|
|
48
58
|
def repo_path
|
49
|
-
@
|
59
|
+
@repo_path ||= @patches.first.repo.path
|
50
60
|
end
|
51
61
|
|
52
62
|
def inspect(patch)
|
@@ -61,7 +71,7 @@ module Pronto
|
|
61
71
|
end
|
62
72
|
|
63
73
|
def new_message(offence, line)
|
64
|
-
path
|
74
|
+
path = line.patch.delta.new_file[:path]
|
65
75
|
level = :warning
|
66
76
|
|
67
77
|
Message.new(path, line, level, offence['message'], nil, self.class)
|
@@ -73,13 +83,14 @@ module Pronto
|
|
73
83
|
|
74
84
|
def run_eslint(patch)
|
75
85
|
Dir.chdir(repo_path) do
|
76
|
-
|
77
|
-
JSON.parse(
|
78
|
-
`#{eslint_executable} #{escaped_file_path} -f json`
|
79
|
-
)
|
86
|
+
JSON.parse `#{eslint_command_line(patch.new_file_full_path.to_s)}`
|
80
87
|
end
|
81
88
|
end
|
82
89
|
|
90
|
+
def eslint_command_line(path)
|
91
|
+
"#{eslint_executable} #{cmd_line_opts} #{Shellwords.escape(path)} -f json"
|
92
|
+
end
|
93
|
+
|
83
94
|
def clean_up_eslint_output(output)
|
84
95
|
# 1. Filter out offences without a warning or error
|
85
96
|
# 2. Get the messages for that file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronto-eslint_npm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Doits
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pronto
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.9.1
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: byebug
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '9'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '9'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: rake
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,20 +73,6 @@ dependencies:
|
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '3.4'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: byebug
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '9'
|
69
|
-
type: :development
|
70
|
-
prerelease: false
|
71
|
-
version_requirements: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '9'
|
76
76
|
description:
|
77
77
|
email: markus.doits@gmail.com
|
78
78
|
executables: []
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
107
107
|
- eslint (in PATH)
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.6
|
109
|
+
rubygems_version: 2.7.6
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Pronto runner for ESLint, pluggable linting utility for JavaScript and JSX
|