jslint-v8 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +23 -0
- data/README.markdown +1 -0
- data/bin/jslint-v8 +24 -0
- data/lib/jslint-v8/formatter.rb +47 -0
- data/lib/jslint-v8/js/jslint.js +538 -0
- data/lib/jslint-v8/lint_error.rb +14 -0
- data/lib/jslint-v8/rake_task.rb +79 -0
- data/lib/jslint-v8/runner.rb +82 -0
- data/lib/jslint-v8/version.rb +11 -0
- data/lib/jslint-v8.rb +6 -0
- data/test/helper.rb +18 -0
- data/test/suite.rb +5 -0
- data/test/test_cli.rb +44 -0
- data/test/test_formatter.rb +51 -0
- data/test/test_lint_error.rb +32 -0
- data/test/test_runner.rb +141 -0
- data/test/test_task.rb +126 -0
- metadata +133 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jslint-v8 (1.0.0)
|
5
|
+
therubyracer (~> 0.9.4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
libv8 (3.3.10.2)
|
11
|
+
rake (0.9.2)
|
12
|
+
test-unit (2.3.2)
|
13
|
+
therubyracer (0.9.4)
|
14
|
+
libv8 (~> 3.3.10)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
java
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
jslint-v8!
|
22
|
+
rake
|
23
|
+
test-unit
|
data/README.markdown
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/whoward/jslint-v8.png)](http://travis-ci.org/whoward/jslint-v8)
|
data/bin/jslint-v8
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require File.expand_path("../lib/jslint-v8", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
if ARGV.empty?
|
6
|
+
puts "usage: #{File.basename(__FILE__)} FILES"
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
formatter = JSLintV8::Formatter.new(STDOUT)
|
11
|
+
|
12
|
+
# get a list of all failed files, printing . or * along the way depending on the result
|
13
|
+
lint_result = JSLintV8::Runner.new(ARGV).run do |file, errors|
|
14
|
+
formatter.tick(errors)
|
15
|
+
end
|
16
|
+
|
17
|
+
# put a separator line in between the ticks and any summary
|
18
|
+
print "\n"
|
19
|
+
|
20
|
+
# print a summary of failed files
|
21
|
+
formatter.summary(ARGV, lint_result)
|
22
|
+
|
23
|
+
# exit with the status code of the number of errors
|
24
|
+
exit(lint_result.values.flatten.length)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
module JSLintV8
|
3
|
+
class Formatter
|
4
|
+
attr_reader :output_stream
|
5
|
+
|
6
|
+
def initialize(stream)
|
7
|
+
@output_stream = stream
|
8
|
+
end
|
9
|
+
|
10
|
+
def tick(errors)
|
11
|
+
output_stream.print(errors.any?? "*" : ".")
|
12
|
+
output_stream.flush
|
13
|
+
end
|
14
|
+
|
15
|
+
def summary(tested_files, lint_result)
|
16
|
+
if lint_result.keys.any?
|
17
|
+
print_error_summary(lint_result)
|
18
|
+
output_stream.print "\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
print_count_summary(tested_files, lint_result)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def print_error_summary(result)
|
26
|
+
out = output_stream
|
27
|
+
|
28
|
+
out.print "\nFailures:\n\n"
|
29
|
+
|
30
|
+
result.each do |file, errors|
|
31
|
+
out.print "#{file}:\n"
|
32
|
+
errors.each do |error|
|
33
|
+
out.print " line #{error.line_number} character #{error.character} #{error.reason}\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def print_count_summary(tested_files, lint_result)
|
39
|
+
file_count = tested_files.length
|
40
|
+
failure_count = lint_result.keys.length
|
41
|
+
error_count = lint_result.values.flatten.length
|
42
|
+
|
43
|
+
output_stream.print "#{file_count} files, #{failure_count} failures, #{error_count} errors\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|