Skip to content

revert: replace all lodash string methods with kasi #4602#4621

Merged
escapedcat merged 2 commits intomasterfrom
fix/4620_non-latin-subject-case
Feb 2, 2026
Merged

revert: replace all lodash string methods with kasi #4602#4621
escapedcat merged 2 commits intomasterfrom
fix/4620_non-latin-subject-case

Conversation

@escapedcat
Copy link
Member

@escapedcat escapedcat commented Feb 2, 2026

User description

Fixes: #4620


PR Type

Bug fix, Tests


Description

  • Reverted kasi library due to incorrect non-Latin case detection

  • Restored lodash-based case detection for proper multi-script support

  • Added comprehensive test coverage for Cyrillic, Chinese, Arabic, Hebrew scripts

  • Updated dependencies from kasi to individual lodash case utilities


Diagram Walkthrough

flowchart LR
  A["kasi@2.0.1<br/>Bug: Misidentifies<br/>non-Latin lowercase"] -->|Revert| B["Lodash case<br/>utilities"]
  B -->|Correct handling| C["Cyrillic, Chinese,<br/>Arabic, Hebrew"]
  D["Add regression<br/>tests"] -->|Prevent future<br/>issues| C
Loading

File Walkthrough

Relevant files
Dependencies
index.test.ts
Replace kasi with lodash camelCase                                             

@commitlint/ensure/src/index.test.ts

  • Replaced kasi import with lodash.camelcase
  • Updated file name transformation to use lodash camelCase function
+2/-2     
to-case.ts
Replace kasi with lodash case utilities                                   

@commitlint/ensure/src/to-case.ts

  • Replaced all kasi case conversion functions with individual lodash
    utilities
  • Updated pascal-case implementation using upperFirst(camelCase(input))
  • Updated sentence-case implementation using upperFirst(input)
  • Imports now use lodash.camelcase, lodash.kebabcase, lodash.snakecase,
    lodash.startcase, lodash.upperfirst
+11/-13 
package.json
Update dependencies from kasi to lodash                                   

@commitlint/ensure/package.json

  • Replaced kasi@^2.0.1 dependency with individual lodash case utilities
  • Added TypeScript type definitions for all lodash case functions
  • Added devDependencies for @types/lodash.* packages
+10/-1   
Tests
subject-case.test.ts
Add non-Latin script subject-case tests                                   

@commitlint/rules/src/subject-case.test.ts

  • Added test for lowercase Cyrillic (Russian) subjects
  • Added test for uppercase Cyrillic rejection
  • Added test for lowercase Chinese subjects
  • Added test for lowercase Arabic subjects
  • Added test for lowercase Hebrew subjects
  • Added test for mixed Latin and Cyrillic subjects
+78/-0   

… and manual (#4602)"

This reverts commit a1ef07e.

kasi@2.0.1 has a bug where it incorrectly identifies lowercase Cyrillic
text as PascalCase/TitleCase, causing the subject-case rule to reject
valid lowercase subjects in non-Latin scripts.

Restores lodash-based case detection which correctly handles non-Latin
alphabets including Cyrillic, Chinese, Arabic, and Hebrew.

Related to #4620
Add regression tests for lowercase and uppercase subjects in:
- Cyrillic (Russian)
- Chinese
- Arabic
- Hebrew
- Mixed Latin + Cyrillic

These tests ensure the subject-case rule correctly handles non-Latin
alphabets and prevent future regressions like the kasi@2.0.1 bug.

Fixes #4620
@escapedcat escapedcat changed the title Fix/4620 non latin subject case fix: non latin subject case #4620 Feb 2, 2026
@qodo-code-review
Copy link

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
🟡
🎫 #4620
🟢 Fix regression introduced in v20.4.0 where the subject-case rule incorrectly rejects fully
lowercase non-Latin (e.g., Cyrillic) subjects.
Ensure commit messages with lowercase non-Latin scripts are accepted when configured to
disallow sentence-case, start-case, pascal-case, and upper-case (default conventional
behavior).
Add regression coverage demonstrating the bug and preventing reintroduction (non-Latin
examples, at least Cyrillic).
Maintain behavior consistent with versions prior to v20.4.0 (i.e., the previously accepted
Cyrillic lowercase subject should pass again).
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

codesandbox-ci bot commented Feb 2, 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

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect test logic for caseless subjects

Fix the test logic for caseless subjects (e.g., Chinese, Arabic, Hebrew) by
changing the rule from never ["upper-case", ...] to never "camel-case", as the
current rule will incorrectly fail for caseless strings.

@commitlint/rules/src/subject-case.test.ts [538-549]

 test("accepts lowercase Chinese subjects", async () => {
 	const message = "fix(面试): 修复评价功能";
 	const parsed = await parse(message);
-	const [actual] = subjectCase(parsed, "never", [
-		"sentence-case",
-		"start-case",
-		"pascal-case",
-		"upper-case",
-	]);
+	const [actual] = subjectCase(parsed, "never", "camel-case");
 
 	expect(actual).toBe(true);
 });
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: This suggestion correctly identifies a logical flaw in the newly added tests for caseless subjects. The current test assertion is incorrect because a caseless string is equivalent to its uppercase form, causing the never 'upper-case' rule to fail. The proposed fix is valid and necessary for the tests to be meaningful.

Medium
General
Correctly implement sentence case conversion

Improve the sentence-case implementation by converting the rest of the string to
lowercase after capitalizing the first letter.

@commitlint/ensure/src/to-case.ts [23-25]

 		case "sentence-case":
 		case "sentencecase":
-			return upperFirst(input);
+			return `${upperFirst(input.toLowerCase())}`;
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that the implementation of sentence-case is incomplete, as it doesn't lowercase the rest of the string. Applying this change would improve the correctness of the case conversion utility.

Medium
Trim input before case conversion

Add input = input.trim() at the beginning of the toCase function to remove
leading and trailing whitespace before case conversion.

@commitlint/ensure/src/to-case.ts [8-10]

 export default function toCase(input: string, target: TargetCaseType): string {
+  input = input.trim();
   switch (target) {
     ...

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why: This is a good suggestion for improving the robustness of the toCase function. Trimming whitespace from the input string would prevent unexpected behavior and make the case conversion logic more reliable.

Low
  • More

@escapedcat escapedcat changed the title fix: non latin subject case #4620 revert: replace all lodash string methods with kasi #4602 Feb 2, 2026
@escapedcat
Copy link
Member Author

/cc @hyperz111

@escapedcat escapedcat merged commit 5326ab9 into master Feb 2, 2026
23 checks passed
@escapedcat escapedcat deleted the fix/4620_non-latin-subject-case branch February 2, 2026 11:56
@hyperz111
Copy link
Contributor

Oh, I'm sorry for this. But thanks for reverting :)

@escapedcat
Copy link
Member Author

No worries, happens. If you have time maybe check existing issues in the kasi repo or open one

This was referenced Feb 22, 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.

fix: subject-case rule rejects non-Latin (Cyrillic) lowercase subjects after update to v20.4.0

2 participants