Feature request: Configurable delimiter for scope
Expected Behavior
I expect that commit message fix(module-a,module-b): Do something will pass scope-case rule.
Current Behavior
It fails, because it does not treat comma as a valid separator
Affected packages
- [ ] cli
- [x] core
- [ ] prompt
- [ ] config-angular
Possible Solution
Make these delimiters configurable: https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/rules/src/scope-case.js#L25
Context
Sometimes there are commits that span across multiple modules. Currently they do not pass the linter. Splitting into multiple is not possible if committed changes require simultaneous update of all affected parts.
We do support comma by now: https://commitlint.js.org/concepts/commit-conventions.html#multiple-scopes But the delimiter can not be configured. Not sure if this is still needed though.
We do support comma by now: https://commitlint.js.org/concepts/commit-conventions.html#multiple-scopes But the delimiter can not be configured. Not sure if this is still needed though.
our projects previous use scope like: feat(A/B): commit msg, B is a sub scope of A, but for now "/" is scopes delimiter to divide input scope string into several scopes, when we update @commitlint/[email protected] , it doesn't work well as before, i wonder if we can config scope delimiter may solve my problem
when we update @commitlint/[email protected] , it doesn't work well as before
Maybe open a separate new issue for this first. Everything that worked should still work the same.
We do support comma by now: https://commitlint.js.org/concepts/commit-conventions.html#multiple-scopes But the delimiter can not be configured. Not sure if this is still needed though.
Hey @escapedcat ! First of all, thanks for your work on such an awesome linter!
I think we need a separate rule – something like scope-separator-style or similar. The thing is, as was mentioned, commitlint currently supports multiple variants: https://commitlint.js.org/concepts/commit-conventions.html#multiple-scopes. But that's actually a problem – we can't properly control it (at least not without regexes). Because if there are several ways to do something, every team member might do it differently. It would be great to unify this – i.e., allow it to be done only in one consistent way. And isn't that one of the main purposes of linters in the first place?
Sure. Wanna create a new issue for this and create a PR?
First of all, thanks for your work on such an awesome linter!
Thank @marionebl for that ❤️
@escapedcat I could give it a try! Don't you think this issue might fit the implementation? It seems to be exactly about that, doesn't it?
Uhm, so I thought the difference is this:
- This issue wants to make the delimiter configurable
i.e. instead of the currently supported defaults the user wants to use
% - You want to make sure that if a delimiter is used it should always we the same within a repo
i.e. not a mixed usage of
,and\
Maybe that's a misunderstanding?
Uhm, so I thought the difference is this:
- This issue wants to make the delimiter configurable i.e. instead of the currently supported defaults the user wants to use
%- You want to make sure that if a delimiter is used it should always we the same within a repo i.e. not a mixed usage of
,and\Maybe that's a misunderstanding?
@escapedcat, here's how I was thinking of doing it.
Add a new rule called scope-separator-style (or similar). It will be configurable and accept an array of values. The default value will be ["/", "\", ","], primarily to maintain backward compatibility:
{
rules: {
"scope-separator-style": [RuleConfigSeverity.Error, "always"] // default value is ["/", "\", ","]
}
}
But it will also be possible to provide custom values – for example, I might leave only ["/"] so that only one option is allowed:
{
rules: {
"scope-separator-style": [RuleConfigSeverity.Error, "always", ["/"]] // only "/" is allowed as scope separator
}
}
Someone else might prefer ["%"], or whatever they want in general:
{
rules: {
"scope-separator-style": [RuleConfigSeverity.Error, "always", ["%"]] // only "%" is allowed as scope separator
}
}
What do you think about that?
Maybe you see a different way to implement it, since you're familiar with the project’s codebase. I haven't looked into it yet, sorry.
[...] since you're familiar with the project’s codebase
I'm really not 😆
What do you think about that?
Got it, yes, that would cover both of the points I mentioned. If you're up for it, have a look.