Open
Description
I 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 |