Skip to content

fix(types): add scope-delimiter-style types#4592

Merged
escapedcat merged 1 commit intoconventional-changelog:masterfrom
what1s1ove:master
Jan 8, 2026
Merged

fix(types): add scope-delimiter-style types#4592
escapedcat merged 1 commit intoconventional-changelog:masterfrom
what1s1ove:master

Conversation

@what1s1ove
Copy link
Copy Markdown
Contributor

@what1s1ove what1s1ove commented Jan 8, 2026

User description

Description

This PR adds TypeScript support for object-based configurations introduced in the previous changes (#4580).

While the runtime behavior and config validation already support object-based values for scope-enum and scope-case, TypeScript types were still restricted to the tuple-based format only. As a result, valid configurations caused TypeScript errors even though commitlint worked correctly at runtime.

This change extends the rule value types only for the affected rules (scope-enum and scope-case) to allow object-based configurations, without altering shared generic rule types. This keeps the existing type model intact while aligning TypeScript definitions with the actual supported configuration format.

No runtime behavior is changed, this PR only updates TypeScript types to reflect the existing functionality.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Bug fix


Description

  • Add ObjectRuleConfig generic type for object-based rule configurations

  • Extend scope-case type to support object format with cases and delimiters

  • Extend scope-enum type to support object format with scopes and delimiters

  • Add scope-delimiter-style rule type to RulesConfig


Diagram Walkthrough

flowchart LR
  A["ObjectRuleConfig<br/>Generic Type"] --> B["scope-case<br/>Union Type"]
  A --> C["scope-enum<br/>Union Type"]
  D["scope-delimiter-style<br/>EnumRuleConfig"] --> E["RulesConfig<br/>Updated"]
  B --> E
  C --> E
Loading

File Walkthrough

Relevant files
Bug fix
rules.ts
Add object-based scope rule configuration types                   

@commitlint/types/src/rules.ts

  • Added new ObjectRuleConfig generic type to support object-based
    configurations
  • Updated scope-case to union type allowing both CaseRuleConfig and
    object format with cases and optional delimiters
  • Updated scope-enum to union type allowing both EnumRuleConfig and
    object format with scopes and optional delimiters
  • Added scope-delimiter-style rule using EnumRuleConfig type
+11/-2   

@qodo-code-review
Copy link
Copy Markdown

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Jan 8, 2026

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.

@qodo-code-review
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Align object configuration with existing type

Update the scope-case object configuration to allow the cases property to be
either a single TargetCaseType or an array, aligning it with the existing
CaseRuleConfig for better consistency.

@commitlint/types/src/rules.ts [116-118]

 	"scope-case":
 		| CaseRuleConfig<V>
-		| ObjectRuleConfig<V, { cases: TargetCaseType[]; delimiters?: string[] }>;
+		| ObjectRuleConfig<
+				V,
+				{ cases: TargetCaseType | TargetCaseType[]; delimiters?: string[] }
+		  >;
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a type inconsistency in the newly added object configuration for scope-case and proposes a fix that aligns it with the existing CaseRuleConfig, improving API consistency and usability.

Medium
  • More

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 adds TypeScript type definitions to support object-based configurations for scope-related rules. Previously, the TypeScript types only allowed tuple-based formats while the runtime already supported object-based configurations, causing type errors for valid configurations.

  • Introduces ObjectRuleConfig generic type for object-based rule configurations
  • Extends scope-case and scope-enum types to support both traditional and object formats with optional delimiters
  • Adds missing scope-delimiter-style rule type definition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@escapedcat escapedcat merged commit 23c1f6e into conventional-changelog:master Jan 8, 2026
18 checks passed
@escapedcat
Copy link
Copy Markdown
Member

Thanks!

@escapedcat
Copy link
Copy Markdown
Member

@what1s1ove
Copy link
Copy Markdown
Contributor Author

Now everything works fine. Thank you!

This was referenced Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants