From c660f51e6e8792b0234f7a7281291925d7d13044 Mon Sep 17 00:00:00 2001 From: Raphaelle Cantin Date: Wed, 23 Oct 2024 16:16:14 +0100 Subject: [PATCH 1/5] Remove husky from Cardigan and upgrade at root --- cardigan/package.json | 1 - content/webapp/components/Map/Map.tsx | 2 - package.json | 2 +- yarn.lock | 72 ++------------------------- 4 files changed, 6 insertions(+), 71 deletions(-) diff --git a/cardigan/package.json b/cardigan/package.json index be1988e051..97135d2cf9 100644 --- a/cardigan/package.json +++ b/cardigan/package.json @@ -18,7 +18,6 @@ "@storybook/react": "^8.3.5", "@storybook/theming": "^8.3.5", "chromatic": "^6.21.1", - "husky": "^4.3.0", "next": "13.5.7", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/content/webapp/components/Map/Map.tsx b/content/webapp/components/Map/Map.tsx index 7f3cb03ec6..abe704dea4 100644 --- a/content/webapp/components/Map/Map.tsx +++ b/content/webapp/components/Map/Map.tsx @@ -52,13 +52,11 @@ const Map: FunctionComponent = ({ }, }; const map = new google.maps.Map(mapCanvas as Element, mapOptions); - /* eslint-disable @typescript-eslint/no-unused-vars */ const marker = new google.maps.Marker({ position: latLng, map, title, }); - /* eslint-enable @typescript-eslint/no-unused-vars */ }); return () => { /** diff --git a/package.json b/package.json index 0662beb31c..139fecec62 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "eslint-plugin-react": "^7.33.1", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-standard": "^5.0.0", - "husky": "^4.3.0", + "husky": "^9.1.6", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "lint-staged": "^14.0.1", diff --git a/yarn.lock b/yarn.lock index aaaeff9aa0..6bd1067045 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6852,11 +6852,6 @@ chrome-trace-event@^1.0.2: resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz#05bffd7ff928465093314708c93bdfa9bd1f0f5b" integrity sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ== -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== - ci-info@^3.2.0: version "3.9.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" @@ -7091,11 +7086,6 @@ commondir@^1.0.1: resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg== -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== - concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -7236,7 +7226,7 @@ cors@^2.8.5: object-assign "^4" vary "^1" -cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: +cosmiconfig@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6" integrity sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA== @@ -8906,13 +8896,6 @@ find-up@^6.3.0: locate-path "^7.1.0" path-exists "^5.0.0" -find-versions@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/find-versions/-/find-versions-4.0.0.tgz#3c57e573bf97769b8cb8df16934b627915da4965" - integrity sha512-wgpWy002tA+wgmO27buH/9KzyEOQnKsG/R0yrcjPT9BOFm0zRBVQbZ95nRGXWMywS8YR5knRbpohio0bcJABxQ== - dependencies: - semver-regex "^3.1.2" - flat-cache@^3.0.4: version "3.2.0" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.2.0.tgz#2c0c2d5040c99b1632771a9d105725c0115363ee" @@ -9632,21 +9615,10 @@ humanize-number@0.0.2: resolved "https://registry.yarnpkg.com/humanize-number/-/humanize-number-0.0.2.tgz#11c0af6a471643633588588048f1799541489c18" integrity sha512-un3ZAcNQGI7RzaWGZzQDH47HETM4Wrj6z6E4TId8Yeq9w5ZKUVB1nrT2jwFheTUjEmqcgTjXDc959jum+ai1kQ== -husky@^4.3.0: - version "4.3.8" - resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.8.tgz#31144060be963fd6850e5cc8f019a1dfe194296d" - integrity sha512-LCqqsB0PzJQ/AlCgfrfzRe3e3+NvmefAdKQhRYpxS4u6clblBoDdzzvHi8fmxKRzvMxPY/1WZWzomPZww0Anow== - dependencies: - chalk "^4.0.0" - ci-info "^2.0.0" - compare-versions "^3.6.0" - cosmiconfig "^7.0.0" - find-versions "^4.0.0" - opencollective-postinstall "^2.0.2" - pkg-dir "^5.0.0" - please-upgrade-node "^3.2.0" - slash "^3.0.0" - which-pm-runs "^1.0.0" +husky@^9.1.6: + version "9.1.6" + resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.6.tgz#e23aa996b6203ab33534bdc82306b0cf2cb07d6c" + integrity sha512-sqbjZKK7kf44hfdE94EoX8MZNk0n7HeW37O4YrVGCF4wzgQjp+akPAkfUK5LZ6KuR/6sqeAVuXHji+RzQgOn5A== iconv-lite@0.4.24, iconv-lite@^0.4.24: version "0.4.24" @@ -12016,11 +11988,6 @@ open@^8.0.4, open@^8.4.2: is-docker "^2.1.1" is-wsl "^2.2.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== - opener@^1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598" @@ -12389,13 +12356,6 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" -pkg-dir@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-5.0.0.tgz#a02d6aebe6ba133a928f74aec20bafdfe6b8e760" - integrity sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA== - dependencies: - find-up "^5.0.0" - pkg-dir@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-7.0.0.tgz#8f0c08d6df4476756c5ff29b3282d0bab7517d11" @@ -12412,13 +12372,6 @@ pkg-types@^1.2.0: mlly "^1.7.2" pathe "^1.1.2" -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" - integrity sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg== - dependencies: - semver-compare "^1.0.0" - pnp-webpack-plugin@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/pnp-webpack-plugin/-/pnp-webpack-plugin-1.7.0.tgz#65741384f6d8056f36e2255a8d67ffc20866f5c9" @@ -13393,16 +13346,6 @@ search-query-parser@^1.3.0: resolved "https://registry.yarnpkg.com/search-query-parser/-/search-query-parser-1.6.0.tgz#d69ade33f3685cae25613a70189b7b18970b46f1" integrity sha512-bhf+phLlKF38nuniwLcVHWPArHGdzenlPhPi955CR3vm1QQifXIuPHwAffhjapojdVVzmv4hgIJ6NOX1d/w+Uw== -semver-compare@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" - integrity sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow== - -semver-regex@^3.1.2: - version "3.1.4" - resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-3.1.4.tgz#13053c0d4aa11d070a2f2872b6b1e3ae1e1971b4" - integrity sha512-6IiqeZNgq01qGf0TId0t3NvKzSvUsjcpdEO3AQNeIjR6A2+ckTnQlDpl4qu1bjRv0RzN3FP9hzFmws3lKqRWkA== - semver@^5.6.0, semver@^5.7.1: version "5.7.2" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" @@ -15108,11 +15051,6 @@ which-collection@^1.0.1, which-collection@^1.0.2: is-weakmap "^2.0.2" is-weakset "^2.0.3" -which-pm-runs@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.1.0.tgz#35ccf7b1a0fce87bd8b92a478c9d045785d3bf35" - integrity sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA== - which-typed-array@^1.1.13, which-typed-array@^1.1.14, which-typed-array@^1.1.15, which-typed-array@^1.1.2: version "1.1.15" resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.15.tgz#264859e9b11a649b388bfaaf4f767df1f779b38d" From d5a85009672ed2e01fc0115931d7d412c6e1dd4c Mon Sep 17 00:00:00 2001 From: Raphaelle Cantin Date: Wed, 23 Oct 2024 16:24:22 +0100 Subject: [PATCH 2/5] Test husky pre-commit --- .husky/pre-commit | 4 ++++ content/webapp/components/Map/Map.tsx | 1 + 2 files changed, 5 insertions(+) create mode 100644 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000000..0312b76025 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged \ No newline at end of file diff --git a/content/webapp/components/Map/Map.tsx b/content/webapp/components/Map/Map.tsx index abe704dea4..8e3614b869 100644 --- a/content/webapp/components/Map/Map.tsx +++ b/content/webapp/components/Map/Map.tsx @@ -52,6 +52,7 @@ const Map: FunctionComponent = ({ }, }; const map = new google.maps.Map(mapCanvas as Element, mapOptions); + /* disable @typescript-eslint/no-unused-vars */ const marker = new google.maps.Marker({ position: latLng, map, From b2c2b1d044486109c2fd52683723de24a888ac37 Mon Sep 17 00:00:00 2001 From: Raphaelle Cantin Date: Wed, 23 Oct 2024 16:26:33 +0100 Subject: [PATCH 3/5] testing pre-commit code --- .husky/pre-commit | 4 +++- content/webapp/components/Map/Map.tsx | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 0312b76025..594df049c8 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,6 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npx lint-staged \ No newline at end of file +npx lint-staged + +exit 1 \ No newline at end of file diff --git a/content/webapp/components/Map/Map.tsx b/content/webapp/components/Map/Map.tsx index 8e3614b869..abe704dea4 100644 --- a/content/webapp/components/Map/Map.tsx +++ b/content/webapp/components/Map/Map.tsx @@ -52,7 +52,6 @@ const Map: FunctionComponent = ({ }, }; const map = new google.maps.Map(mapCanvas as Element, mapOptions); - /* disable @typescript-eslint/no-unused-vars */ const marker = new google.maps.Marker({ position: latLng, map, From ef40ae681da9f09d26b6c764718364fd666cccc7 Mon Sep 17 00:00:00 2001 From: Raphaelle Cantin Date: Wed, 23 Oct 2024 16:29:11 +0100 Subject: [PATCH 4/5] Tidy husky set-up --- .husky/pre-commit | 2 -- content/webapp/components/Map/Map.tsx | 2 ++ package.json | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) mode change 100644 => 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 index 594df049c8..d24fdfc601 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,5 +2,3 @@ . "$(dirname -- "$0")/_/husky.sh" npx lint-staged - -exit 1 \ No newline at end of file diff --git a/content/webapp/components/Map/Map.tsx b/content/webapp/components/Map/Map.tsx index abe704dea4..7f3cb03ec6 100644 --- a/content/webapp/components/Map/Map.tsx +++ b/content/webapp/components/Map/Map.tsx @@ -52,11 +52,13 @@ const Map: FunctionComponent = ({ }, }; const map = new google.maps.Map(mapCanvas as Element, mapOptions); + /* eslint-disable @typescript-eslint/no-unused-vars */ const marker = new google.maps.Marker({ position: latLng, map, title, }); + /* eslint-enable @typescript-eslint/no-unused-vars */ }); return () => { /** diff --git a/package.json b/package.json index 139fecec62..15fbd1572a 100644 --- a/package.json +++ b/package.json @@ -117,11 +117,6 @@ "stylelint --max-warnings=0" ] }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } - }, "dependencies": { "yarn": "^1.22.21" } From 9697ad6f9aec7dedd3e6949cdb43589a85ef7f87 Mon Sep 17 00:00:00 2001 From: Raphaelle Cantin Date: Thu, 31 Oct 2024 13:34:42 +0000 Subject: [PATCH 5/5] Add husky.sh --- .husky/_/husky.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .husky/_/husky.sh diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh new file mode 100644 index 0000000000..cec959a6b9 --- /dev/null +++ b/.husky/_/husky.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh +if [ -z "$husky_skip_init" ]; then + debug () { + if [ "$HUSKY_DEBUG" = "1" ]; then + echo "husky (debug) - $1" + fi + } + + readonly hook_name="$(basename -- "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + readonly husky_skip_init=1 + export husky_skip_init + sh -e "$0" "$@" + exitCode="$?" + + if [ $exitCode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitCode (error)" + fi + + if [ $exitCode = 127 ]; then + echo "husky - command not found in PATH=$PATH" + fi + + exit $exitCode +fi