diff --git a/@commitlint/rules/src/scope-case.ts b/@commitlint/rules/src/scope-case.ts index 9bac0d3db2..7544cc1fa0 100644 --- a/@commitlint/rules/src/scope-case.ts +++ b/@commitlint/rules/src/scope-case.ts @@ -27,7 +27,7 @@ export const scopeCase: SyncRule = ( // Scopes may contain slash or comma delimiters to separate them and mark them as individual segments. // This means that each of these segments should be tested separately with `ensure`. - const delimiters = /\/|\\|,/g; + const delimiters = /\/|\\|, ?/g; const scopeSegments = scope.split(delimiters); const result = checks.some((check) => { diff --git a/@commitlint/rules/src/scope-enum.test.ts b/@commitlint/rules/src/scope-enum.test.ts index f624d7bce8..b5abb87481 100644 --- a/@commitlint/rules/src/scope-enum.test.ts +++ b/@commitlint/rules/src/scope-enum.test.ts @@ -6,6 +6,7 @@ const messages = { superfluous: 'foo(): baz', empty: 'foo: baz', multiple: 'foo(bar,baz): qux', + multipleCommaSpace: 'foo(bar, baz): qux', }; const parsed = { @@ -13,6 +14,7 @@ const parsed = { superfluous: parse(messages.superfluous), empty: parse(messages.empty), multiple: parse(messages.multiple), + multipleCommaSpace: parse(messages.multipleCommaSpace), }; test('scope-enum with plain message and always should succeed empty enum', async () => { @@ -93,20 +95,29 @@ test('scope-enum with empty scope and never should succeed empty enum', async () expect(actual).toEqual(expected); }); -test('scope-enum with multiple scope should succeed on message with multiple scope', async () => { +test('scope-enum with multiple scopes should succeed on message with multiple scopes', async () => { const [actual] = scopeEnum(await parsed.multiple, 'never', ['bar', 'baz']); const expected = false; expect(actual).toEqual(expected); }); -test('scope-enum with multiple scope should error on message with forbidden enum', async () => { +test('scope-enum with multiple scopes should error on message with forbidden enum', async () => { const [actual] = scopeEnum(await parsed.multiple, 'never', ['bar', 'qux']); const expected = true; expect(actual).toEqual(expected); }); -test('scope-enum with multiple scope should error on message with superfluous scope', async () => { +test('scope-enum with multiple scopes should error on message with superfluous scope', async () => { const [actual] = scopeEnum(await parsed.multiple, 'never', ['bar']); const expected = true; expect(actual).toEqual(expected); }); + +test('scope-enum with multiple scope with comma+space should succeed on message with multiple scopes', async () => { + const [actual] = scopeEnum(await parsed.multipleCommaSpace, 'always', [ + 'bar', + 'baz', + ]); + const expected = true; + expect(actual).toEqual(expected); +}); diff --git a/@commitlint/rules/src/scope-enum.ts b/@commitlint/rules/src/scope-enum.ts index e368df5a6a..3e3633c636 100644 --- a/@commitlint/rules/src/scope-enum.ts +++ b/@commitlint/rules/src/scope-enum.ts @@ -13,7 +13,7 @@ export const scopeEnum: SyncRule = ( // Scopes may contain slash or comma delimiters to separate them and mark them as individual segments. // This means that each of these segments should be tested separately with `ensure`. - const delimiters = /\/|\\|,/g; + const delimiters = /\/|\\|, ?/g; const scopeSegments = parsed.scope.split(delimiters); const negated = when === 'never';