浏览代码

build: husky + lint-staged + commitlint

Burt 2 年之前
父节点
当前提交
e9602040a5
共有 5 个文件被更改,包括 903 次插入9 次删除
  1. 4 0
      .husky/commit-msg
  2. 4 0
      .husky/pre-commit
  3. 4 0
      commitlint.config.cjs
  4. 17 0
      package.json
  5. 874 9
      pnpm-lock.yaml

+ 4 - 0
.husky/commit-msg

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+npx --no-install commitlint --edit 

+ 4 - 0
.husky/pre-commit

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+npx --no-install -- lint-staged

+ 4 - 0
commitlint.config.cjs

@@ -0,0 +1,4 @@
+// commitlint.config.cjs
+module.exports = {
+  extends: ['@commitlint/config-conventional'],
+}

+ 17 - 0
package.json

@@ -37,8 +37,20 @@
     "build:quickapp-webview": "uni build -p quickapp-webview",
     "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
     "build:quickapp-webview-union": "uni build -p quickapp-webview-union",
+    "prepare": "husky install",
     "type-check": "vue-tsc --noEmit"
   },
+  "lint-staged": {
+    "**/*.{html,vue,ts,cjs,json,md}": [
+      "prettier --write"
+    ],
+    "**/*.{vue,js,ts,jsx,tsx}": [
+      "eslint --fix"
+    ],
+    "**/*.{vue,css,scss,html}": [
+      "stylelint --fix"
+    ]
+  },
   "dependencies": {
     "@dcloudio/uni-app": "3.0.0-3081220230817001",
     "@dcloudio/uni-app-plus": "3.0.0-3081220230817001",
@@ -57,6 +69,8 @@
     "vue-i18n": "^9.1.9"
   },
   "devDependencies": {
+    "@commitlint/cli": "^18.4.3",
+    "@commitlint/config-conventional": "^18.4.3",
     "@dcloudio/types": "^3.3.2",
     "@dcloudio/uni-automator": "3.0.0-3081220230817001",
     "@dcloudio/uni-cli-shared": "3.0.0-3081220230817001",
@@ -66,12 +80,15 @@
     "@typescript-eslint/parser": "^6.15.0",
     "@vue/runtime-core": "^3.2.45",
     "@vue/tsconfig": "^0.1.3",
+    "commitlint": "^18.4.3",
     "eslint": "^8.56.0",
     "eslint-config-airbnb-base": "^15.0.0",
     "eslint-config-prettier": "^9.1.0",
     "eslint-import-resolver-typescript": "^3.6.1",
     "eslint-plugin-import": "^2.29.1",
     "eslint-plugin-prettier": "^5.1.0",
+    "husky": "^8.0.3",
+    "lint-staged": "^15.2.0",
     "postcss": "^8.4.32",
     "postcss-html": "^1.5.0",
     "postcss-scss": "^4.0.9",

文件差异内容过多而无法显示
+ 874 - 9
pnpm-lock.yaml