12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/support/jslint/jslint_checker.rb', line 12
def self.lint_file(file)
errors = []
V8::Context.new do |context|
context.load(LINT_PATH)
context['input'] = lambda{
File.read(file)
}
context['reportErrors'] = lambda{|js_errors|
js_errors.each do |e|
next if e.nil? || OK_REASONS.include?(e.reason)
errors << "\n\e[1;31mJSLINT: #{file}\e[0m"
errors << " Error at line #{e['line'].to_i + 1} " +
"character #{e['character'].to_i + 1}: \e[1;33m#{e['reason']}\e[0m"
errors << "#{e['evidence']}"
end
}
context.eval %{
JSLINT(input(), { evil: true, forin: true, maxerr: 100 });
reportErrors(JSLINT.errors);
}
end
return errors
end
|