Module: JSLint

Defined in:
lib/jslint.rb,
lib/jslint/testtask.rb

Defined Under Namespace

Classes: Result, TestTask

Class Method Summary collapse

Class Method Details

.contextObject

Internal: The ExecJS Context in which to run JSLINT().

Provides a small helper function JSLINTR to return both the JSLINT() return value and the JSLINT.errors object.



9
10
11
12
13
14
15
# File 'lib/jslint.rb', line 9

def self.context
  ExecJS.compile(
    JSLint::Source.contents +
    "function JSLINTR(source, options) { " +
    "return [JSLINT(source, options),JSLINT.errors]; };"
  )
end

.run(source, options = {}) ⇒ Object

Public: Run JSLint over some JavaScript source.

source - some String-like or IO-like JavaScript source. options - Hash of options passed directly to JSLINT (default: {})



21
22
23
24
# File 'lib/jslint.rb', line 21

def self.run(source, options={})
  source = source.respond_to?(:read) ? source.read : source
  Result.new(*context.call("JSLINTR", source, options))
end