Skip to content

Commit b4246d6

Browse files
authored
fix: subject-full-stop false positive when using ellipsis (#3839)
* test: using ellipses in titles ending The SubjectFullStop failing test on a title that ends with ellipsis. * fix: subjectFullStop considering ellipsis
1 parent 3ee4c28 commit b4246d6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

@commitlint/rules/src/subject-full-stop.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const messages = {
77
without: `test: subject\n`,
88
standardScopeWith: `type(scope): subject.\n`,
99
nonStandardScopeWith: 'type.scope: subject.\n',
10+
ellipsisMessage: 'test: subject ends with ellipsis...',
1011
};
1112

1213
const parsed = {
@@ -15,6 +16,7 @@ const parsed = {
1516
without: parse(messages.without),
1617
standardScopeWith: parse(messages.standardScopeWith),
1718
nonStandardScopeWith: parse(messages.nonStandardScopeWith),
19+
ellipsisMessage: parse(messages.ellipsisMessage),
1820
};
1921

2022
test('empty against "always" should succeed', async () => {
@@ -72,3 +74,9 @@ test('commit message title with non standard scope and full-stop against "never
7274
const expected = false;
7375
expect(actual).toEqual(expected);
7476
});
77+
78+
test('ellipsis is not fullstop so commit title ending with it against "never ." should not fail', async () => {
79+
const [actual] = subjectFullStop(await parsed.ellipsisMessage, 'never', '.');
80+
const expected = true;
81+
expect(actual).toEqual(expected);
82+
});

@commitlint/rules/src/subject-full-stop.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export const subjectFullStop: SyncRule<string> = (
1414
const input = parsed.header;
1515

1616
const negated = when === 'never';
17-
const hasStop = input[input.length - 1] === value;
17+
let hasStop = input[input.length - 1] === value;
18+
if (input.slice(-3) === '...') {
19+
hasStop = false;
20+
}
1821

1922
return [
2023
negated ? !hasStop : hasStop,

0 commit comments

Comments
 (0)