class Overcommit::Hook::PreCommit::Stylelint

Runs ‘stylelint` against any modified CSS file.

@see github.com/stylelint/stylelint

Constants

MESSAGE_REGEX

example of output: index.css: line 4, col 4, error - Expected indentation of 2 spaces (indentation)

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/stylelint.rb, line 13
def run
  result = execute(command, args: applicable_files)
  output = result.stdout + result.stderr.chomp
  return :pass if result.success? && output.empty?

  extract_messages(
    output.split("\n"),
    MESSAGE_REGEX
  )
end