codeinabox@programming.dev to Git@programming.devEnglish · 3 days agoImplementing Conventional Commits with Jira Ticket Prefix Validationheristop.github.ioexternal-linkmessage-square1fedilinkarrow-up15arrow-down10
arrow-up15arrow-down1external-linkImplementing Conventional Commits with Jira Ticket Prefix Validationheristop.github.iocodeinabox@programming.dev to Git@programming.devEnglish · 3 days agomessage-square1fedilink
minus-squarecodeinabox@programming.devOPlinkfedilinkEnglisharrow-up1·3 days agoAfter a bit of experimentation, I’ve managed to find a cleaner solution to enforcing the ticket number in the subject: module.exports = { extends: ['@commitlint/config-conventional'], rules: { // Enforce scope to match JIRA ticket format like PER-123 'jira-ticket-rule': [2, 'always'], 'subject-case': [0], }, plugins: [ { rules: { 'jira-ticket-rule': ({ subject }) => { return [ subject && subject.match(/[A-Z]+-\d+/), 'Your subject should contain a JIRA ticket eg PER-123', ]; }, }, }, ], };
After a bit of experimentation, I’ve managed to find a cleaner solution to enforcing the ticket number in the subject:
module.exports = { extends: ['@commitlint/config-conventional'], rules: { // Enforce scope to match JIRA ticket format like PER-123 'jira-ticket-rule': [2, 'always'], 'subject-case': [0], }, plugins: [ { rules: { 'jira-ticket-rule': ({ subject }) => { return [ subject && subject.match(/[A-Z]+-\d+/), 'Your subject should contain a JIRA ticket eg PER-123', ]; }, }, }, ], };