Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ issue](https://github.com/brigade/overcommit/issues/238) for more details.
* [SlimLint](lib/overcommit/hook/pre_commit/slim_lint.rb)
* [Sqlint](lib/overcommit/hook/pre_commit/sqlint.rb)
* [Standard](lib/overcommit/hook/pre_commit/standard.rb)
* [StyleLint](lib/overcommit/hook/pre_commit/style_lint.rb)
* [TrailingWhitespace](lib/overcommit/hook/pre_commit/trailing_whitespace.rb)
* [TravisLint](lib/overcommit/hook/pre_commit/travis_lint.rb)
* [TsLint](lib/overcommit/hook/pre_commit/ts_lint.rb)
Expand Down
9 changes: 9 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,15 @@ PreCommit:
install_command: 'npm install -g standard'
include: '**/*.js'

StyleLint:
enabled: false
description: 'Analyze with Stylelint'
required_executable: 'stylelint'
install_command: 'npm install -g stylelint'
include:
- '**/*.scss'
- '**/*.css'

TsLint:
enabled: false
description: 'Analyze with TSLint'
Expand Down
23 changes: 23 additions & 0 deletions lib/overcommit/hook/pre_commit/style_lint.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Overcommit::Hook::PreCommit
# Runs `stylelint` against any modified CSS files.
#
# @see https://github.com/stylelint/stylelint
class StyleLint < Base
MESSAGE_REGEX = /(?<type>✖|⚠)
((?<file>(\/\D+)*\D+\.\D+))
((?<line>\d+):)
/x

def run
result = execute(command, args: applicable_files)
output = result.stdout.chomp
return :pass if result.success? && output.empty?

extract_messages(
output.split("\n").reject(&:empty?),
MESSAGE_REGEX,
lambda { |type| type.downcase.to_sym }
)
end
end
end
2 changes: 1 addition & 1 deletion lib/overcommit/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# Defines the gem version.
module Overcommit
VERSION = '0.41.0'.freeze
VERSION = '0.42.0'.freeze
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this out for now. We'll update the version when we release the next version. Thanks!

end