https://github.com/winjs-dev/commitlint-config-win
Git 规约
https://github.com/winjs-dev/commitlint-config-win
Last synced: 8 months ago
JSON representation
Git 规约
- Host: GitHub
- URL: https://github.com/winjs-dev/commitlint-config-win
- Owner: winjs-dev
- License: mit
- Created: 2021-08-06T15:28:49.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-08-15T09:24:40.000Z (almost 3 years ago)
- Last Synced: 2024-09-04T15:18:45.189Z (almost 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 544 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @winner-fed/commitlint-config-win
本包提供了《Git 规约》配套的 [commitlint 可共享配置](https://commitlint.js.org/#/concepts-shareable-config),用于对 git commit message 进行校验。
## 安装
除了本包,你需要同时安装 [@commitlint/cli](https://www.npmjs.com/package/@commitlint/cli):
```bash
npm install @winner-fed/commitlint-config-win @commitlint/cli --save-dev
```
## 使用
本包同时支持 CommonJS 和 ESM 模块系统。
### CommonJS
在项目中的 `commitlint.config.js` 中继承本包:
```javascript
module.exports = {
extends: ['@winner-fed/commitlint-config-win'],
};
```
### ESM
在项目中的 `commitlint.config.mjs` 中继承本包:
```javascript
export default {
extends: ['@winner-fed/commitlint-config-win'],
};
```
或者在 `package.json` 中设置 `"type": "module"` 后,在 `commitlint.config.js` 中使用:
```javascript
export default {
extends: ['@winner-fed/commitlint-config-win'],
};
```
### TypeScript
如果你使用 TypeScript,可以在 `commitlint.config.ts` 中使用:
```typescript
import type { UserConfig } from '@commitlint/types';
const config: UserConfig = {
extends: ['@winner-fed/commitlint-config-win'],
};
export default config;
```
## 设置 git hook
可通过 [husky](https://www.npmjs.com/package/husky) 设置在 git commit 时触发 commitlint。
首先安装 husky:
```bash
npm install husky --save-dev
```
然后在 `package.json` 中增加:
```json
{
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}
```
更多信息可参考 [commitlint 文档](https://commitlint.js.org/#/guides-local-setup?id=install-husky)。