Using Local Plugin throws "TypeError: normalizedName.indexOf is not a function"
See original GitHub issueUsing the Local Plugin example from the docs: https://commitlint.js.org/#/reference-plugins?id=usage-example
Expected Behavior
Given I use the examples for Local Plugin from the documentation When I make a commit such as “some message” Then I should see a list of errors containing “Your subject should contain Hello World message”
Current Behavior
Given I use the examples for Local Plugin from the documentation When I make a commit such as “some message” Then commitlint throws an exception and exits with no error list of invalid commit details
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
This error is due to the function normalizePackageName in @commitlint/load/lib/utils which is expecting to be called with a string. When using a Local Plugin there is no package name, instead it is called with the plugin configuration object as specified in the commitlint.config.js.
This doesn’t appear to be the only area expecting a string, however.
Steps to Reproduce (for bugs)
// commitlint.config.js
module.exports = {
rules: {
'hello-world-rule': [2, 'always']
},
plugins: [
{
rules: {
'hello-world-rule': ({subject}) => {
const HELLO_WORLD = 'Hello World';
return [
subject.includes(HELLO_WORLD),
`Your subject should contain ${HELLO_WORLD} message`
];
}
}
}
]
};
and using husky
{
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
-
make a commit
git commit -m"some message"
-
View the error:
.../node_modules/@commitlint/cli/lib/cli.js:131
throw err;
^
TypeError: normalizedName.indexOf is not a function
Context
I wanted to write a plugin on my local within the context of an existing project before moving it to a separate package
Instead I will symlink a local repository and write the plugin there until I want to publish it.
Your Environment
Executable | Version |
---|---|
commitlint --version |
9.0.1 |
git --version |
2.26.0 |
node --version |
Tried 10 and 14 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
Verified fixed in 9.1.1 🎉
Sweet! Thanks to @EmaSuriano I guess 😃
I guess we’ll release 9.1.0 soonish.