danger-eslint 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c20321a95232c6ec4bd37c3679866ac4678eb1a6
4
+ data.tar.gz: d093d388c1348899387ea1bc09c5aa2cedf77576
5
+ SHA512:
6
+ metadata.gz: cb96d8eae6c2de7dad89259f7ca917f79b05e993dd23f100d8195f4eb1bf91827545dcd6242dc5b2682710f3dcf0879c84fac0fe283f992ff5742f3ea219ccbf
7
+ data.tar.gz: 9adf4de7828027b68372403b3f59542df49274b9326102616f58b4c13ad4f4a7b881ef8e13807fdde4d79d9456c3e1f3762d7d3c40b4c63ec37ca5a79ea277b3
@@ -0,0 +1 @@
1
+ ignored.js
@@ -0,0 +1,23 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "commonjs": true,
5
+ "es6": true,
6
+ "node": true
7
+ },
8
+ "parserOptions": {
9
+ "ecmaFeatures": {
10
+ "jsx": true
11
+ },
12
+ "sourceType": "module"
13
+ },
14
+ "rules": {
15
+ "no-const-assign": "warn",
16
+ "no-this-before-super": "warn",
17
+ "no-undef": "warn",
18
+ "no-unreachable": "warn",
19
+ "no-unused-vars": "warn",
20
+ "constructor-super": "warn",
21
+ "valid-typeof": "warn"
22
+ }
23
+ }
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .yardoc
5
+ .vscode/
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.0
8
+ - 2.1.3
9
+ - 2.3.1
10
+
11
+ script:
12
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-eslint.gemspec
4
+ gemspec
@@ -0,0 +1,135 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-eslint (0.1.0)
5
+ danger-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.1)
11
+ public_suffix (~> 2.0, >= 2.0.2)
12
+ ast (2.3.0)
13
+ claide (1.0.2)
14
+ claide-plugins (0.9.2)
15
+ cork
16
+ nap
17
+ open4 (~> 1.3)
18
+ coderay (1.1.1)
19
+ colored2 (3.1.2)
20
+ cork (0.3.0)
21
+ colored2 (~> 3.1)
22
+ danger (5.3.0)
23
+ claide (~> 1.0)
24
+ claide-plugins (>= 0.9.2)
25
+ colored2 (~> 3.1)
26
+ cork (~> 0.1)
27
+ faraday (~> 0.9)
28
+ faraday-http-cache (~> 1.0)
29
+ git (~> 1)
30
+ kramdown (~> 1.5)
31
+ octokit (~> 4.2)
32
+ terminal-table (~> 1)
33
+ danger-plugin-api (1.0.0)
34
+ danger (> 2.0)
35
+ diff-lcs (1.3)
36
+ faraday (0.12.1)
37
+ multipart-post (>= 1.2, < 3)
38
+ faraday-http-cache (1.3.1)
39
+ faraday (~> 0.8)
40
+ ffi (1.9.18)
41
+ formatador (0.2.5)
42
+ git (1.3.0)
43
+ guard (2.14.1)
44
+ formatador (>= 0.2.4)
45
+ listen (>= 2.7, < 4.0)
46
+ lumberjack (~> 1.0)
47
+ nenv (~> 0.1)
48
+ notiffany (~> 0.0)
49
+ pry (>= 0.9.12)
50
+ shellany (~> 0.0)
51
+ thor (>= 0.18.1)
52
+ guard-compat (1.2.1)
53
+ guard-rspec (4.7.3)
54
+ guard (~> 2.1)
55
+ guard-compat (~> 1.1)
56
+ rspec (>= 2.99.0, < 4.0)
57
+ kramdown (1.13.2)
58
+ listen (3.0.7)
59
+ rb-fsevent (>= 0.9.3)
60
+ rb-inotify (>= 0.9.7)
61
+ lumberjack (1.0.12)
62
+ method_source (0.8.2)
63
+ multipart-post (2.0.0)
64
+ nap (1.1.0)
65
+ nenv (0.3.0)
66
+ notiffany (0.1.1)
67
+ nenv (~> 0.1)
68
+ shellany (~> 0.0)
69
+ octokit (4.7.0)
70
+ sawyer (~> 0.8.0, >= 0.5.3)
71
+ open4 (1.3.4)
72
+ parallel (1.11.2)
73
+ parser (2.4.0.0)
74
+ ast (~> 2.2)
75
+ powerpack (0.1.1)
76
+ pry (0.10.4)
77
+ coderay (~> 1.1.0)
78
+ method_source (~> 0.8.1)
79
+ slop (~> 3.4)
80
+ public_suffix (2.0.5)
81
+ rainbow (2.2.2)
82
+ rake
83
+ rake (10.5.0)
84
+ rb-fsevent (0.9.8)
85
+ rb-inotify (0.9.8)
86
+ ffi (>= 0.5.0)
87
+ rspec (3.6.0)
88
+ rspec-core (~> 3.6.0)
89
+ rspec-expectations (~> 3.6.0)
90
+ rspec-mocks (~> 3.6.0)
91
+ rspec-core (3.6.0)
92
+ rspec-support (~> 3.6.0)
93
+ rspec-expectations (3.6.0)
94
+ diff-lcs (>= 1.2.0, < 2.0)
95
+ rspec-support (~> 3.6.0)
96
+ rspec-mocks (3.6.0)
97
+ diff-lcs (>= 1.2.0, < 2.0)
98
+ rspec-support (~> 3.6.0)
99
+ rspec-support (3.6.0)
100
+ rubocop (0.49.1)
101
+ parallel (~> 1.10)
102
+ parser (>= 2.3.3.1, < 3.0)
103
+ powerpack (~> 0.1)
104
+ rainbow (>= 1.99.1, < 3.0)
105
+ ruby-progressbar (~> 1.7)
106
+ unicode-display_width (~> 1.0, >= 1.0.1)
107
+ ruby-progressbar (1.8.1)
108
+ sawyer (0.8.1)
109
+ addressable (>= 2.3.5, < 2.6)
110
+ faraday (~> 0.8, < 1.0)
111
+ shellany (0.0.1)
112
+ slop (3.6.0)
113
+ terminal-table (1.8.0)
114
+ unicode-display_width (~> 1.1, >= 1.1.1)
115
+ thor (0.19.4)
116
+ unicode-display_width (1.2.1)
117
+ yard (0.9.9)
118
+
119
+ PLATFORMS
120
+ ruby
121
+
122
+ DEPENDENCIES
123
+ bundler (~> 1.3)
124
+ danger-eslint!
125
+ guard (~> 2.14)
126
+ guard-rspec (~> 4.7)
127
+ listen (= 3.0.7)
128
+ pry
129
+ rake (~> 10.0)
130
+ rspec (~> 3.4)
131
+ rubocop (~> 0.41)
132
+ yard (~> 0.8)
133
+
134
+ BUNDLED WITH
135
+ 1.15.0
@@ -0,0 +1,19 @@
1
+ # A guardfile for making Danger Plugins
2
+ # For more info see https://github.com/guard/guard#readme
3
+
4
+ # To run, use `bundle exec guard`.
5
+
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # Ruby files
17
+ ruby = dsl.ruby
18
+ dsl.watch_spec_files_for(ruby.lib_files)
19
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Ke Xu <leonhartx.k@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ # danger-eslint
2
+
3
+ A description of danger-eslint.
4
+
5
+ ## Installation
6
+
7
+ $ gem install danger-eslint
8
+
9
+ ## Usage
10
+
11
+ Methods and attributes from this plugin are available in
12
+ your `Dangerfile` under the `eslint` namespace.
13
+
14
+ ## Development
15
+
16
+ 1. Clone this repo
17
+ 2. Run `bundle install` to setup dependencies.
18
+ 3. Run `bundle exec rake spec` to run the tests.
19
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
20
+ 5. Make your changes.
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ Rake::Task['spec_docs'].invoke
13
+ end
14
+
15
+ desc 'Run RuboCop on the lib/specs directory'
16
+ RuboCop::RakeTask.new(:rubocop) do |task|
17
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
18
+ end
19
+
20
+ desc 'Ensure that the plugin passes `danger plugins lint`'
21
+ task :spec_docs do
22
+ sh 'bundle exec danger plugins lint'
23
+ end
@@ -0,0 +1,49 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eslint/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-eslint'
8
+ spec.version = Eslint::VERSION
9
+ spec.authors = ['leonhartX']
10
+ spec.email = ['leonhartx.k@gmail.com']
11
+ spec.description = %q{A short description of danger-eslint.}
12
+ spec.summary = %q{A longer description of danger-eslint.}
13
+ spec.homepage = 'https://github.com/leonhartX/danger-eslint'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
22
+
23
+ # General ruby development
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+
27
+ # Testing support
28
+ spec.add_development_dependency 'rspec', '~> 3.4'
29
+
30
+ # Linting code and docs
31
+ spec.add_development_dependency "rubocop", "~> 0.41"
32
+ spec.add_development_dependency "yard", "~> 0.8"
33
+
34
+ # Makes testing easy via `bundle exec guard`
35
+ spec.add_development_dependency 'guard', '~> 2.14'
36
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
37
+
38
+ # If you want to work on older builds of ruby
39
+ spec.add_development_dependency 'listen', '3.0.7'
40
+
41
+ # This gives you the chance to run a REPL inside your tests
42
+ # via:
43
+ #
44
+ # require 'pry'
45
+ # binding.pry
46
+ #
47
+ # This will stop test execution and let you inspect the results
48
+ spec.add_development_dependency 'pry'
49
+ end
@@ -0,0 +1 @@
1
+ require 'eslint/gem_version'
@@ -0,0 +1 @@
1
+ require 'eslint/plugin'
@@ -0,0 +1,3 @@
1
+ module Eslint
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,93 @@
1
+ require 'mkmf'
2
+
3
+ module Danger
4
+ # This is your plugin class. Any attributes or methods you expose here will
5
+ # be available from within your Dangerfile.
6
+ #
7
+ # To be published on the Danger plugins site, you will need to have
8
+ # the public interface documented. Danger uses [YARD](http://yardoc.org/)
9
+ # for generating documentation from your plugin source, and you can verify
10
+ # by running `danger plugins lint` or `bundle exec rake spec`.
11
+ #
12
+ # You should replace these comments with a public description of your library.
13
+ #
14
+ # @example Ensure people are well warned about merging on Mondays
15
+ #
16
+ # my_plugin.warn_on_mondays
17
+ #
18
+ # @see leonhartX/danger-eslint
19
+ # @tags monday, weekends, time, rattata
20
+ #
21
+ class DangerEslint < Plugin
22
+ # An path to eslint's config file
23
+ # @return [String]
24
+ attr_accessor :config_file
25
+
26
+ # An path to eslint's ignore file
27
+ # @return [String]
28
+ attr_accessor :ignore_file
29
+
30
+ # Enable filtering
31
+ # Only show messages within changed files.
32
+ # @return [Boolean]
33
+ attr_accessor :filtering
34
+
35
+ # Lints javascript files.
36
+ # Generates `errors` and `warnings` due to eslint's config.
37
+ # Will try to send inline comment if supported(Github)
38
+ #
39
+ # @return [void]
40
+ #
41
+ def lint
42
+ bin = eslint_path
43
+ 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 }
49
+ .reject { |r| r['messages'].length.zero? }
50
+ .reject { |r| r['messages'].first['message'].include? 'matching ignore pattern' }
51
+ .map { |r| send_comment r }
52
+ end
53
+
54
+ private
55
+
56
+ # Get eslint' bin path
57
+ #
58
+ # return [String]
59
+ def eslint_path
60
+ local = './node_modules/.bin/eslint'
61
+ File.exist?(local) ? local : find_executable('eslint')
62
+ end
63
+
64
+ # Run eslint aginst a single file.
65
+ #
66
+ # @param [String] bin
67
+ # The binary path of eslint
68
+ #
69
+ # @param [String] file
70
+ # File to be linted
71
+ #
72
+ # return [Hash]
73
+ def run_lint(bin, file)
74
+ command = "#{bin} -f json"
75
+ command << " -c #{config_file}" if config_file
76
+ command << " --ignore-path #{ignore_file}" if ignore_file
77
+ result = `#{command} #{file}`
78
+ JSON.parse(result)
79
+ end
80
+
81
+ # Send comment with danger's warn or fail method.
82
+ #
83
+ # @return [void]
84
+ def send_comment(results)
85
+ dir = "#{Dir.pwd}/"
86
+ results['messages'].each do |r|
87
+ filename = results['filePath'].gsub(dir, '')
88
+ method = r['severity'] > 1 ? 'fail' : 'warn'
89
+ send(method, r['message'], file: filename, line: r['line'])
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,121 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerEslint do
5
+ it 'should be a plugin' do
6
+ expect(Danger::DangerEslint.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ #
10
+ # You should test your custom attributes and methods here
11
+ #
12
+ describe 'with Dangerfile' do
13
+ before do
14
+ @dangerfile = testing_dangerfile
15
+ @eslint = @dangerfile.eslint
16
+ allow(@eslint.git).to receive(:deleted_files).and_return([])
17
+ allow(@eslint.git).to receive(:added_files).and_return([])
18
+ allow(@eslint.git).to receive(:modified_files).and_return([])
19
+ allow(@eslint).to receive(:eslint_path).and_return('eslint')
20
+ end
21
+
22
+ it 'does not make an empty message' do
23
+ allow(@eslint).to receive(:lint).and_return('[]')
24
+ expect(@eslint.status_report[:errors].first).to be_nil
25
+ expect(@eslint.status_report[:warnings].first).to be_nil
26
+ expect(@eslint.status_report[:markdowns].first).to be_nil
27
+ end
28
+
29
+ it 'failed if eslint not installed' do
30
+ allow(@eslint).to receive(:eslint_path).and_return(nil)
31
+ expect { @eslint.lint }.to raise_error('eslint is not installed')
32
+ end
33
+
34
+ describe :lint do
35
+ before do
36
+ @error_result = JSON.parse(File.read('spec/fixtures/results/error.json'))
37
+ @warning_result = JSON.parse(File.read('spec/fixtures/results/warning.json'))
38
+ @alter_warning_result = JSON.parse(File.read('spec/fixtures/results/alter_warning.json'))
39
+ @empty_result = JSON.parse(File.read('spec/fixtures/results/empty.json'))
40
+ @ignored_result = JSON.parse(File.read('spec/fixtures/results/ignored.json'))
41
+ @alter_ignored_result = JSON.parse(File.read('spec/fixtures/results/alter_ignored.json'))
42
+
43
+ allow(@eslint.git).to receive(:added_files).and_return([])
44
+ allow(@eslint.git).to receive(:modified_files).and_return([])
45
+
46
+ allow(@eslint).to receive(:run_lint)
47
+ .with(anything, /error.js/).and_return(@error_result)
48
+ allow(@eslint).to receive(:run_lint)
49
+ .with(anything, /warning.js/).and_return(@warning_result)
50
+ allow(@eslint).to receive(:run_lint)
51
+ .with(anything, /empty.js/).and_return(@empty_result)
52
+ allow(@eslint).to receive(:run_lint)
53
+ .with(anything, /ignored.js/).and_return(@ignored_result)
54
+ end
55
+
56
+ it 'lint all js files when filtering not set' do
57
+ @eslint.lint
58
+ error = @eslint.status_report[:errors].first
59
+ warn = @eslint.status_report[:warnings].first
60
+ expect(error).to eq('Parsing error: Unexpected token ;')
61
+ expect(@eslint.status_report[:errors].length).to be(1)
62
+ expect(warn).to eq("'a' is assigned a value but never used.")
63
+ expect(@eslint.status_report[:warnings].length).to be(1)
64
+ end
65
+
66
+ it 'lint only changed files when filtering enabled' do
67
+ allow(@eslint.git).to receive(:modified_files)
68
+ .and_return(['spec/fixtures/javascript/error.js'])
69
+
70
+ @eslint.filtering = true
71
+ @eslint.lint
72
+ error = @eslint.status_report[:errors].first
73
+ expect(error).to eq('Parsing error: Unexpected token ;')
74
+ expect(@eslint.status_report[:warnings].length).to be(0)
75
+ end
76
+
77
+ it 'do not print anything if no violations' do
78
+ allow(@eslint.git).to receive(:modified_files)
79
+ .and_return(['spec/fixtures/javascript/empty.js'])
80
+
81
+ @eslint.filtering = true
82
+ @eslint.lint
83
+
84
+ expect(@eslint.status_report[:errors].length).to be(0)
85
+ expect(@eslint.status_report[:warnings].length).to be(0)
86
+ end
87
+
88
+ it 'do not report ignored files' do
89
+ allow(@eslint.git).to receive(:modified_files)
90
+ .and_return(['spec/fixtures/javascript/ignored.js'])
91
+
92
+ @eslint.filtering = true
93
+ @eslint.lint
94
+
95
+ expect(@eslint.status_report[:errors].length).to be(0)
96
+ expect(@eslint.status_report[:warnings].length).to be(0)
97
+ end
98
+
99
+ it 'accept config file' do
100
+ allow(@eslint).to receive(:run_lint)
101
+ .with(anything, /warning.js/).and_return(@alter_warning_result)
102
+
103
+ @eslint.config_file = 'spec/fixtures/config/.eslintrc.json'
104
+ @eslint.lint
105
+ expect(@eslint.status_report[:errors].length).to be(2)
106
+ expect(@eslint.status_report[:warnings].length).to be(0)
107
+ end
108
+
109
+ it 'accept ignore file' do
110
+ allow(@eslint).to receive(:run_lint)
111
+ .with(anything, /ignored.js/).and_return(@alter_ignored_result)
112
+
113
+ @eslint.ignore_file = 'spec/fixtures/config/.eslintignore'
114
+ @eslint.lint
115
+ expect(@eslint.status_report[:errors].length).to be(1)
116
+ expect(@eslint.status_report[:warnings].length).to be(2)
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1 @@
1
+ !*.js
@@ -0,0 +1,23 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "commonjs": true,
5
+ "es6": true,
6
+ "node": true
7
+ },
8
+ "parserOptions": {
9
+ "ecmaFeatures": {
10
+ "jsx": true
11
+ },
12
+ "sourceType": "module"
13
+ },
14
+ "rules": {
15
+ "no-const-assign": "warn",
16
+ "no-this-before-super": "warn",
17
+ "no-undef": "warn",
18
+ "no-unreachable": "warn",
19
+ "no-unused-vars": "error",
20
+ "constructor-super": "warn",
21
+ "valid-typeof": "warn"
22
+ }
23
+ }
File without changes
@@ -0,0 +1 @@
1
+ var a = ;
@@ -0,0 +1 @@
1
+ a = 1;
@@ -0,0 +1 @@
1
+ var a = 1;
@@ -0,0 +1,17 @@
1
+ [{
2
+ "filePath": "danger-eslint/spec/fixtures/javascript/ignored.js",
3
+ "messages": [{
4
+ "ruleId": "no-undef",
5
+ "severity": 1,
6
+ "message": "'a' is not defined.",
7
+ "line": 1,
8
+ "column": 1,
9
+ "nodeType": "Identifier",
10
+ "source": "a = 1;"
11
+ }],
12
+ "errorCount": 0,
13
+ "warningCount": 1,
14
+ "fixableErrorCount": 0,
15
+ "fixableWarningCount": 0,
16
+ "source": "a = 1;"
17
+ }]
@@ -0,0 +1,17 @@
1
+ [{
2
+ "filePath": "danger-eslint/spec/fixtures/javascript/warning.js",
3
+ "messages": [{
4
+ "ruleId": "no-unused-vars",
5
+ "severity": 2,
6
+ "message": "'a' is assigned a value but never used.",
7
+ "line": 1,
8
+ "column": 5,
9
+ "nodeType": "Identifier",
10
+ "source": "var a = 1;"
11
+ }],
12
+ "errorCount": 1,
13
+ "warningCount": 0,
14
+ "fixableErrorCount": 0,
15
+ "fixableWarningCount": 0,
16
+ "source": "var a = 1;"
17
+ }]
@@ -0,0 +1,8 @@
1
+ [{
2
+ "filePath": "danger-eslint/spec/fixtures/javascript/empty.js",
3
+ "messages": [],
4
+ "errorCount": 0,
5
+ "warningCount": 0,
6
+ "fixableErrorCount": 0,
7
+ "fixableWarningCount": 0
8
+ }]
@@ -0,0 +1,17 @@
1
+ [{
2
+ "filePath": "danger-eslint/spec/fixtures/javascript/error.js",
3
+ "messages": [{
4
+ "ruleId": null,
5
+ "fatal": true,
6
+ "severity": 2,
7
+ "source": "var a = ;",
8
+ "message": "Parsing error: Unexpected token ;",
9
+ "line": 1,
10
+ "column": 9
11
+ }],
12
+ "errorCount": 1,
13
+ "warningCount": 0,
14
+ "fixableErrorCount": 0,
15
+ "fixableWarningCount": 0,
16
+ "source": "var a = ;"
17
+ }]
@@ -0,0 +1,12 @@
1
+ [{
2
+ "filePath": "/Users/01011775/Work/danger-eslint/spec/fixtures/javascript/ignored.js",
3
+ "messages": [{
4
+ "fatal": false,
5
+ "severity": 1,
6
+ "message": "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."
7
+ }],
8
+ "errorCount": 0,
9
+ "warningCount": 1,
10
+ "fixableErrorCount": 0,
11
+ "fixableWarningCount": 0
12
+ }]
@@ -0,0 +1,17 @@
1
+ [{
2
+ "filePath": "danger-eslint/spec/fixtures/javascript/warning.js",
3
+ "messages": [{
4
+ "ruleId": "no-unused-vars",
5
+ "severity": 1,
6
+ "message": "'a' is assigned a value but never used.",
7
+ "line": 1,
8
+ "column": 5,
9
+ "nodeType": "Identifier",
10
+ "source": "var a = 1;"
11
+ }],
12
+ "errorCount": 0,
13
+ "warningCount": 1,
14
+ "fixableErrorCount": 0,
15
+ "fixableWarningCount": 0,
16
+ "source": "var a = 1;"
17
+ }]
@@ -0,0 +1,59 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
4
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'pry'
8
+
9
+ require 'rspec'
10
+ require 'danger'
11
+
12
+ # Use coloured output, it's the best.
13
+ RSpec.configure do |config|
14
+ config.filter_gems_from_backtrace 'bundler'
15
+ config.color = true
16
+ config.tty = true
17
+ end
18
+
19
+ require 'danger_plugin'
20
+
21
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
22
+ # If you are expanding these files, see if it's already been done ^.
23
+
24
+ # A silent version of the user interface,
25
+ # it comes with an extra function `.string` which will
26
+ # strip all ANSI colours from the string.
27
+
28
+ # rubocop:disable Lint/NestedMethodDefinition
29
+ def testing_ui
30
+ @output = StringIO.new
31
+ def @output.winsize
32
+ [20, 9999]
33
+ end
34
+
35
+ cork = Cork::Board.new(out: @output)
36
+ def cork.string
37
+ out.string.gsub(/\e\[([;\d]+)?m/, '')
38
+ end
39
+ cork
40
+ end
41
+ # rubocop:enable Lint/NestedMethodDefinition
42
+
43
+ # Example environment (ENV) that would come from
44
+ # running a PR on TravisCI
45
+ def testing_env
46
+ {
47
+ 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
48
+ 'TRAVIS_PULL_REQUEST' => '800',
49
+ 'TRAVIS_REPO_SLUG' => 'artsy/eigen',
50
+ 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
51
+ 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
52
+ }
53
+ end
54
+
55
+ # A stubbed out Dangerfile for use in tests
56
+ def testing_dangerfile
57
+ env = Danger::EnvironmentManager.new(testing_env)
58
+ Danger::Dangerfile.new(env, testing_ui)
59
+ end
metadata ADDED
@@ -0,0 +1,227 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-eslint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - leonhartX
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.41'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.41'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: listen
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.7
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 3.0.7
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: A short description of danger-eslint.
154
+ email:
155
+ - leonhartx.k@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".eslintignore"
161
+ - ".eslintrc.json"
162
+ - ".gitignore"
163
+ - ".travis.yml"
164
+ - Gemfile
165
+ - Gemfile.lock
166
+ - Guardfile
167
+ - LICENSE.txt
168
+ - README.md
169
+ - Rakefile
170
+ - danger-eslint.gemspec
171
+ - lib/danger_eslint.rb
172
+ - lib/danger_plugin.rb
173
+ - lib/eslint/gem_version.rb
174
+ - lib/eslint/plugin.rb
175
+ - spec/eslint_spec.rb
176
+ - spec/fixtures/config/.eslintignore
177
+ - spec/fixtures/config/.eslintrc.json
178
+ - spec/fixtures/javascript/empty.js
179
+ - spec/fixtures/javascript/error.js
180
+ - spec/fixtures/javascript/ignored.js
181
+ - spec/fixtures/javascript/warning.js
182
+ - spec/fixtures/results/alter_ignored.json
183
+ - spec/fixtures/results/alter_warning.json
184
+ - spec/fixtures/results/empty.json
185
+ - spec/fixtures/results/error.json
186
+ - spec/fixtures/results/ignored.json
187
+ - spec/fixtures/results/warning.json
188
+ - spec/spec_helper.rb
189
+ homepage: https://github.com/leonhartX/danger-eslint
190
+ licenses:
191
+ - MIT
192
+ metadata: {}
193
+ post_install_message:
194
+ rdoc_options: []
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ required_rubygems_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ requirements: []
208
+ rubyforge_project:
209
+ rubygems_version: 2.6.11
210
+ signing_key:
211
+ specification_version: 4
212
+ summary: A longer description of danger-eslint.
213
+ test_files:
214
+ - spec/eslint_spec.rb
215
+ - spec/fixtures/config/.eslintignore
216
+ - spec/fixtures/config/.eslintrc.json
217
+ - spec/fixtures/javascript/empty.js
218
+ - spec/fixtures/javascript/error.js
219
+ - spec/fixtures/javascript/ignored.js
220
+ - spec/fixtures/javascript/warning.js
221
+ - spec/fixtures/results/alter_ignored.json
222
+ - spec/fixtures/results/alter_warning.json
223
+ - spec/fixtures/results/empty.json
224
+ - spec/fixtures/results/error.json
225
+ - spec/fixtures/results/ignored.json
226
+ - spec/fixtures/results/warning.json
227
+ - spec/spec_helper.rb