Sha256: 5e15529f69a62da0a8116cf7c1df35ed2dafc338775bda347d6336058f01b2d5

Contents?: true

Size: 605 Bytes

Versions: 5

Compression:

Stored size: 605 Bytes

Contents

require 'pre-commit/checks/js_check'

module PreCommit
  class JshintCheck < JsCheck
    def self.config
      if config_file = [ENV['JSHINT_CONFIG'], ".jshintrc"].compact.detect { |f| File.exist?(f) }
        ExecJS.exec("return (#{File.read(config_file)});")
      else
        {}
      end
    end

    def self.check_name
      "JSHint"
    end

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

    def self.linter_src
      File.expand_path("../../support/jshint/jshint.js", __FILE__)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pre-commit-0.11.0 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.10.0 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.9.2 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.9.1 lib/pre-commit/checks/jshint_check.rb
pre-commit-0.9.0 lib/pre-commit/checks/jshint_check.rb