您如何配置commitlint以忽略某些提交消息,例如包含字符串“ WIP”的任何提交消息?

问题描述 投票:0回答:1

我们正在使用commitlint在我们的提交上执行命名约定,但是,我可以弄清楚如何允许它忽略包含“ 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)[];

这是我们当前的提交皮棉配置:

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

添加此示例的语法是什么?

git lint
1个回答
0
投票

语法由ignores?: ((message: string) => boolean)[];提供的类型信息给出。

您需要添加一个函数,该函数接受字符串参数message,对其进行处理,然后返回布尔值。一个例子:

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

如果消息中的任何地方都有true,则会添加一个返回WIP的函数,从而使其被忽略。

© www.soinside.com 2019 - 2024. All rights reserved.