question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Local Plugin throws "TypeError: normalizedName.indexOf is not a function"

See original GitHub issue

Using 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"
  }
}
  1. make a commit git commit -m"some message"

  2. 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:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
ls-jacob-lawrencecommented, Jul 14, 2020

Verified fixed in 9.1.1 🎉

1reaction
escapedcatcommented, Jun 24, 2020

Sweet! Thanks to @EmaSuriano I guess 😃
I guess we’ll release 9.1.0 soonish.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Uncaught TypeError: a.indexOf is not a function" error when ...
I was using jquery.poptrox.min.js for image popping and zooming and I received an error which said: “Uncaught TypeError: a.indexOf is not a function”...
Read more >
e.indexOf is not a function in ooohboi.libs.locomotion.js
Uncaught TypeError: e.indexOf is not a function in ooohboi.libs.locomotion.js ... S.fn.load = function(e, t, n) { var r, i, o, a = this,...
Read more >
axe-core/axe.js - chromium/src/third_party - Git at Google
throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');.
Read more >
Design Patterns with React Easy State | by Bertalan Miklos
React Easy State is a transparent reactive state management library with two functions and two accompanying rules. Always wrap your components with view()...
Read more >
With React Query - React Location - TanStack
Clamped)?Array$\u002F.test(n)) return arrayLikeToArray(o, minLen);\\n}\",\"export default function _nonIterableRest() {\\n throw new TypeError(\\\"Invalid ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found