question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't work with emoji?

See original GitHub issue

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

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:

屏幕快照 2019-12-22 16 32 55

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
fsmaiacommented, Mar 4, 2021

Up

0reactions
xiefengacommented, Dec 21, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Emojis and special characters not working. - Apple Community
Launch System Preferences. You can do so by clicking on the 'Apple' logo in the Mac menu bar at the top, then clicking...
Read more >
Emoticon Keyboard opens, but doens't work
3. Try Win+. keys to open emoji panel and see if it works. 4. If you don't see US keyboard in the input...
Read more >
Why Other People Can't See Your Emojis and How to Fix It
There are several different reasons why emojis can get lost in ... but the real problems start when emojis can't be displayed at...
Read more >
6 Quick Fixes for Predictive Emoji Not Working on an iPhone ...
Here's what you need to do: Open the app that doesn't show you predictive emojis. Begin typing a few characters.
Read more >
How To FIX Missing Emojis On Android! (2022) - YouTube
Your browser can't play this video. Learn more. Switch camera.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found