From 11ae2ad97cb8b830764a7bfa85fb83270572e9cb Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 31 Aug 2024 23:06:34 +0800 Subject: [PATCH] chore: add husky and lint-staged (#1062) --- .husky/pre-commit | 1 + package.json | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..d0a77842 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npx lint-staged \ No newline at end of file diff --git a/package.json b/package.json index b8804610..784de39a 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "scripts": { "start": "dumi dev", "build": "dumi build", - "prepare": "dumi setup", + "prepare": "husky && dumi setup", "compile": "father build && lessc assets/index.less assets/index.css", "prepublishOnly": "npm run compile && np --yolo --no-publish", "lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js", @@ -40,6 +40,9 @@ "tsc": "tsc --noEmit", "now-build": "npm run build" }, + "lint-staged": { + "*": "prettier --write --ignore-unknown" + }, "peerDependencies": { "react": "*", "react-dom": "*" @@ -67,8 +70,10 @@ "eslint-plugin-jest": "^27.6.0", "eslint-plugin-unicorn": "^50.0.1", "father": "^4.0.0", + "husky": "^9.1.5", "jsonp": "^0.2.1", "less": "^4.2.0", + "lint-staged": "^15.2.9", "np": "^9.2.0", "prettier": "^3.1.1", "querystring": "^0.2.1",