• codeinabox@programming.devOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 days ago

    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',
              ];
            },
          },
        },
      ],
    };