danger-eslint 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eslint/gem_version.rb +1 -1
- data/lib/eslint/plugin.rb +10 -5
- data/spec/eslint_spec.rb +22 -5
- data/spec/fixtures/results/ignored.json +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1180844b62ed462c63d0d4499d2a966323935fe9
|
4
|
+
data.tar.gz: d4d0cf2f19d4253c10155f37b0c45c33bc295745
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9da0dacc407c6399097ca0dbb508ac212f69367436d88ec0a9fb2eb4135188d497b4d81d9eb7d01517efa82cb482e2f684ca47fe60c29a34473ee48ba85e890
|
7
|
+
data.tar.gz: a81811c2be884c329c940361d322ca2dd57176f12ac20348e00d0ad1c689b7a66d419d2201d24d6cd31f3bf3da2d48cb3d25a95568a8f32caa91d1d0f53bfab7
|
data/lib/eslint/gem_version.rb
CHANGED
data/lib/eslint/plugin.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mkmf'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module Danger
|
4
5
|
# This is your plugin class. Any attributes or methods you expose here will
|
@@ -41,11 +42,15 @@ module Danger
|
|
41
42
|
def lint
|
42
43
|
bin = eslint_path
|
43
44
|
raise 'eslint is not installed' unless bin
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
if filtering
|
46
|
+
results = ((git.modified_files - git.deleted_files) + git.added_files)
|
47
|
+
.select { |f| f.end_with? '.js' }
|
48
|
+
.map { |f| f.gsub("#{Dir.pwd}/", '') }
|
49
|
+
.map { |f| run_lint(bin, f).first }
|
50
|
+
else
|
51
|
+
results = run_lint(bin, '.')
|
52
|
+
end
|
53
|
+
results
|
49
54
|
.reject { |r| r['messages'].length.zero? }
|
50
55
|
.reject { |r| r['messages'].first['message'].include? 'matching ignore pattern' }
|
51
56
|
.map { |r| send_comment r }
|
data/spec/eslint_spec.rb
CHANGED
@@ -51,6 +51,13 @@ module Danger
|
|
51
51
|
.with(anything, /empty.js/).and_return(@empty_result)
|
52
52
|
allow(@eslint).to receive(:run_lint)
|
53
53
|
.with(anything, /ignored.js/).and_return(@ignored_result)
|
54
|
+
allow(@eslint).to receive(:run_lint).with(anything, '.').and_return(
|
55
|
+
[
|
56
|
+
@empty_result.first,
|
57
|
+
@error_result.first,
|
58
|
+
@warning_result.first
|
59
|
+
]
|
60
|
+
)
|
54
61
|
end
|
55
62
|
|
56
63
|
it 'lint all js files when filtering not set' do
|
@@ -97,8 +104,13 @@ module Danger
|
|
97
104
|
end
|
98
105
|
|
99
106
|
it 'accept config file' do
|
100
|
-
allow(@eslint).to receive(:run_lint)
|
101
|
-
|
107
|
+
allow(@eslint).to receive(:run_lint).with(anything, '.').and_return(
|
108
|
+
[
|
109
|
+
@empty_result.first,
|
110
|
+
@error_result.first,
|
111
|
+
@alter_warning_result.first
|
112
|
+
]
|
113
|
+
)
|
102
114
|
|
103
115
|
@eslint.config_file = 'spec/fixtures/config/.eslintrc.json'
|
104
116
|
@eslint.lint
|
@@ -107,9 +119,14 @@ module Danger
|
|
107
119
|
end
|
108
120
|
|
109
121
|
it 'accept ignore file' do
|
110
|
-
allow(@eslint).to receive(:run_lint)
|
111
|
-
|
112
|
-
|
122
|
+
allow(@eslint).to receive(:run_lint).with(anything, '.').and_return(
|
123
|
+
[
|
124
|
+
@empty_result.first,
|
125
|
+
@error_result.first,
|
126
|
+
@warning_result.first,
|
127
|
+
@alter_ignored_result.first
|
128
|
+
]
|
129
|
+
)
|
113
130
|
@eslint.ignore_file = 'spec/fixtures/config/.eslintignore'
|
114
131
|
@eslint.lint
|
115
132
|
expect(@eslint.status_report[:errors].length).to be(1)
|