-
-
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.
Git Hook Manager & Runner: husky (#20)
In GH-17 lint-staged [1] was added, a Git Hook [2] run linters against staged files before each commit. To automatically run this and other hooks that might be added later on, the hook manager and runner husky [3] is used. Like the already added tools Prettier [4], remark-lint [5] and lint-staged [6] it is (unfortunately) also written in JavaScript again Since NodeJS [7] is therefore already a development dependency it doesn't really matter that husky is another NPM package too. Unlike these previous tools there are indeed alternatives written in Go [8] like lefthook [9] or quickhook [10], but it requires time to test and evaluate them before actually replacing husky. Also a long as there are no comparable alternatives to the already used tools listed above, this template would be more complex by requiring both Node and Go as development dependency. Therefore husky takes over the part as hook manager & runner since it is a stable, production-proven and advanced project that I already use in almost any other project setup. >>> Configuration The `.huskyrc.js` configuration file is placed in the project root and includes the command to run for any supported Git hook [11]. Initially it contains entries for the following hooks: - `pre-commit` - Runs lint-staged (GH-17) before each commit to ensure all staged files are compliant to all style guides. [1]: https://github.com/okonet/lint-staged [2]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks [3]: https://github.com/typicode/husky [4]: #13 [5]: #15 [6]: #17 [7]: https://nodejs.org [8]: https://go.dev [9]: https://github.com/Arkweid/lefthook [10]: https://github.com/dirk/quickhook [11]: https://github.com/typicode/husky/blob/master/DOCS.md#supported-hooks Resolves GH-19
- Loading branch information
Showing
3 changed files
with
115 additions
and
0 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,15 @@ | ||
/* | ||
* Copyright (c) 2020-present Sven Greb <[email protected]> | ||
* This source code is licensed under the MIT license found in the LICENSE file. | ||
*/ | ||
|
||
/** | ||
* The configuration for husky. | ||
* | ||
* @see https://github.com/typicode/husky | ||
*/ | ||
module.exports = { | ||
hooks: { | ||
"pre-commit": "lint-staged", | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,6 +125,11 @@ chalk@^4.0.0: | |
ansi-styles "^4.1.0" | ||
supports-color "^7.1.0" | ||
|
||
ci-info@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" | ||
integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== | ||
|
||
clean-stack@^2.0.0: | ||
version "2.2.0" | ||
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" | ||
|
@@ -184,6 +189,11 @@ commander@^5.1.0: | |
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae" | ||
integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg== | ||
|
||
compare-versions@^3.6.0: | ||
version "3.6.0" | ||
resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.6.0.tgz#1a5689913685e5a87637b8d3ffca75514ec41d62" | ||
integrity sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA== | ||
|
||
[email protected]: | ||
version "0.0.1" | ||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" | ||
|
@@ -332,6 +342,21 @@ fill-range@^7.0.1: | |
dependencies: | ||
to-regex-range "^5.0.1" | ||
|
||
find-up@^4.0.0: | ||
version "4.1.0" | ||
resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" | ||
integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== | ||
dependencies: | ||
locate-path "^5.0.0" | ||
path-exists "^4.0.0" | ||
|
||
find-versions@^3.2.0: | ||
version "3.2.0" | ||
resolved "https://registry.yarnpkg.com/find-versions/-/find-versions-3.2.0.tgz#10297f98030a786829681690545ef659ed1d254e" | ||
integrity sha512-P8WRou2S+oe222TOCHitLy8zj+SIsVJh52VP4lvXkaFVnOFFdoWv1H1Jjvel1aI6NCFOAaeAVm8qrI0odiLcww== | ||
dependencies: | ||
semver-regex "^2.0.0" | ||
|
||
format@^0.2.0: | ||
version "0.2.2" | ||
resolved "https://registry.yarnpkg.com/format/-/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b" | ||
|
@@ -391,6 +416,22 @@ human-signals@^1.1.1: | |
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" | ||
integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== | ||
|
||
husky@^4.2.5: | ||
version "4.2.5" | ||
resolved "https://registry.yarnpkg.com/husky/-/husky-4.2.5.tgz#2b4f7622673a71579f901d9885ed448394b5fa36" | ||
integrity sha512-SYZ95AjKcX7goYVZtVZF2i6XiZcHknw50iXvY7b0MiGoj5RwdgRQNEHdb+gPDPCXKlzwrybjFjkL6FOj8uRhZQ== | ||
dependencies: | ||
chalk "^4.0.0" | ||
ci-info "^2.0.0" | ||
compare-versions "^3.6.0" | ||
cosmiconfig "^6.0.0" | ||
find-versions "^3.2.0" | ||
opencollective-postinstall "^2.0.2" | ||
pkg-dir "^4.2.0" | ||
please-upgrade-node "^3.2.0" | ||
slash "^3.0.0" | ||
which-pm-runs "^1.0.0" | ||
|
||
import-fresh@^3.1.0: | ||
version "3.2.1" | ||
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66" | ||
|
@@ -528,6 +569,13 @@ load-json-file@^4.0.0: | |
pify "^3.0.0" | ||
strip-bom "^3.0.0" | ||
|
||
locate-path@^5.0.0: | ||
version "5.0.0" | ||
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" | ||
integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== | ||
dependencies: | ||
p-locate "^4.1.0" | ||
|
||
log-symbols@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920" | ||
|
@@ -671,13 +719,37 @@ onetime@^5.1.0: | |
dependencies: | ||
mimic-fn "^2.1.0" | ||
|
||
opencollective-postinstall@^2.0.2: | ||
version "2.0.3" | ||
resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259" | ||
integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q== | ||
|
||
p-limit@^2.2.0: | ||
version "2.3.0" | ||
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" | ||
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== | ||
dependencies: | ||
p-try "^2.0.0" | ||
|
||
p-locate@^4.1.0: | ||
version "4.1.0" | ||
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" | ||
integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== | ||
dependencies: | ||
p-limit "^2.2.0" | ||
|
||
p-map@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" | ||
integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== | ||
dependencies: | ||
aggregate-error "^3.0.0" | ||
|
||
p-try@^2.0.0: | ||
version "2.2.0" | ||
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" | ||
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== | ||
|
||
parent-module@^1.0.0: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" | ||
|
@@ -703,6 +775,11 @@ parse-json@^5.0.0: | |
json-parse-better-errors "^1.0.1" | ||
lines-and-columns "^1.1.6" | ||
|
||
path-exists@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" | ||
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== | ||
|
||
path-key@^2.0.1: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" | ||
|
@@ -745,6 +822,13 @@ pify@^3.0.0: | |
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" | ||
integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= | ||
|
||
pkg-dir@^4.2.0: | ||
version "4.2.0" | ||
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" | ||
integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== | ||
dependencies: | ||
find-up "^4.0.0" | ||
|
||
please-upgrade-node@^3.2.0: | ||
version "3.2.0" | ||
resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942" | ||
|
@@ -1522,6 +1606,11 @@ semver-compare@^1.0.0: | |
resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" | ||
integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w= | ||
|
||
semver-regex@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-2.0.0.tgz#a93c2c5844539a770233379107b38c7b4ac9d338" | ||
integrity sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw== | ||
|
||
"semver@2 || 3 || 4 || 5", semver@^5.5.0: | ||
version "5.7.1" | ||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" | ||
|
@@ -1561,6 +1650,11 @@ signal-exit@^3.0.2: | |
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" | ||
integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== | ||
|
||
slash@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" | ||
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== | ||
|
||
slice-ansi@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-3.0.0.tgz#31ddc10930a1b7e0b67b08c96c2f49b77a789787" | ||
|
@@ -1780,6 +1874,11 @@ vfile-location@^2.0.0, vfile-location@^2.0.1: | |
resolved "https://registry.yarnpkg.com/vfile-location/-/vfile-location-2.0.6.tgz#8a274f39411b8719ea5728802e10d9e0dff1519e" | ||
integrity sha512-sSFdyCP3G6Ka0CEmN83A2YCMKIieHx0EDaj5IDP4g1pa5ZJ4FJDvpO0WODLxo4LUX4oe52gmSCK7Jw4SBghqxA== | ||
|
||
which-pm-runs@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb" | ||
integrity sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs= | ||
|
||
which@^1.2.9: | ||
version "1.3.1" | ||
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" | ||
|