Class: PreCommit::Checks::Jshint
- Inherits:
-
Js
- Object
- Plugin
- Js
- PreCommit::Checks::Jshint
show all
- Defined in:
- lib/plugins/pre_commit/checks/jshint.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
Class Method Details
.description ⇒ Object
28
29
30
|
# File 'lib/plugins/pre_commit/checks/jshint.rb', line 28
def self.description
"Checks javascript files with JSHint."
end
|
Instance Method Details
#alternate_config_file ⇒ Object
24
25
26
|
# File 'lib/plugins/pre_commit/checks/jshint.rb', line 24
def alternate_config_file
".jshintrc"
end
|
#js_config ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/plugins/pre_commit/checks/jshint.rb', line 7
def js_config
if config_file
ExecJS.exec("return (#{File.read(config_file)});")
else
{}
end
end
|
#linter_src ⇒ Object
20
21
22
|
# File 'lib/plugins/pre_commit/checks/jshint.rb', line 20
def linter_src
File.expand_path("../../../../pre-commit/support/jshint/jshint.js", __FILE__)
end
|
#run_check(file) ⇒ Object
15
16
17
18
|
# File 'lib/plugins/pre_commit/checks/jshint.rb', line 15
def run_check(file)
context = ExecJS.compile(File.read(linter_src))
context.call("JSHINT", File.read(file), js_config, js_config["globals"])
end
|