Solvedcommitlint How to validate github issues / jira issues

i am currently looking into how i could validate that a commit msg does include a github issue number or a jira issue number.
We currently do this with validate-commit-msg
since that package is supposed to be deprecated i was wondering how i am supposed to do something similar with commitlint.

21 Answers

✔️Accepted Answer

Is it also possible to configure so that this would be accepted:

PROJ-1 feat(users): add model

Other Answers:

You can do this via the references-empty rule

// commitlint.config.js
module.exports = {
  'references-empty': [2, 'never']

This checks for the presence of any "reference", which depends on conventional-commit-parser settings. Per default this yields:

λ echo "type: subject" | commitlint
   input: type: subject
   references may not be empty [references-empty]
   found 1 problems, 0 warnings

λ echo "type: subject #1" | commitlint
   input: type: subject #1
   found 0 problems, 0 warnings

When validating JIRA ticket numbers you'll want to configure an issuePrefix:

// commitlint.config.js
module.exports = {
  parserPreset: {
    parserOpts: {
      issuePrefixes: ['PROJ-']
  'references-empty': [2, 'never']

This create the following results:

λ echo "type: subject" | commitlint
   input: type: subject
   references may not be empty [references-empty]
   found 1 problems, 0 warnings

λ echo "type: subject #1" | commitlint
   input: type: subject #1
   references may not be empty [references-empty]
   found 1 problems, 0 warnings

λ echo "type: subject PROJ-1" | commitlint
   input: type: subject PROJ-1
   found 0 problems, 0 warnings

This question crops up often enough to warrant documentation.
Thinking about creating a "Common use cases" page.

@cevatkerim rules definitions have to be wrapped into a rules, parserPreset must be inside parserOpts:

// commitlint.config.js
module.exports = {
  parserPreset: {
    parserOpts: {
      issuePrefixes: ['PROJ-']
  rules: {
    'references-empty': [2, 'never']
echo "type: subject" | commitlint
   input: type: subject
   references may not be empty [references-empty]
   found 1 problems, 0 warnings

echo "type: subject PROJ-1" | commitlint
   input: type: subject PROJ-1
   found 0 problems, 0 warnings

@Anzumana @belamrani @mebibou I created a plugin and a config special for JIRA commit messages style commitlint-jira

Related Issues:

commitlint How to validate github issues / jira issues
Is it also possible to configure so that this would be accepted: Hey ...
commitlint core: multiple scopes in commit message
Thanks for the quick reply @marionebl :) For a lerna project with the following packages: Current Be...
commitlint [input] is required: supply via stdin, or --env or --edit or --from and --to
I hope this helps with identifying the issue If you explicitly specify the default value it works as...
husky Can't find Husky, skipping pre-commit hook
I was able to fix this issue with: yarn in v1.6.0 husky installed information: config in .huskyrc I ...
husky husky with sourcetree : Can't find node in PATH, trying to find a node binary on your system
I was experiencing this error with NVM & WebStorm (while everything was fine from the Ubuntu termina...
husky Command "husky-run" not found.
Try yarn husky install Just have upgraded from v4.3.8 to v5.0.9 and got the error have tried to unin...
husky husky is using some strange node version when running hooks
The fix for node v10 is to update lint-staged to ^7.0.5: or First problem husky is using npm when I'...
husky Bug commit from vscode
I use VS Code and Husky v6 I ran echo $PATH from the root of my project Then I copied the output to ...
husky Husky v5 and Gitkraken
@adriankwiat you can try shx for cross-platform: Disclaimer This is no longer an issue since Gitkrak...
husky Can't find Node.js installed with NVM, when used in VS Code
Looks like adding a ~/.huskyrc file with: Stops VS Code from committing and allows husky to continue...
15 What about work in progress commits
I came across this as an open source maintainer and agree with @rikhoffbauer examle: i'm work on fea...
husky Git LFS and husky prepush hook?
To summarize suggestions by @jmchambers and @Fandekasp I just tried to husky a prepush script and no...
husky Problem with the pre-push git hook
As @soda0289 pointed out it was missing a A new version (4.0.10) has been released with the fix Than...
husky hook fails as it assumes yarn will be available in $PATH
There's a similar issue when using husky with SourceTree Getting an error: This error can't be fixed...
husky git commit hooks never get created when husky v5 is installed
Hi @DouglasDev It's normal behaviour with v5 You need to run npx husky install and create hooks with...
desktop The user name or passphrase you entered is not correct.
It sure looks like something's screwy with Keychain Try opening Keychain ...
git lfs Encountered 1 file(s) that should have been pointers, but weren't
Run git lfs uninstall and then git reset --hard (assuming there are no changes you want to keep!) On...
desktop Could not resolve host:
Check this out as well it helped me. Description I create a new repository in my local and complete ...
desktop It keeps saying The user name or passphrase you entered is not correct.
@tom10271 we think this is related to Keychain access due to some sort of macOS update: Try opening ...
git lfs Simple steps to uninstall Git LFS from your repository
Thanx that helped me a lot while I was migrating from BitBucket to AWS CodeCommit ...
git lfs git-lfs aborts with "LFS: Git credentials for https://XXX not found." even for repositories without passwords
In my case on Windows using gitbash I had to use: git config --global credential.helper wincred ...
desktop A lock file already exists in the repository, which blocks this operation from completing.
@simhox thank you for updating the issue body and uploading the log file! Here's the related error: ...
desktop Improve ease of configuring Git to work with corporate proxy
@DanielKeogh currently you still need to tell Git about your proxy settings: git config --global htt...
desktop fatal: unable to access '': Could not resolve proxy: aproxy
Run the below command git config --global --unset http.proxy Description [Description of the issue] ...
nodegit Can't install via NPM
Latest Xcode just straight up broke things all across the world Try running sudo xcode-select --inst...
git lfs installation in ubuntu is not working
Running the following command looks to have fixed this issue for me: Trying the instruction: yields ...
desktop reference broken
@herio5154 thanks for the feedback! It looks like something with the underlying Git repository has b...
desktop Feature Request: Graph history view
IMO full tree is too complex and we should decide the main reason to add this feature ...
desktop Commit failed error with GPG signing turned on
In case it helps someone the workaround I'm using for now is to disable gpg signing with a repositor...
git lfs git lfs issue even after adding the file
Hi @kamlekar thanks for opening this issue and I'm sorry that you're having some trouble! Here's my ...
gitsome Command "python egg_info" failed with error code 1 in /tmp/pip-build-7SrToZ/gitsome/
I had the same problem on OSX and Solve my issue (I have both python versions installed). ...
git lfs Authentication required : You must have push access to verify locks error.
I'm trying to help you skip the pre-push hook You inadvertently re-installed it :) Try this: Sorry a...
bat Ubuntu install error when rg is installed also
As a workaround one can use sudo apt install -o Dpkg::Options::=--force-overwrite bat ripgrep (taken...
lint staged Build typescript on commit
hi I know this is an already closed issue but I still ran into it I'm trying to rebuild my typescrip...
pre commit python3.7: command not found
Just adding this here for anyone that comes across this issue When you create a virtualenv using for...
lint staged No staged files match src/**/*.{ts,tsx}
I solved my problem I had a space in between ts and tsx change in .lintstagedrc.json from *.{ts tsx}...
bfg repo cleaner Just write how to install it.
@srugano I agree I had no idea how to properly install it Luckily I found it on homebrew so I instal...
patchwork remote Permission to jlord/patchwork.git denied returned error: 403
When you get a 403 on this challenge it is because you are trying to push your changes to a reposito...
desktop "Warning: line endings have changed from 'LF' to 'CRLF'." when files have LF line endings on Windows
@stuartpb Isn't configuration from Github Desktop you using Windows Git assumes CRLF but your text e...
desktop Authentication Failed
Experienced this issue with a Bitbucket SSH URL changing to a https URL in the Repository Settings f...
cli Ability to configure a default editor for use with gh
I think it would make most sense to honour GIT_EDITOR since that is likely what people will have set...
git lfs cannot spawn .git/hooks/pre-push: No such file or directory
Cool glad you got it working What ended up being the solution? my solution was git lfs update --forc...
git lfs Force pushes can lead to "bad object" message from git rev-list
You can run git fetch to fetch from the remote first. Describe the bug When force-pushing a ref to a...
desktop Github Desktop version 1.0.12 Authentication Failed during fetch with remote
Goto File > Options > Sign Out and Sign In again It works for me. Description After upgrading to the...
lint staged lint-staged ignores tsconfig.json when it called through husky hooks
Similar issue with tsc Passing files AND project config is not possible When invoked from husky ...
netlify cms Support for multilingual content authoring
So I can see from #2988 that we're still looking for UI/UX solutions on this Thanks @barthc for the ...
git lfs Object does not exist on the server
For anyone in a situation where git lfs thinks everything is dandy but repos are spouting Object doe...
desktop file too large, but can't remove it
This worked for me: A simple solution I used: Do git reset HEAD^ for as many commits you want to und...
vscode gitlens GitLens disables merging CodeLens
Hey guys So after long searching with trying i may discovered the reason of disabled options for the...