forked from thewca/worldcubeassociation.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from using the
pre_commit
gem to overcommit
`pre_commit` was starting to show its age: - It uses the now defunct `scss-lint` package. See jish/pre-commit#278 and thewca#3649. - It bundles an older version of JsHint that does not have support for ES{7,8,9}. I've configured `overcommit` to behave similarly to `pre_commit`. Here's a list of the specific things I've configured and tested: + css linting using stylelint (this brings us one step closer to getting off of `ruby-sass`: thewca#3649) + illegal char check (such as <<<) + rubocop + jshint (with support for ES9!)
- Loading branch information
Showing
15 changed files
with
120 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module Overcommit::Hook::PreCommit | ||
class IllegalStrings < Base | ||
def run | ||
errors = [] | ||
|
||
illegal_strs = { | ||
("<" * 3) => "conflict marker", | ||
"\t" => "tab", | ||
"\r" => "carriage return", | ||
"\uFEFF" => "byte order marker (BOM)", | ||
("WCA " + "id") => "We prefer 'WCA ID', see https://github.com/thewca/worldcubeassociation.org/issues/268", | ||
} | ||
applicable_files.each do |file| | ||
File.foreach(file).with_index do |line, line_num| | ||
illegal_strs.each do |illegal_str, description| | ||
index = line.index illegal_str | ||
if index | ||
errors << "#{file}:#{line_num+1}:#{index+1} Found illegal string: #{description}" | ||
end | ||
end | ||
end | ||
end | ||
|
||
return :fail, errors.join("\n") if errors.any? | ||
|
||
:pass | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"esnext": true, | ||
"esversion": 8, | ||
"asi": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Use this file to configure the Overcommit hooks you wish to use. This will | ||
# extend the default configuration defined in: | ||
# https://github.com/sds/overcommit/blob/master/config/default.yml | ||
# | ||
# At the topmost level of this YAML file is a key representing type of hook | ||
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can | ||
# customize each hook, such as whether to only run it on certain files (via | ||
# `include`), whether to only display output if it fails (via `quiet`), etc. | ||
# | ||
# For a complete list of hooks, see: | ||
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook | ||
# | ||
# For a complete list of options that you can use to customize hooks, see: | ||
# https://github.com/sds/overcommit#configuration | ||
# | ||
# Uncomment the following lines to make the configuration take effect. | ||
|
||
PreCommit: | ||
ALL: | ||
exclude: | ||
- 'regulations/**/*' | ||
- 'webroot/**/*' | ||
- 'WcaOnRails/vendor/**/*' | ||
- 'WcaOnRails/tmp/**/*' | ||
- 'WcaOnRails/db/structure.sql' | ||
- 'WcaOnRails/node_modules/**/*' | ||
- 'chef/**/*' | ||
- '.gitmodules' | ||
- '**/*.pdf' | ||
- '**/*.jpg' | ||
- '**/*.png' | ||
- '**/*.gif' | ||
- '**/*.xls' | ||
- '**/*.ico' | ||
- '**/*.jar' | ||
- '**/*.svg' | ||
|
||
RuboCop: | ||
enabled: true | ||
on_warn: fail # Treat all warnings as failures | ||
|
||
IllegalStrings: | ||
enabled: true | ||
|
||
JsHint: | ||
enabled: true | ||
required_executable: 'WcaOnRails/bin/yarn' | ||
flags: ['run', '-s', 'jshint', '--verbose'] | ||
|
||
Stylelint: | ||
enabled: true | ||
required_executable: 'WcaOnRails/bin/yarn' | ||
flags: ['run', '-s', 'stylelint', '-f', 'compact'] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
extends: "stylelint-config-recommended-scss", | ||
rules: { | ||
"no-descending-specificity": null, | ||
"block-no-empty": null, | ||
"font-family-no-missing-generic-family-keyword": null | ||
}, | ||
ignoreFiles: ["WcaOnRails/app/assets/stylesheets/selectize.default.css"] | ||
}; |