Skip to content
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

fix: sentence-case doesn't allow upper-case characters in first word #531

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions @commitlint/ensure/src/case.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ function toCase(input, target) {
case 'uppercase':
return input.toUpperCase();
case 'sentence-case':
case 'sentencecase': {
const [word] = input.split(' ');
return `${toCase(word.charAt(0), 'upper-case')}${toCase(
word.slice(1),
'lower-case'
)}${input.slice(word.length)}`;
}
case 'sentencecase':
return input.charAt(0).toUpperCase() + input.slice(1);
case 'lower-case':
case 'lowercase':
case 'lowerCase': // Backwards compat config-angular v4
Expand Down
8 changes: 4 additions & 4 deletions @commitlint/ensure/src/case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ test('false for lowercase on sentencecase', t => {
t.is(ensure('sentence case', 'sentence-case'), false);
});

test('false for UPPERCASE on sentencecase', t => {
t.is(ensure('UPPERCASE', 'sentence-case'), false);
test('true for UPPERCASE on sentencecase', t => {
t.is(ensure('UPPERCASE', 'sentence-case'), true);
});

test('true for Start Case on sentencecase', t => {
t.is(ensure('Start Case', 'sentence-case'), true);
});

test('false for PascalCase on sentencecase', t => {
t.is(ensure('PascalCase', 'sentence-case'), false);
test('true for PascalCase on sentencecase', t => {
t.is(ensure('PascalCase', 'sentence-case'), true);
});

test('false for kebab-case on sentencecase', t => {
Expand Down