diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..05831721 --- /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 format:mdx${CLEAN} to format files" && exit 1) diff --git a/package.json b/package.json index 090d3ba1..79bb7292 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "check:mdx": "prettier --prose-wrap preserve --check \"docs/**/*.{md,mdx}\"", "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" --fix", "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"", + "prepare": "husky install", "postinstall": "patch-package" }, "dependencies": { @@ -74,6 +75,7 @@ "eslint-config-react-app": "^7.0.1", "eslint-plugin-jsdoc": "^46.4.4", "eslint-plugin-prefer-arrow": "^1.2.3", + "husky": "^8.0.3", "mdast-util-to-markdown": "^1.4.0", "prettier": "^3.0.0", "react-player": "^2.12.0", diff --git a/yarn.lock b/yarn.lock index e3e3948a..a4d7fbf3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7077,6 +7077,11 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +husky@^8.0.3: + version "8.0.3" + resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" + integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== + hyphenate-style-name@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz#691879af8e220aea5750e8827db4ef62a54e361d"