Sha256: 494c7029ae6f040c05e68b3c25de9c123e3be9a4e210f4548cb856e850b45026

Contents?: true

Size: 789 Bytes

Versions: 15

Compression:

Stored size: 789 Bytes

Contents

require 'pre-commit/checks/js_check'

# This (PreCommit) should be a module
# ... it should also have a cooler name :P
class PreCommit
  class JslintCheck < JsCheck

    attr_accessor :type

    def check_name
      "JSLint"
    end

    def initialize(type = :all)
      @type = type
    end

    def files_to_check
      case @type
      when :new
        Utils.new_files('.').split(" ")
      else
        Utils.staged_files('.').split(" ")
      end
    end

    def run_check(file)
      context = ExecJS.compile(File.read(linter_src))
      if !(context.call('JSLINT', File.read(file)))
        context.exec('return JSLINT.errors;')
      else
        []
      end
    end

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

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pre-commit-0.6.1 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.6.0 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.5.0 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.4.0 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.3.1 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.3.0 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.2.0 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.1.19 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.1.18 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.1.17 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.1.16 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.1.15 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.1.14 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.1.13 lib/pre-commit/checks/jslint_check.rb
pre-commit-0.1.12 lib/pre-commit/checks/jslint_check.rb