-
Notifications
You must be signed in to change notification settings - Fork 950
feat(rules): add scope-delimiter-style #4580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new scope-delimiter-style rule to validate commit scope delimiters and adds support for configurable delimiters in the existing scope-enum and scope-case rules. This addresses the long-standing limitation where delimiter handling was hardcoded, making it impossible to adapt commitlint to projects with different delimiter conventions.
Key changes:
- New
scope-delimiter-stylerule that validates which delimiters can be used in multi-segment scopes - Enhanced
scope-enumandscope-caserules to accept object-based configuration with customizable delimiters - Comprehensive test coverage for all new functionality and backward compatibility
- Updated documentation describing the new rule and configuration options
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/reference/rules.md | Documents the new scope-delimiter-style rule and object-based configuration for scope-enum and scope-case |
| docs/concepts/commit-conventions.md | Updates the Multiple Scopes section to reference configurable delimiters |
| @commitlint/rules/src/scope-delimiter-style.ts | Implements the new rule that validates scope delimiters against an allowed list |
| @commitlint/rules/src/scope-delimiter-style.test.ts | Comprehensive test suite for the new rule covering default and custom configurations |
| @commitlint/rules/src/scope-enum.ts | Adds object-based configuration support with custom delimiter handling |
| @commitlint/rules/src/scope-enum.test.ts | Tests for object-based configuration including custom delimiters and edge cases |
| @commitlint/rules/src/scope-case.ts | Adds object-based configuration support with custom delimiter handling |
| @commitlint/rules/src/scope-case.test.ts | Tests for object-based configuration with various delimiter scenarios |
| @commitlint/rules/src/index.ts | Exports the new scope-delimiter-style rule |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Pressed the copilot review. Have a look if any of that is valid or useful, thanks! |
|
Hey @escapedcat! Thanks a lot, some of Copilot's suggestions were pretty helpful. I've pushed the changes. Whenever you have a moment, could you take a look? |
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: