refactor(cz-commitlint,prompt): remove duplication in case conversion#2794
Conversation
| case 'sentence-case': | ||
| case 'sentencecase': | ||
| return input.charAt(0).toUpperCase() + input.slice(1); | ||
| return upperFirst(input); |
There was a problem hiding this comment.
This is functionally equivalent to the current implementation as far as I can tell.
| case 'sentencecase': | ||
| return (input: string) => | ||
| `${input.charAt(0).toUpperCase()}${input.substring(1).toLowerCase()}`; | ||
| return (input: string) => upperFirst(input); |
There was a problem hiding this comment.
The implementation here deviates from the one in @commitlint/ensure/src/case.ts
|
Hey @hasghari , thanks for this PR! Edit: Ah. you're on it right now ;) Thanks! |
Updated with description and context. |
f81f1c5 to
cfce62c
Compare
|
Hey @hasghari , thanks for pointing out this issue and explaining it :)
No need to worry about the monorepo thing. You could just export the function and use it in the |
7337683 to
a416168
Compare
|
@escapedcat I took a stab at removing the duplication. I also left my earlier commit in place but I'd be happy to squash it. |
|
@escapedcat @hasghari It's good to extract |
a416168 to
5350795
Compare
Thanks for pointing out the |
|
@hasghari would you mind rebasing this? Thanks! |
The @commitlint/cz-commitlint was previously duplicating the case conversion logic also found in the @commitlint/ensure package.
The @commitlint/prompt package was previously duplicating the case conversion logic also found in the @commitlint/ensure package.
5350795 to
5199ccf
Compare
Done. |
|
Thanks @hasghari ! Moving this in. |
|
It's released with 14.0.0/14.1.0 |
Description
The implementation of
sentence-casefor cz-commitlint differs from the one in@commitlint/ensure/src/case.ts. Ideally the@commitlint/cz-commitlintpackage should depend on the@commitlint/ensurepackage and import thetoCasefunction to remove the duplicate implementation but admittedly I'm not sure how to accomplish that in a monorepo like this. Does that require submitting a separate pull request for@commitlint/ensureto export thetoCasefunction?Motivation and Context
Let's say my desired commit message is "ci: Add GitHub Action for commitlint". If I author that manually, it passes commitlint. However with commitizen, it converts everything except the first character to lowercase, ending up with "ci: Add github action for commitlint"
Types of changes
Checklist: