commitlint
commitlint copied to clipboard
Can't work with emoji?
Expected Behavior
I use npm run commit to generate commit message, I hope it will success generate commit message!
Current Behavior
I use npm run commit to generate commit message, but the commlint check always fails !😫
Affected packages
- [ ] @commitlint/cli
- [ ] commitizen
- [ ] commitlint-config-cz
- [ ] cz-customizable
- [ ] husky
Possible Solution
I queried all documents and issess,I find maybe I need setting headerPattern
Steps to Reproduce (for bugs)
1.I npm install those:
"@commitlint/cli": "^8.2.0",
"commitizen": "^4.0.3",
"commitlint-config-cz": "^0.12.1",
"cz-customizable": "^6.2.0",
"husky": "^3.1.0"
.cz.config.js
:
module.exports = {
types: [
{ value: 'feat✨', name: '特性: 一个新的特性' },
{ value: 'fix🐞', name: '修复: 修复一个Bug' },
{ value: 'docs📚', name: '文档: 变更的只有文档' },
{ value: 'style💅', name: '格式: 空格, 分号等格式修复' },
{ value: 'refactor🛠', name: '重构: 代码重构,注意和特性、修复区分开' },
{ value: 'perf🐎', name: '性能: 提升性能' },
{ value: 'test🏁', name: '测试: 添加一个测试' },
{ value: 'revert⏪', name: '回滚: 代码回退' },
{ value: 'chore🗯', name: '工具:开发工具变动(构建、脚手架工具等)' }
],
messages: {
type: '选择一种你的提交类型:',
customScope: '请输入修改范围(可选):',
subject: '短说明:',
body: '长说明,使用"|"换行(可选):',
footer: '关联关闭的issue,例如:#31, #34(可选):',
confirmCommit: '确定提交说明?'
},
allowCustomScopes: true,
allowBreakingChanges: ['特性', '修复'],
subjectLimit: 100
}
commitlint.config.js
:
module.exports = {
extends: [
'cz'
],
rules: {
'type-empty': [2, 'never'],
'subject-empty': [2, 'never']
}
}
project.json
settings:
...
"config": {
"commitizen": {
"path": "node_modules/cz-customizable"
}
},
"cz-customizable": {
"config": ".cz-config.js"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
after I finish those step, I use npm run commit to generate commit message, but the commlint check always fails !😫 Just like this:

Context
I guess Emoji (🐞 etc.) in my commit message causes it. but I don't know how to fix it. In fact, I have selected the type and input the subject. you can see:
? 选择一种你的提交类型: 修复: 修复一个Bug // this is my type
? 短说明: 代码提交bug // this is my subject
But the commlint check always fails ! I don't know why, hope got your help !!
Your Environment
Executable | Version |
---|---|
commitlint --version |
"^8.2.0" |
git --version |
2.20.1 |
node --version |
v10.15.3 |
repository
this is my repository
Up
Any update here??
Unfortunately not, happy for any help
我也有同样的错误,至今解决不了,我只能暂时先把此功能禁用。
'type-case': [0],
'type-empty': [0],
'scope-empty': [0],
'scope-case': [0],
Update on this in https://github.com/conventional-changelog/commitlint/issues/2674#issuecomment-906968919
you can add headerPattern
config to help commitlint parse messages with gitmoji
for example
// commitlint.config.js
module.exports = {
parserPreset: {
parserOpts: {
headerPattern: /^(?<type>((?::\w+:|(?:\ud83c[\udf00-\udfff])|(?:\ud83d[\udc00-\ude4f\ude80-\udeff])|[\u2600-\u2B55]))?\s?\w*)(?:\((?<scope>.*)\))?!?:\s(?<subject>(?:(?!#).)*(?:(?!\s).))(?:\s\(?(?<ticket>#\d*)\)?)?$/,
headerCorrespondence: ['type', 'scope', 'subject', 'ticket'],
}
},
rules: {
'type-enum': [2, 'always', [...]],
'type-empty': [2, 'never']
}
}
you can modify it based on my config, my configuration is also modified on the basis of @gitmoji/parser-opts