From 532c01132c8391440d60f02316a0af59f471eda8 Mon Sep 17 00:00:00 2001 From: ajaxzheng <894103554@qq.com> Date: Mon, 4 Dec 2023 20:14:26 +0800 Subject: [PATCH] ci(eslint): add husky and commitlint to eslint code (#1021) --- .lintstagedrc.json | 4 ++++ commitlint.config.js | 2 +- package.json | 25 +++++++++---------------- 3 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 .lintstagedrc.json diff --git a/.lintstagedrc.json b/.lintstagedrc.json new file mode 100644 index 000000000..a932d01b9 --- /dev/null +++ b/.lintstagedrc.json @@ -0,0 +1,4 @@ +{ + "*.{js,jsx,ts,tsx,vue}": ["prettier --write", "eslint --fix"], + "*.md": ["prettier --write"] +} diff --git a/commitlint.config.js b/commitlint.config.js index 33a7b5c1d..4fedde6da 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1 +1 @@ -module.exports = { extends: ['@commitlint/config-conventional'] } \ No newline at end of file +module.exports = { extends: ['@commitlint/config-conventional'] } diff --git a/package.json b/package.json index 02014d9f5..dcabcc30b 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "scripts": { "preinstall": "npx only-allow pnpm", "postinstall": "pnpm build:internals", + "prepare": "husky install", "bootstrap": "pnpm --filter=\"!./packages/dist/**\" install", "dev": "pnpm build:entry && gulp themeConcat -w & pnpm -C examples/vue3 dev", "dev:saas": "pnpm create:icon-saas && pnpm build:entry && pnpm -C examples/vue3 dev:saas", @@ -119,7 +120,8 @@ "build:ui-react": "pnpm create:mapping-react && pnpm build:entry-react && pnpm build:react", "pub:react": "pnpm --filter=\"./packages/dist-react/**\" publish --no-git-checks --access=public", "dev:react-site": "pnpm --filter @opentiny/react-site start", - "build:react-site": "pnpm --filter @opentiny/react-site build" + "build:react-site": "pnpm --filter @opentiny/react-site build", + "commit": "git-cz" }, "dependencies": { "@vue/composition-api": "1.2.2", @@ -135,8 +137,6 @@ }, "devDependencies": { "@antfu/eslint-config": "^0.38.6", - "@commitlint/cli": "^17.3.0", - "@commitlint/config-conventional": "^17.3.0", "@types/color": "^3.0.3", "@types/eslint": "^8.4.10", "@types/node": "^18.11.18", @@ -159,7 +159,12 @@ "gulp-svg-inline": "^1.0.1", "gulp-transform": "^3.0.5", "lerna": "^6.4.0", - "lint-staged": "^13.0.3", + "lint-staged": "^15.2.0", + "husky": "^8.0.0", + "commitlint": "^18.4.3", + "@commitlint/config-conventional": "^18.4.3", + "commitizen": "^4.3.0", + "cz-conventional-changelog": "^3.3.0", "minimist": "^1.2.8", "node-xlsx": "^0.21.0", "prettier": "^3.0.0", @@ -171,18 +176,6 @@ "vue": "^3.3.9", "vue-tsc": "^1.6.5" }, - "husky": { - "hooks": { - "pre-commit": "lint-staged", - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" - } - }, - "lint-staged": { - "*.{js,ts,jsx,tsx,vue}": [ - "prettier --write", - "eslint --fix" - ] - }, "config": { "commitizen": { "path": "cz-conventional-changelog"