cz commitlint CLI question customization for custom rules.
See original GitHub issueI would like to add the ability to add a CLI prompt for a custom rule. (e.g. ticket number included in commit message)
Expected Behavior
Would like for a way to add new custom option to add ticket number to the CLI prompt.
feat(button): added theme settings [TICKET-123]
commitlint.config.js
module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: [
{
rules: {
ticket: ({ subject }) => {
const ticketRegex = /(\w+-{1}\d+)/;
return [
ticketRegex.test(subject),
"Your subject should include the ticket, for example PRJ-300.",
];
},
},
},
],
rules: {
ticket: [2, "always"],
},
parserPreset: './parser-presets.js',
prompt: {
questions: {
// ...
subject: {
description: 'Write a short, imperative tense description of the change',
},
ticket: {
description: 'Provide a Ticket Number',
},
body: {
description: 'Provide a longer description of the change',
},
// ...
},
}
}
parser-preset.js
module.exports = {
parserOpts: {
headerPattern: /^(\w+)\(\w+\):[ ]{1}(\w{1}.+\w{1})[ ]{1}\[(\w+-{1}\d+)\]$/,
headerCorrespondence: ['type', 'scope', 'subject', 'ticket'],
},
};
Current Behavior
Currently ignores my new rule / custom CLI prompt. I can’t find any documentation that directly walks through this process of making a custom prompt with a custom rule. You can override current rules and change language. But unable to have question use new custom made rules. If this isn’t something that can be / is supported that’s perfectly fine! I’m just curious if it’s currently possible, and if it is where I may be tripping up.
Affected packages
- cli
- cz-commitlint
Executable | Version |
---|---|
commitlint --version |
12.1.4 |
git --version |
2.32.0 |
node --version |
14.17.1 |
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Make everyone in your project write beautiful commit ...
Now create a file in your root folder named .cz-config.js to customize the options of the CLI helper, and paste the below config....
Read more >commitlint - Lint commit messages
commitlint helps your team adhere to a commit convention. By supporting npm-installed configurations it makes sharing of commit conventions easy.
Read more >Setup and Customize Conventional Commits and Semantic ...
Allows one to customize the changelog generation and other bits in the process. Conventional Commits Standards (specification) is a useful ...
Read more >cz-customizable | Yarn - Package Manager
Commitizen customizable adapter following the conventional-changelog format. readme. cz-customizable. The customizable Commitizen plugin (or standalone utility) ...
Read more >Additional command on Husky Hooks fail - Stack Overflow
Have you tried with this: "husky": { "hooks": { "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true" } }.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same issue. With the help of this comment I was able to fix it by adding a rule for each header correspondence. Otherwise it was just being ignored.
So I ended up with something similar to this:
Hope it helps!
@escapedcat 😂 I forgot to paste it . Here it is
I find it too much configurations which didn’t work for me
The second one here seems a bit interesting as it uses emojis too with no problems.