commitlint
commitlint copied to clipboard
Using custom regex on headerPattern ins't creating a valid message
Hi,
I'm trying to make a custom commit message that starts with the ID of the issue on ours system.
This is a exemple of the message #123 fix: fix issue
.
Here is my files
//package.json
"devDependencies": {
"@commitlint/cli": "^8.3.4",
"husky": "^4.0.0"
}
//commitlint.config.js
module.exports = {
parserPreset: "./parser-preset.js",
rules: {
"type-empty": [2, "never"],
"subject-empty": [2, "never"]
}
};
//parser-preset.js
module.exports = {
parserOpts: {
headerPattern: /^#(\d*)\s(\w*):\s(.*)$/,
headerCorrespondence: ["id", "type", "subject"]
}
};
//.ruskyrc.js
module.exports = {
hooks: {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
};
By the parser-preset, a commit message with #123 fix: fix issue
, should be a valid message, and should send the type
and subject
correctly for the commitlint. But I'm getting this error:
✖ type may not be empty [type-empty]
✖ subject may not be empty [subject-empty]
✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
What I'm missing? What I did wrong?
Not sure, I also tried the "local" example from the docs and it doesn't seem to work (anymore?). Might be a bug. I'll add a label and we'll see.
I have similar issue. I want commitlint to only check if commit message contains "#
Node 12.14.1.
//package.json
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"husky": "^3.0.9"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
}
},
//commitlint.config.js
module.exports = {
parserPreset: './parser-preset.js',
rules: {
'body-leading-blank': [0],
'footer-leading-blank': [0],
'header-max-length': [0],
'scope-case': [0],
'subject-case': [0],
'subject-empty': [0],
'subject-full-stop': [0],
'type-case': [0],
'type-empty': [0],
'type-enum': [0],
},
};
//parser-preset.js
module.exports = {
parserOpts: {
headerPattern: /^#\d+\s|\s#\d+\s|#\d+$|^merge/gi,
},
};
Add extends: ['@commitlint/config-conventional'],
in your module.exports
Looks like the same as #607