Shane
Shane

Reputation: 4315

How do you configure commitlint to ignore certain commit messages such as any that contain the string "WIP"?

We are using commitlint to enforce a naming convention on our commits, however, I can figure out how to allow it to ignore commit messages that contain "WIP".

https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-configuration.md

   /*
   * Functions that return true if commitlint should ignore the given message.
   */
  ignores?: ((message: string) => boolean)[];

This is our current commit lint configuration:

module.exports = {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'subject-case': [2, 'never', ['start-case', 'pascal-case']],
  },
  ignores: [],
};

What is example syntax to add this?

Upvotes: 5

Views: 10936

Answers (1)

gelliott181
gelliott181

Reputation: 1028

The syntax is given by the type information provided by ignores?: ((message: string) => boolean)[];.

You need to add a function that takes a string argument message, does something with it, then returns a boolean. An example:

ignores: [
    (message) => message.includes('WIP')
]

This would add a function that returns true if the message has WIP anywhere in it, causing it to be ignored.

Upvotes: 7

Related Questions