From 1c26ac9f7963a33d2a8e70a2d58f82526e2c6d67 Mon Sep 17 00:00:00 2001 From: Gleb Date: Thu, 16 Mar 2023 13:04:05 -0700 Subject: [PATCH] Add git hook --- .husky/pre-commit | 8 ++++++++ package.json | 6 ++++-- yarn.lock | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..75e3805ca --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,8 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +G='\033[0;32m' +P='\033[0;35m' +CLEAN='\033[0;0m' + +yarn run check:mdx || (echo -e "${G}Hint:${CLEAN} execute ${P}yarn run format:mdx${CLEAN} to format files" && exit 1) diff --git a/package.json b/package.json index 5ed58b153..d7b862074 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "format:mdx": "prettier --write \"docs/**/*.{md,mdx}\"", "check:mdx": "prettier -c \"docs/**/*.{md,mdx}\"", "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" --fix", - "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"" + "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"", + "prepare": "husky install" }, "dependencies": { "@docusaurus/core": "^2.2.0", @@ -64,6 +65,7 @@ "eslint-plugin-jsdoc": "^39.3.6", "eslint-plugin-prefer-arrow": "^1.2.3", "prettier": "^2.7.1", - "typescript": "^4.8.2" + "typescript": "^4.8.2", + "husky": "^8.0.0" } } diff --git a/yarn.lock b/yarn.lock index 452957230..84d816f00 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7447,6 +7447,11 @@ human-signals@^2.1.0: resolved "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +husky@^8.0.0: + version "8.0.3" + resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" + integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== + iconv-lite@0.4, iconv-lite@0.4.24: version "0.4.24" resolved "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz"