danger-eslint 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c20321a95232c6ec4bd37c3679866ac4678eb1a6
4
- data.tar.gz: d093d388c1348899387ea1bc09c5aa2cedf77576
3
+ metadata.gz: 1180844b62ed462c63d0d4499d2a966323935fe9
4
+ data.tar.gz: d4d0cf2f19d4253c10155f37b0c45c33bc295745
5
5
  SHA512:
6
- metadata.gz: cb96d8eae6c2de7dad89259f7ca917f79b05e993dd23f100d8195f4eb1bf91827545dcd6242dc5b2682710f3dcf0879c84fac0fe283f992ff5742f3ea219ccbf
7
- data.tar.gz: 9adf4de7828027b68372403b3f59542df49274b9326102616f58b4c13ad4f4a7b881ef8e13807fdde4d79d9456c3e1f3762d7d3c40b4c63ec37ca5a79ea277b3
6
+ metadata.gz: b9da0dacc407c6399097ca0dbb508ac212f69367436d88ec0a9fb2eb4135188d497b4d81d9eb7d01517efa82cb482e2f684ca47fe60c29a34473ee48ba85e890
7
+ data.tar.gz: a81811c2be884c329c940361d322ca2dd57176f12ac20348e00d0ad1c689b7a66d419d2201d24d6cd31f3bf3da2d48cb3d25a95568a8f32caa91d1d0f53bfab7
@@ -1,3 +1,3 @@
1
1
  module Eslint
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -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
- files = filtering ? (git.modified_files - git.deleted_files) + git.added_files : Dir.glob('**/*')
45
- files
46
- .select { |f| f.end_with? '.js' }
47
- .map { |f| f.gsub("#{Dir.pwd}/", '') }
48
- .map { |f| run_lint(bin, f).first }
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 }
@@ -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
- .with(anything, /warning.js/).and_return(@alter_warning_result)
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
- .with(anything, /ignored.js/).and_return(@alter_ignored_result)
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)
@@ -1,5 +1,5 @@
1
1
  [{
2
- "filePath": "/Users/01011775/Work/danger-eslint/spec/fixtures/javascript/ignored.js",
2
+ "filePath": "danger-eslint/spec/fixtures/javascript/ignored.js",
3
3
  "messages": [{
4
4
  "fatal": false,
5
5
  "severity": 1,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-eslint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - leonhartX