commit lint issuePrefixes - scope could not be optional
See original GitHub issueI 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 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6 (2 by maintainers)
Top Results From Across the Web
commitlint not able to make scope optional - Stack Overflow
The rule 'scope-empty': [1, 'never'], is means display warning if scope is not empty. If you want to disable this rule completely, ...
Read more >standard-commit - npm
Start using standard-commit in your project by running `npm i ... There are no other projects in the npm registry using standard-commit.
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 >commitlint - Bountysource
I'd like it to be purely optional and not block the commit in case it finds problems with ... Error: Cannot find module...
Read more >Git Commit Guidelines | EU System
Commit Message Format ... The header is mandatory and the scope of the header is optional. Any line of the commit message cannot...
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
@AdeAttwood Thanks for your suggestion! This pattern has worked for me with the following options:
Using the following commit message:
XXXX-0000: feat: subject
XXXX-0000: feat(scope): subject
Also the following commit messages will fail as expected with reasonable error logs:
XX-0000: test: subject
XXXX-AA: feat: subject
I didn’t need to use
referenceActions
, i think it’s not necessary sinceissuePrefixes
with the above settings already works like expected. Or do you @AdeAttwood know whatreferenceActions
would achieve in this setting?I think this is missing a
?
in theheaderPattern
. Can you please try the below pattern and let me know how it goes