chore: replace husky with simple-git-hooks (#143)

This commit is contained in:
CharleeWa 2025-02-20 22:12:54 +08:00
parent 24f15fde5c
commit 831732c719
6 changed files with 1018 additions and 120 deletions

View File

@ -1 +0,0 @@
node scripts/verifyCommit.js

View File

@ -1 +0,0 @@
pnpm lint

32
commitlint.config.ts Normal file
View File

@ -0,0 +1,32 @@
import type { UserConfig } from '@commitlint/types'
import { RuleConfigSeverity } from '@commitlint/types'
const Configuration: UserConfig = {
extends: ['@commitlint/config-conventional'],
formatter: '@commitlint/format',
rules: {
'type-enum': [
RuleConfigSeverity.Error,
'always',
[
'feat',
'fix',
'perf',
'style',
'docs',
'test',
'refactor',
'build',
'ci',
'chore',
'revert',
'wip',
'workflow',
'types',
'release',
],
],
},
}
export default Configuration

View File

@ -8,14 +8,14 @@
"scripts": {
"dev": "cross-env MOCK_SERVER_PORT=8086 vite",
"build": "vue-tsc --noEmit && vite build",
"build:dev": "vue-tsc --noEmit && vite build --mode=development",
"preview": "vite preview",
"test": "vitest",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "vitest",
"release": "bumpp --commit --push --tag",
"prepare": "husky",
"typecheck": "vue-tsc --noEmit"
"typecheck": "vue-tsc --noEmit",
"commitlint": "commitlint --edit",
"prepare": "simple-git-hooks"
},
"dependencies": {
"@unhead/vue": "~1.11.19",
@ -37,6 +37,9 @@
},
"devDependencies": {
"@antfu/eslint-config": "4.3.0",
"@commitlint/cli": "^19.7.1",
"@commitlint/config-conventional": "^19.7.1",
"@commitlint/types": "^19.5.0",
"@iconify-json/carbon": "^1.2.7",
"@intlify/unplugin-vue-i18n": "^6.0.3",
"@types/lodash-es": "^4.17.12",
@ -53,11 +56,12 @@
"cross-env": "^7.0.3",
"eslint": "^9.20.1",
"eslint-plugin-format": "^1.0.1",
"husky": "^9.1.7",
"less": "^4.2.2",
"lint-staged": "^15.4.3",
"mockjs": "^1.1.0",
"postcss-mobile-forever": "^4.4.0",
"rollup": "^4.34.8",
"simple-git-hooks": "^2.11.1",
"terser": "^5.39.0",
"typescript": "^5.7.3",
"unocss": "66.0.0",
@ -82,5 +86,12 @@
},
"resolutions": {
"vite": "^6.1.0"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged",
"commit-msg": "pnpm commitlint $1"
},
"lint-staged": {
"*": "eslint --fix"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +0,0 @@
import fs from 'node:fs'
import process from 'node:process'
const msg = fs.readFileSync('.git/COMMIT_EDITMSG', 'utf-8').trim()
const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
const mergeRe = /^(Merge pull request|Merge branch)/
if (!commitRE.test(msg)) {
if (!mergeRe.test(msg)) {
console.log('git commit unpass')
console.error('git commit error, needs title(scope): desc')
process.exit(1)
}
}
else {
console.log('git commit pass')
}