Open danrivett opened 4 years ago
As a follow-up I just published a new commitlint plugin - commitlint-plugin-github - which was the trigger for this feature request.
Currently I've had to revert code in the plugin and globally disable certain rules from being evaluated against WIP commits since I cannot configure certain rules to apply against WIP commits, but other rules not to.
I've been working on a custom plugin with custom rules, and for some of the rules I want to apply to all commit comments, however for other rules I want to only apply for non-WIP commits. I don't believe I can currently do this on a per rule basis.
Expected Behaviour
What I would like to do is something like this (ignore rule names since they refer to custom rules I created):
Notice how some rules use some new
when
values to only apply to non-WIP commits, while others apply to all commits.As you can see, what I would like to do is specify in my configuration
always-in-non-wips
ornever-in-non-wips
since my custom plugin identifies whether a commit is a WIP or not and if it is a WIP and thewhen
value is one of these custom values, it just returns[true]
as it skips validating the WIP commit.If the commit isn't a WIP though, then it converts the custom
when
to the standard equivalent:always-in-non-wips
=>always
;never-in-non-wips
=>never
. It then proceeds to validate accordingly.In the configuration example above, many of the custom rules delegate to the standard corresponding rules such as
subject-case
,subject-full-stop
, but the custom rules short-circuit for WIP commits if thewhen
value stipulates to only validate non-WIPs. Otherwise it delegates to the standard rules after converting thewhen
to the corresponding standardalways
andnever
values as necessary.Current Behaviour
This all works great with one problem I didn't anticipate - the overall commitlint linter rejects any custom
when
value in a configuration and so blows everything up, so I can't do this.Not allowing individual rules to allow for more than two different rule conditions seems quite limiting, and I'm raising this Issue to get some feedback on this.
Suggestion
My suggestion would be to update the linter to avoid globally policing the allowable
when
values and instead delegate that to individual rules to allow each one to police which values it accepts.Affected packages
Your Environment
commitlint --version
git --version
node --version