Class: PreCommit::Checks::ClosureLinter

Inherits:
Plugin
  • Object
show all
Defined in:
lib/plugins/pre_commit/checks/closure_linter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject



21
22
23
# File 'lib/plugins/pre_commit/checks/closure_linter.rb', line 21

def self.description
  "Runs closure linter syntax check"
end

Instance Method Details

#alternate_config_fileObject



17
18
19
# File 'lib/plugins/pre_commit/checks/closure_linter.rb', line 17

def alternate_config_file
  '.gjslintrc'
end

#call(staged_files) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/plugins/pre_commit/checks/closure_linter.rb', line 7

def call(staged_files)
  staged_files = staged_files.grep(/\.js$/)
  return if staged_files.empty?

  output = `gjslint #{gjslint_options} #{staged_files.join(" ")}`
  return if output =~ /(\d*) files checked, no errors found(.*)/

  output
end

#gjslint_optionsObject



25
26
27
28
29
# File 'lib/plugins/pre_commit/checks/closure_linter.rb', line 25

def gjslint_options
  return '' unless config_file

  File.readlines(config_file).map(&:chomp).join(' ')
end