Class: PreCommit::Checks::Csslint

Inherits:
Js
  • Object
show all
Defined in:
lib/plugins/pre_commit/checks/csslint.rb

Constant Summary collapse

SOURCE =
"https://github.com/stubbornella/csslint/blob/v0.10.0/release/csslint.js"

Instance Attribute Summary

Attributes inherited from Plugin

#config, #pluginator

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Js

#call, #display_error

Methods inherited from Plugin

#initialize, #name

Constructor Details

This class inherits a constructor from PreCommit::Checks::Plugin

Class Method Details

.descriptionObject


26
27
28
# File 'lib/plugins/pre_commit/checks/csslint.rb', line 26

def self.description
  "Checks CSS files with CSSLint."
end

Instance Method Details

#error_selectorObject


18
19
20
# File 'lib/plugins/pre_commit/checks/csslint.rb', line 18

def error_selector
  'message'
end

#files_filter(staged_files) ⇒ Object


22
23
24
# File 'lib/plugins/pre_commit/checks/csslint.rb', line 22

def files_filter(staged_files)
  staged_files.grep(/\.css$/)
end

#linter_srcObject


14
15
16
# File 'lib/plugins/pre_commit/checks/csslint.rb', line 14

def linter_src
  File.expand_path("../../../../pre-commit/support/csslint/csslint.js", __FILE__)
end

#run_check(file) ⇒ Object


9
10
11
12
# File 'lib/plugins/pre_commit/checks/csslint.rb', line 9

def run_check(file)
  context = ExecJS.compile(File.read(linter_src))
  context.call("CSSLint.verify", File.read(file))["messages"]
end