conventional-changelog / conventional-changelog/commitlint

commit lint issuePrefixes - scope could not be optional

Open
#1,016 6 comments 5 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
18.7k
Forks
970
Avg merge
7h 33m
Merged PRs (30d)
49

Description

I am trying to use issue prefix to have my commit format as mentioned below

`JIRA-ID: type(scope): Subject
`
**scope should be optional.**
which means following are valid message

- AAAA-12: fix(test): fixed the failing test

- AAAA-12: fix: fixed the failing test

Following is how my **commitlint.config.js** looks like
```
module.exports = {
extends: ['@commitlint/config-conventional'],
parserPreset: {
parserOpts: {
headerPattern: /^[A-Z]{1,4}-[0-9]{1,4}:\s(\w*)\((\w*)\):\s(.*)$/,
headerCorrespondence: ["type", "scope", "subject"],
issuePrefixes: ["^[A-Z]{1,4}-[0-9]{1,4}"],
referenceActions: ["xxx-"] // (!!)
}
},
rules: {
'references-empty': [2, 'never'],
'scope-empty': [1, 'never'],
...
...
}
}
```

## Expected Behavior
following message should be valid.
- AAAA-12: fix(test): fixed the failing test

- AAAA-12: fix: fixed the failing test

Need to understand how to extend the current config to add one more rule for prefix.

## Current Behavior
following message appears to be invalid. I can't make scope optional
- AAAA-12: fix: fixed the failing test

## Affected packages

- [ ] cli
- [ ] core
- [ ] prompt
- [ ] config-angular

## Possible Solution

## Steps to Reproduce (for bugs)
Change the **parserPreset** as mentioned above with rules mentioned.

commitlint.config.js


```js
```

## Context

## Your Environment

| Executable | Version |
| ---------------------: | :------ |
| `commitlint --version` | VERSION |
| `git --version` | VERSION |
| `node --version` | VERSION |

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.