feat(rules): add scope-delimiter-style #4580
Open
+487
−28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a new rule,
scope-delimiter-style, which validates that commit scopes use only the allowed delimiters. This ensures consistent behavior when custom delimiters are configured.It also adds support for passing custom
delimitersto thescope-enumandscope-caserules, allowing users to redefine how multi-segment scopes are split and validated.The default delimiters (
/,\,,) remain unchanged unless explicitly overridden.Documentation has been updated to reflect:
scope-enumandscope-casescope-delimiter-styleruleThis brings delimiter handling across all scope-related rules to a unified and configurable model.
Motivation and Context
Resolves #701
Current scope-related rules (
scope-enum,scope-case) use hardcoded delimiters to split multi-segment scopes. This makes it impossible for users to adapt commitlint to projects that use different delimiter conventions.This PR introduces configurable delimiters and a dedicated
scope-delimiter-stylerule, enabling consistent validation across all scope rules. It provides a unified and flexible way to define how scopes should be parsed and validated, solving the long-standing limitation described in the linked issue.Usage examples
How Has This Been Tested?
All changes are covered by an extended test suite:
Updated existing tests for
scope-enumandscope-caseto ensure backward compatibility with default delimiters.Added new tests for object-based configuration, including custom delimiter lists and empty delimiter arrays.
Added a full test suite for the new
scope-delimiter-stylerule, covering:alwaysandneverconditions-and_Types of changes
Checklist: