feat: commitlint 集成

commitlint 集成测试

BREAKING CHANGE: 新增 commitlint.config.js .husky 文件

#I4O3H0
This commit is contained in:
dingyongya 2022-02-16 15:53:40 +08:00
parent 12a608cd42
commit befd0985dc
3 changed files with 44 additions and 3 deletions

4
.husky/commit-msg Normal file
View File

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

21
commitlint.config.js Normal file
View File

@ -0,0 +1,21 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"type-enum": [2,
"always",
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test'
]
],
},
};

View File

@ -29,7 +29,10 @@
"build:types": "rimraf types && tsc -d", "build:types": "rimraf types && tsc -d",
"build:example": "vite build example", "build:example": "vite build example",
"lint:eslint": "eslint 'src/**/*.{vue,ts,tsx}' --fix", "lint:eslint": "eslint 'src/**/*.{vue,ts,tsx}' --fix",
"lint:prettier": "prettier --write 'src/**/*'" "lint:prettier": "prettier --write \"src/**/*\"",
"prepare": "husky install",
"postinstall": "npm run prepare",
"commit": "git-cz"
}, },
"dependencies": { "dependencies": {
"@layui/hooks-vue": "^0.1.6", "@layui/hooks-vue": "^0.1.6",
@ -46,6 +49,8 @@
"@babel/core": "^7.15.8", "@babel/core": "^7.15.8",
"@babel/preset-env": "^7.15.8", "@babel/preset-env": "^7.15.8",
"@babel/preset-typescript": "^7.15.0", "@babel/preset-typescript": "^7.15.0",
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@rollup/plugin-babel": "^5.3.0", "@rollup/plugin-babel": "^5.3.0",
"@types/markdown-it": "^12.2.3", "@types/markdown-it": "^12.2.3",
"@types/markdown-it-container": "^2.0.4", "@types/markdown-it-container": "^2.0.4",
@ -56,12 +61,13 @@
"@vue/compiler-sfc": "^3.2.30", "@vue/compiler-sfc": "^3.2.30",
"@vue/server-renderer": "^3.2.30", "@vue/server-renderer": "^3.2.30",
"commitizen": "^4.2.4", "commitizen": "^4.2.4",
"cz-conventional-changelog": "3.3.0", "cz-conventional-changelog": "^3.3.0",
"escape-html": "^1.0.3", "escape-html": "^1.0.3",
"eslint": "^8.5.0", "eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.2.0", "eslint-plugin-vue": "^8.2.0",
"husky": "^7.0.4",
"less": "^4.1.2", "less": "^4.1.2",
"markdown-it-container": "^3.0.0", "markdown-it-container": "^3.0.0",
"prettier": "^2.5.1", "prettier": "^2.5.1",
@ -81,5 +87,15 @@
"current node", "current node",
"last 2 versions and > 2%", "last 2 versions and > 2%",
"ie > 10" "ie > 10"
] ],
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
} }