diff --git a/.husky/pre-commit b/.husky/pre-commit index f80aed3..6b7a3b7 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,7 @@ +echo "对已暂存文件运行 lint-staged..." +npx lint-staged + echo "运行类型检查..." -npm run typecheck \ No newline at end of file +npm run typecheck + +echo "所有检查通过,准备提交..." \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push index f80aed3..6b7a3b7 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,2 +1,7 @@ +echo "对已暂存文件运行 lint-staged..." +npx lint-staged + echo "运行类型检查..." -npm run typecheck \ No newline at end of file +npm run typecheck + +echo "所有检查通过,准备提交..." \ No newline at end of file diff --git a/package.json b/package.json index a74e856..fe71ce9 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "homepage": "https://github.com/algerkong/AlgerMusicPlayer", "scripts": { "prepare": "husky", - "format": "prettier --write .", - "lint": "eslint . --fix", + "format": "prettier --write ./src", + "lint": "eslint ./src --fix", "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", "typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false", "typecheck": "npm run typecheck:node && npm run typecheck:web", @@ -22,6 +22,14 @@ "build:mac": "npm run build && electron-builder --mac", "build:linux": "npm run build && electron-builder --linux" }, + "lint-staged": { + "*.{ts,tsx,vue,js}": [ + "eslint --fix" + ], + "*.{ts,tsx,vue,js,css,scss,md,json}": [ + "prettier --write" + ] + }, "dependencies": { "@electron-toolkit/preload": "^3.0.1", "@electron-toolkit/utils": "^4.0.0", @@ -76,6 +84,7 @@ "eslint-plugin-vue": "^10.3.0", "eslint-plugin-vue-scoped-css": "^2.11.0", "globals": "^16.3.0", + "lint-staged": "^15.2.10", "howler": "^2.2.4", "lodash": "^4.17.21", "marked": "^15.0.4",