Sha256: cf8080df11b656899a9fa9695c10c096af2b13dced8e572f3439debd5f5b355e

Contents?: true

Size: 698 Bytes

Versions: 9

Compression:

Stored size: 698 Bytes

Contents

require 'pre-commit/checks/js_check'

class PreCommit
  class JshintCheck < JsCheck

    def check_name
      "JSHint"
    end

    def files_to_check
      Utils.staged_files('.').split(" ")
    end

    def config
      config_file = ENV['JSHINT_CONFIG']
      config_file ||= File.exists?(".jshintrc") ? ".jshintrc" : nil

      if config_file
        ExecJS.exec("return (#{File.read(config_file)});")
      else
        {}
      end
    end

    def run_check(file)
      context = ExecJS.compile(File.read(linter_src))
      context.call('JSHINT', File.read(file), config)
    end

    def linter_src
      File.join(PreCommit.root, 'lib', 'support', 'jshint', 'jshint.js')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pre-commit-0.6.1 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.6.0 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.5.0 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.4.0 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.3.1 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.3.0 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.2.0 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.1.19 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.1.18 lib/pre-commit/checks/jshint_check.rb