From 6a785aed8598b4f569f79993ce9ce266d66f33ef Mon Sep 17 00:00:00 2001 From: Romaric Date: Wed, 14 Sep 2022 18:09:18 +0100 Subject: [PATCH] Set up pre-commit git hook using husky --- .husky/pre-commit | 4 ++++ package-lock.json | 22 ++++++++++++++++++++++ package.json | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..cf0c46b936 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx --no-install lint-staged diff --git a/package-lock.json b/package-lock.json index 6838b176ff..1b898292a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "gulp-task-listing": "^1.1.0", "gulp-uglify": "^3.0.2", "html5shiv": "^3.7.3", + "husky": "^8.0.1", "jest": "^27.4.3", "jest-axe": "^5.0.1", "jest-puppeteer": "^6.0.2", @@ -10175,6 +10176,21 @@ "ms": "^2.0.0" } }, + "node_modules/husky": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", + "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", + "dev": true, + "bin": { + "husky": "lib/bin.js" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -33212,6 +33228,12 @@ "ms": "^2.0.0" } }, + "husky": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", + "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", + "dev": true + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", diff --git a/package.json b/package.json index c50a29db62..b7beaf3661 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "test:build:dist": "jest tasks/gulp/__tests__/after-build-dist.test.js", "lint": "npm run lint:js && npm run lint:scss", "lint:js": "standard", - "lint:scss": "stylelint \"app/**/*.scss\" \"src/**/*.scss\"" + "lint:scss": "stylelint \"app/**/*.scss\" \"src/**/*.scss\"", + "prepare": "husky install" }, "devDependencies": { "@percy/cli": "^1.0.0-beta.75", @@ -55,6 +56,7 @@ "gulp-task-listing": "^1.1.0", "gulp-uglify": "^3.0.2", "html5shiv": "^3.7.3", + "husky": "^8.0.1", "jest": "^27.4.3", "jest-axe": "^5.0.1", "jest-puppeteer": "^6.0.2",