jslint-v8 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTlmNDUzNWNjZmExMTQ0OTJmYTdkYWEzOGY1ODE0NTM5OTZiYTFhMg==
4
+ OWIyMDg4ODBiODUwNTYyNmE3Nzg3YmRlYTI5MjE3OTdiZTg4Y2QzOQ==
5
5
  data.tar.gz: !binary |-
6
- NWJmYWJmMjVhOGQ4Y2NhNTkyNmIzNzM1ZWQ0MzFkZWQ5ZDhhMGRkOA==
6
+ YjYzNGQ1OThlOGQ1ODZjZTQ2ZWZiYTgyYzlmMmFiNWE2NjkxODJhOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzkyODk3OTZmY2JiMDVmYTZlZDIyMjYzYWZlNTk1ZmM2N2U2MzRlYzBiY2Y5
10
- NzViNTczMDRhNzM2MzgxNzQ2OTVhYmU0OTUzYjBjYmNlMzA5YTExNWY4MmRi
11
- OTE0Y2JkYzc5Zjc3YWYwYzZiNmFlODM2ZWYyYTkyYmIwNGEwNGE=
9
+ NTJmMDcwNDdhZmJhMzY5MGFhNDRiMmJhNmYxYzQwMzZhZjQ0ODMxOThkM2Q3
10
+ YmIyZTllMTE5ZTljMWI2OWVlODQ4OTI0Yjc5YWVlOWQ4NDgwYjFlZTc1ZTNj
11
+ YmRjYjA5MmU2MjcyNTdhZmJiMTA5MmVmZGE0NTdmY2RlMTg0NjI=
12
12
  data.tar.gz: !binary |-
13
- YThiNzExZmIwZjc5MjBiODU1NTZmODZmMDQyMGE3NmJjZjBlZTg4YTRlMzY5
14
- MDc3ZGEzMWM0ODBmZTkzMzgxODQwNmMwMWRhMjU3YTNkOTg4YmM0Y2M1YmQ1
15
- Y2YzNDM2YTZhNDgyOTFkNzM4ZGY0ODE0MTJjNzgyOGM0NzE5NmY=
13
+ YWQ1N2ViNzE0MTIxODUyMjNjNzc0Y2RkNjk0OTY5MDE4YzlmN2IwMWUzZDky
14
+ OTUzYjFmYTE2YzJiMDNhMmRmMTNkYWI4OTMyMGE1YjdlN2ZjMWM2N2RiNTA5
15
+ OWNhZDk2MTY2NmVhMzkwZTJiMGY5OTYyMzJkNjhlYTBjODYwMmU=
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require File.expand_path("../lib/jslint-v8", File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift File.expand_path("../lib", File.dirname(__FILE__))
3
+
4
+ require "jslint-v8"
4
5
 
5
6
  def print_usage
6
7
  STDERR.puts JSLintV8::OptionParser.new.help
@@ -27,7 +28,11 @@ end
27
28
  print_usage if ARGV.empty?
28
29
 
29
30
  # set up a formatter for standard output
30
- formatter = JSLintV8::Formatter.new(STDOUT)
31
+ if (!parser.options[:json])
32
+ formatter = JSLintV8::Formatter.new(STDOUT)
33
+ else
34
+ formatter = JSLintV8::Json.new(STDOUT)
35
+ end
31
36
 
32
37
  # set up a runner
33
38
  runner = JSLintV8::Runner.new(ARGV)
@@ -1,8 +1,9 @@
1
1
  module JSLintV8 end
2
2
 
3
- require File.expand_path("jslint-v8/runner", File.dirname(__FILE__))
4
- require File.expand_path("jslint-v8/rake_task", File.dirname(__FILE__))
5
- require File.expand_path("jslint-v8/lint_error", File.dirname(__FILE__))
6
- require File.expand_path("jslint-v8/formatter", File.dirname(__FILE__))
7
- require File.expand_path("jslint-v8/option_parser", File.dirname(__FILE__))
8
- require File.expand_path("jslint-v8/version", File.dirname(__FILE__))
3
+ require 'jslint-v8/runner'
4
+ require 'jslint-v8/rake_task'
5
+ require 'jslint-v8/lint_error'
6
+ require 'jslint-v8/formatter'
7
+ require 'jslint-v8/json'
8
+ require 'jslint-v8/option_parser'
9
+ require 'jslint-v8/version'
@@ -0,0 +1,39 @@
1
+ require 'json'
2
+
3
+ module JSLintV8
4
+ class Json
5
+ attr_reader :output_stream
6
+
7
+ def initialize(stream)
8
+ @output_stream = stream
9
+ end
10
+
11
+ def tick(errors)
12
+ end
13
+
14
+ def summary(tested_files, lint_result)
15
+ if lint_result.keys.any?
16
+ output = lint_result.map do |file_errors|
17
+ { file_errors[0] =>
18
+ file_errors[1].map do |errors|
19
+ { "line" => errors.line_number,
20
+ "column" => errors.character,
21
+ "reason" => errors.reason,
22
+ "evidence" => errors.evidence
23
+ }
24
+ end
25
+ }
26
+ end
27
+ print_error_summary(output)
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def print_error_summary(result)
34
+ out = output_stream
35
+ out.print JSON.dump(result)
36
+ end
37
+
38
+ end
39
+ end
@@ -25,6 +25,10 @@ module JSLintV8
25
25
  end
26
26
  end
27
27
 
28
+ on("--json", "Return output in JSON format") do |j|
29
+ options[:json] = j
30
+ end
31
+
28
32
  on("-h", "--help", "Show this message") do
29
33
  STDERR.puts self.help
30
34
  exit(-1)
@@ -3,7 +3,7 @@ module JSLintV8
3
3
  module Version
4
4
  MAJOR = 1
5
5
  MINOR = 1
6
- PATCH = 2
6
+ PATCH = 3
7
7
  BUILD = nil
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -9,6 +9,10 @@ def erb_fixture(basename)
9
9
  ::ERB.new(File.read(erb_filename(basename))).result
10
10
  end
11
11
 
12
+ def json_fixture(basename)
13
+ File.read(json_filename(basename))
14
+ end
15
+
12
16
  def erb_filename(basename)
13
17
  File.expand_path("fixtures/#{basename}.txt.erb", File.dirname(__FILE__))
14
18
  end
@@ -16,3 +20,7 @@ end
16
20
  def js_filename(basename)
17
21
  File.expand_path("fixtures/#{basename}.js", File.dirname(__FILE__))
18
22
  end
23
+
24
+ def json_filename(basename)
25
+ File.expand_path("fixtures/#{basename}.json", File.dirname(__FILE__))
26
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path('helper', File.dirname(__FILE__))
2
+ require 'erb'
3
+ require 'stringio'
4
+ require 'json'
5
+
6
+ class TestJsonFormatter < Test::Unit::TestCase
7
+
8
+ def setup
9
+ @output = String.new
10
+ @output_stream = StringIO.new(@output, "w+")
11
+
12
+ @formatter = JSLintV8::Json.new(@output_stream)
13
+ end
14
+
15
+ def test_summary_with_errors
16
+ error_1 = JSLintV8::LintError.new("line" => 42, "character" => 10, "reason" => "because i can")
17
+ error_2 = JSLintV8::LintError.new("line" => 43, "character" => 3, "reason" => "a proof is not a proof")
18
+ error_3 = JSLintV8::LintError.new("line" => 139, "character" => 12, "reason" => "undefined global 'foo'")
19
+ result = {
20
+ "foo" => [error_1, error_2],
21
+ "bar" => [error_3]
22
+ }
23
+
24
+ @formatter.summary(%w(foo bar baz one two three), result)
25
+
26
+ assert_equal json_fixture("json-formatter-summary-errors").strip, @output
27
+ end
28
+
29
+ def test_summary_with_no_errors
30
+ @formatter.summary(%w(foo bar), {})
31
+
32
+ assert_equal json_fixture("json-formatter-summary-noerrors"), @output
33
+ end
34
+ end
@@ -27,7 +27,7 @@ class TestTask < Test::Unit::TestCase
27
27
  end
28
28
 
29
29
  def test_default_description
30
- JSLintV8::RakeTask.new
30
+ JSLintV8::RakeTask.new
31
31
 
32
32
  task = Rake.application.lookup("lint")
33
33
 
@@ -35,7 +35,7 @@ class TestTask < Test::Unit::TestCase
35
35
  end
36
36
 
37
37
  def test_default_include_pattern
38
- task = JSLintV8::RakeTask.new
38
+ task = JSLintV8::RakeTask.new
39
39
 
40
40
  assert_equal "app/javascripts/**/*.js", task.include_pattern
41
41
  end
@@ -63,9 +63,9 @@ class TestTask < Test::Unit::TestCase
63
63
 
64
64
  task = JSLintV8::RakeTask.new do |task|
65
65
  task.name = "foo"
66
-
66
+
67
67
  task.description = "Points out the bad codezzzz"
68
-
68
+
69
69
  task.include_pattern = "js/**/*.js"
70
70
  task.exclude_pattern = "js/**/*.txt"
71
71
 
@@ -93,7 +93,7 @@ class TestTask < Test::Unit::TestCase
93
93
  task.exclude_pattern = File.expand_path("fixtures/*.erb", File.dirname(__FILE__))
94
94
  end
95
95
 
96
- expected_files = Dir.glob(File.expand_path("fixtures/*.js", File.dirname(__FILE__))).sort
96
+ expected_files = Dir.glob(File.expand_path("fixtures/*.{js,json}", File.dirname(__FILE__))).sort
97
97
 
98
98
  assert_equal expected_files, task.files_to_run
99
99
  end
@@ -151,4 +151,4 @@ class TestTask < Test::Unit::TestCase
151
151
 
152
152
  assert_equal erb_fixture("cli-suite-expected-output"), result
153
153
  end
154
- end
154
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jslint-v8
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-08 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: therubyracer
@@ -68,6 +68,7 @@ files:
68
68
  - lib/jslint-v8.rb
69
69
  - lib/jslint-v8/formatter.rb
70
70
  - lib/jslint-v8/js/jslint.js
71
+ - lib/jslint-v8/json.rb
71
72
  - lib/jslint-v8/lint_error.rb
72
73
  - lib/jslint-v8/option_parser.rb
73
74
  - lib/jslint-v8/rake_task.rb
@@ -77,6 +78,7 @@ files:
77
78
  - test/suite.rb
78
79
  - test/test_cli.rb
79
80
  - test/test_formatter.rb
81
+ - test/test_json.rb
80
82
  - test/test_lint_error.rb
81
83
  - test/test_runner.rb
82
84
  - test/test_task.rb
@@ -99,15 +101,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
101
  version: '0'
100
102
  requirements: []
101
103
  rubyforge_project:
102
- rubygems_version: 2.2.2
104
+ rubygems_version: 2.4.3
103
105
  signing_key:
104
106
  specification_version: 4
105
107
  summary: JSLint CLI and rake tasks via therubyracer (JavaScript V8 gem)
106
108
  test_files:
107
- - test/test_formatter.rb
108
- - test/helper.rb
109
- - test/test_cli.rb
110
- - test/test_lint_error.rb
109
+ - test/suite.rb
111
110
  - test/test_runner.rb
111
+ - test/helper.rb
112
112
  - test/test_task.rb
113
- - test/suite.rb
113
+ - test/test_lint_error.rb
114
+ - test/test_formatter.rb
115
+ - test/test_cli.rb
116
+ - test/test_json.rb