https://github.com/ridvanaltun/commitlint-plugin-selective-scope
Limit scopes per type with regexp and plain text.
https://github.com/ridvanaltun/commitlint-plugin-selective-scope
commitlint commitlint-plugin commitlintplugin
Last synced: 6 months ago
JSON representation
Limit scopes per type with regexp and plain text.
- Host: GitHub
- URL: https://github.com/ridvanaltun/commitlint-plugin-selective-scope
- Owner: ridvanaltun
- License: mit
- Created: 2021-09-30T11:39:20.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-22T22:26:22.000Z (about 3 years ago)
- Last Synced: 2025-06-18T08:17:00.308Z (6 months ago)
- Topics: commitlint, commitlint-plugin, commitlintplugin
- Language: JavaScript
- Homepage:
- Size: 197 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Introduction
[](https://npmjs.com/package/commitlint-plugin-selective-scope)
[](https://npmjs.com/package/commitlint-plugin-selective-scope)
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/semantic-release/semantic-release)
[](https://travis-ci.com/ridvanaltun/commitlint-plugin-selective-scope)
[](https://coveralls.io/github/ridvanaltun/commitlint-plugin-selective-scope?branch=master)
[](https://github.com/ridvanaltun/commitlint-plugin-selective-scope/blob/master/LICENSE)
> Limit scopes per type with regexp and plain text.
## Installation
```bash
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
```javascript
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