安装stylelint

  1. 安装依赖

    1
    npm install --save-dev @commitlint/config-conventional @commitlint/cli
  2. 不单独使用命令,结合Husky使用,请继续查阅Husky文档

配置文件约定

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* type-enum 相关定义 参考公司文档http://doc.gitlab.py.pages:280/it-doc/pages/73cb32/
init: 初始化项目
feat:新功能(feature)
fix:修补
docs:文档(documentation)以及注释相关
style: 格式(不影响代码运行的变动)
refactor:重构(即不是新增功能,也不是修改bug的代码变动)
test:增加测试,测试用例,接口测试等等
revert:feat(pencil): add 'graphiteWidth' option (撤销之前的commit)
perf: Performance的缩写, 提升代码性能
ci:主要目的是修改项目继续完成集成流程(例如Travis,Jenkins,GitLab CI,Circle)的提交
build: 主要目的是修改项目构建系统(例如glup,webpack,rollup的配置等)的提交
// 个人认为,应该新增 chore
chore: 其他修改, 比如改变构建流程、或者增加依赖库、工具等
// 个人认为以下重复 应该去掉
// upgrade:升级改造,或者需求变动相关升级
// bugfix:修补bug
// optimize:优化,逻辑优化,代码结构优化等等
*/

module.exports = {
// 使用该主流插件 https://www.conventionalcommits.org/zh-hans/v1.0.0/
// 默认规则详情 https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional#type-enum
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'init',
'feat',
'fix',
'docs',
'style',
'refactor',
'test',
'revert',
'perf',
'ci',
'build',
'chore',
],
],
},
}