You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I want to write my own rules based on Angular rules but has strict rules for scope, which may looks like below:
feat(core/module): add new feature ...
I want rule the scope message with a fixed head, like core, ui, etc...
then give more message descrip affected part(could be empty).
I think the rules I want to add can be expressed with regex like
Using the plugin, you can write something like this as commitlint config. Note that I've changed from regex to simply do startsWith and give a nice error message with allowed scope, but you could also use a regex!
Hope this helps!
module.exports={extends: ['@commitlint/config-conventional'],plugins: ['commitlint-plugin-function-rules'],rules: {'scope-enum': [0],// level: disabled'function-rules/scope-enum': [2,// level: error'always',(parsed)=>{constscopes=['core','ui'];if(!parsed.scope||scopes.some((scope)=>parsed.scope.startsWith(scope))){return[true];}return[false,`scope must be one of ${scopes.join(', ')}`];},],},};
How to write rules with regex
Expected Behavior
Hi, I want to write my own rules based on Angular rules but has strict rules for scope, which may looks like below:
I want rule the scope message with a fixed head, like core, ui, etc...
then give more message descrip affected part(could be empty).
I think the rules I want to add can be expressed with regex like
I tried
but it doesn`t work.
So is there anyway can I apply regex to commitlint rules?
Current Behavior
Affected packages
Possible Solution
Steps to Reproduce (for bugs)
commitlint.config.js
```js ```Context
Your Environment
commitlint --version
git --version
node --version
The text was updated successfully, but these errors were encountered: