Skip to content

ridvanaltun/commitlint-plugin-selective-scope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4c20417 · Dec 22, 2022

History

6 Commits
Dec 22, 2022
Dec 22, 2022
Sep 30, 2021
Sep 30, 2021
Sep 30, 2021
Sep 30, 2021
Dec 22, 2022
Dec 22, 2022
Sep 30, 2021
Sep 30, 2021
Sep 30, 2021
Dec 22, 2022
Sep 30, 2021
Dec 22, 2022
Dec 22, 2022
Sep 30, 2021

Repository files navigation

Introduction

npm version npm downloads Commitizen friendly semantic-release Build Status Coverage Status license

Limit scopes per type with regexp and plain text.

Installation

npm i commitlint-plugin-selective-scope --save-dev

Usage

  • If a type does not appear in the rule, do not enforce scope
  • If a type appears in the rule with an empty array, do not allow scope
  • If a type appears in the rule with an non-empty array, only allow the values in the array for scope.
  • If the array includes null, the scope is optional.

Example

module.exports = {
  plugins: ['selective-scope'],
  rules: {
    'selective-scope': [
      2,
      'always',
      {
        feat: [/^frontend\/[^\/]+$/, 'backend'],
        perf: [],
        ci: [null, 'codebuild', 'jenkins']
      }
    ]
  }
}

In the above rules configuration,

  • if the type is feat, the scope must be either match the regex /frontend\/[^\/]+/ or be backend
  • if the type if chore, the scope is optional and can be anything
  • if the type is perf, a scope is not allowed
  • if the type is ci, the scope must be codebuild or jenkins if present, but is not required