Class: Overcommit::Hook::PreCommit::EsLint
- Defined in:
- lib/overcommit/hook/pre_commit/es_lint.rb
Overview
Runs ‘eslint` against any modified JavaScript files.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#applicable_files, #command, #description, #enabled?, #execute, #execute_in_background, #flags, #in_path?, #initialize, #name, #quiet?, #required?, #required_executable, #required_libraries, #run?, #run_and_transform, #skip?
Constructor Details
This class inherits a constructor from Overcommit::Hook::Base
Instance Method Details
#run ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/overcommit/hook/pre_commit/es_lint.rb', line 6 def run result = execute(command + applicable_files) output = result.stdout.chomp return :pass if result.success? && output.empty? # example message: # path/to/file.js: line 1, col 0, Error - Error message (ruleName) ( output.split("\n").grep(/Warning|Error/), /^(?<file>[^:]+):[^\d]+(?<line>\d+).*?(?<type>Error|Warning)/, lambda { |type| type.downcase.to_sym } ) end |