Class: PreCommit::Checks::Jslint

Inherits:
Js
  • Object
show all
Defined in:
lib/plugins/pre_commit/checks/jslint.rb

Instance Attribute Summary

Attributes inherited from Plugin

#config, #pluginator

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Js

#call, #display_error, #error_selector, #files_filter

Methods inherited from Plugin

#initialize, #name

Constructor Details

This class inherits a constructor from PreCommit::Checks::Plugin

Class Method Details

.aliasesObject



7
8
9
# File 'lib/plugins/pre_commit/checks/jslint.rb', line 7

def self.aliases
  [ :js_lint, :js_lint_all, :js_lint_new ]
end

.descriptionObject



24
25
26
# File 'lib/plugins/pre_commit/checks/jslint.rb', line 24

def self.description
  "Checks javascript files with JSLint."
end

Instance Method Details

#linter_srcObject



20
21
22
# File 'lib/plugins/pre_commit/checks/jslint.rb', line 20

def linter_src
  File.expand_path("../../../../pre-commit/support/jslint/lint.js", __FILE__)
end

#run_check(file) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/plugins/pre_commit/checks/jslint.rb', line 11

def run_check(file)
  context = ExecJS.compile(File.read(linter_src))
  if !(context.call('JSLINT', File.read(file)))
    context.exec('return JSLINT.errors;')
  else
    []
  end
end