Limit scopes per type with regexp and plain text
npm install commitlint-plugin-selective-scope






> Limit scopes per type with regexp and plain text.
``bash`
npm i commitlint-plugin-selective-scope --save-dev
- 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.
`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 backendchore
- if the type if , the scope is optional and can be anythingperf
- if the type is , a scope is not allowedci
- if the type is , the scope must be codebuild or jenkins` if present, but is not required