Open
Description
Steps to Reproduce (for bugs)
Develop a local plugin like documented here:
https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-plugins.md#local-plugins
So the config file starts like this:
module.exports = {
parserPreset: 'conventional-changelog-conventionalcommits',
rules: {
'body-leading-blank': [1, 'always'],
'footer-leading-blank': [1, 'always'],
'footer-max-line-length': [2, 'always', 150],
'header-max-length': [2, 'always', 50],
'subject-full-stop': [2, 'never', '.'],
'type-empty': [1, 'never'],
'type-space-after-colon': [2, 'always'],
'subject-lowercase': [2, 'always'],
},
plugins: [
{
rules: {
'subject-lowercase': ({subject}) => {
if (subject === null || subject === undefined) {
// otherwise, String(null) might give us the stupid string "null"
throw new Error('Unexpected subject===null or subject===undefined happened');
}
let offence = false;
if (subject != null && subject.length > 1) {
let firstIsUpperCase = subject[0].toUpperCase() == subject[0];
let firstIsLowerCase = subject[0].toLowerCase() == subject[0];
let secondIsUpperCase = subject[1].toUpperCase() == subject[1];
let secondIsLowerCase = subject[1].toLowerCase() == subject[1];
offence = firstIsUpperCase && (!firstIsLowerCase)
// to whitelist acronyms
&& (!secondIsUpperCase) && secondIsLowerCase;
}
return [
!offence,
`Please use lowercase as the first letter for your subject, i.e. the text after your area/scope`
];
...
- Run the plugin against a commit msg like
foo: bar baz
, it works. - Run the plugin against a commit msg like
foo.bar: baz
orfoo-bar: baz
orfoo,bar: baz
, then....
Current Behavior
It crashes with "Unexpected subject===null or subject===undefined happened" because of the assertion.
Expected Behavior
It should not crash. Subject should always be the text after the first colon.
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
No idea, didn't yet dive in the source code of commitlint sorry.
Your Environment
Executable | Version |
---|---|
commitlint --version |
17.1.2 |
git --version |
2.37.3 |
node --version |
v16.17.0 |