From 67b783fecb685e41b6c9de97bee75cdd31e0f511 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Thu, 31 Mar 2022 21:05:33 +0530 Subject: [PATCH 1/3] Add husky --- package-lock.json | 6 ++++++ package.json | 1 + 2 files changed, 7 insertions(+) diff --git a/package-lock.json b/package-lock.json index f8b343db6..70c3c913d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15476,6 +15476,12 @@ "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "dev": true }, + "husky": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", + "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", + "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 3d4ed359f..0bfa4048d 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "grunt-contrib-copy": "1.0.0", "grunt-shell": "4.0.0", "grunt-wp-deploy": "2.1.2", + "husky": "^7.0.4", "lint-staged": "12.3.7", "npm-run-all": "4.1.5", "prettier": "2.6.1", From 8ca8c293f72fb4c7c8026abd596b30bf1834f0a5 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Thu, 31 Mar 2022 21:07:10 +0530 Subject: [PATCH 2/3] Add npm script as prepare for husky install --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0bfa4048d..d55438c09 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,8 @@ "lint:pkg-json": "wp-scripts lint-pkg-json --ignorePath .gitignore", "lint:staged": "lint-staged", "test": "npm-run-all --parallel test:*", - "test:php": "vendor/bin/phpunit" + "test:php": "vendor/bin/phpunit", + "prepare": "husky install" }, "lint-staged": { "package.json": [ From c0f90bb09402dd80d66152b04bdaf10b0c1e6d44 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Thu, 31 Mar 2022 21:08:28 +0530 Subject: [PATCH 3/3] Add husky pre-commit hook --- .husky/pre-commit | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..3199e8e02 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npm run lint:staged