Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Handle JSHint fatal errors #1

Merged
merged 1 commit into from

2 participants

Pip Tom Lea
Pip

When JSHint experiences a fatal error, the last element of JSHINT.errors is null. This pull request updates simple_jshint to handle this case without throwing an exception.

Tom Lea
Owner

Looks good. Merging.

Tom Lea cwninja merged commit e70a7e1 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 22, 2013
  1. Pip
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 1 deletion.
  1. +5 −1 lib/simple_jshint.rb
  2. +5 −0 spec/integration_spec.rb
6 lib/simple_jshint.rb
View
@@ -8,7 +8,11 @@ class Result < Array
def initialize(errors)
super errors.map{|error|
- "Line %i: %s : Error %s" % error.values_at("line", "evidence", "reason")
+ if error.nil?
+ "A fatal error occurred"
+ else
+ "Line %i: %s : Error %s" % error.values_at("line", "evidence", "reason")
+ end
}
end
5 spec/integration_spec.rb
View
@@ -17,5 +17,10 @@
result.should be_ok
result.should == [ ]
end
+
+ it "handles fatal errors (JSHINT.errors will have null as last element)" do
+ result = SimpleJSHint.check("<>")
+ result.last.should == "A fatal error occurred"
+ end
end
end
Something went wrong with that request. Please try again.