Merge pull request #5 from damianopetrungaro/master

feat: support ! for notifying breaking change
This commit is contained in:
Adrian Smijulj 2022-06-12 19:02:56 +02:00 committed by GitHub
commit 8862f17547
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -2,6 +2,8 @@ import isValidCommitMessage from "../isValidCommitMesage";
test("should be able to correctly validate the commit message", () => { test("should be able to correctly validate the commit message", () => {
expect(isValidCommitMessage("chore(nice-one): doing this right")).toBe(true); expect(isValidCommitMessage("chore(nice-one): doing this right")).toBe(true);
expect(isValidCommitMessage("feat!: change all the things")).toBe(true);
expect(isValidCommitMessage("fix(user)!: a fix with some breaking changes")).toBe(true);
expect(isValidCommitMessage("fix: menu must open on shortcut press")).toBe(true); expect(isValidCommitMessage("fix: menu must open on shortcut press")).toBe(true);
expect(isValidCommitMessage("something: should not work")).toBe(false); expect(isValidCommitMessage("something: should not work")).toBe(false);
expect(isValidCommitMessage("fixes something")).toBe(false); expect(isValidCommitMessage("fixes something")).toBe(false);

View file

@ -31,6 +31,7 @@ const isValidCommitMessage = (message, availableTypes = DEFAULT_COMMIT_TYPES): b
possiblyValidCommitType = possiblyValidCommitType possiblyValidCommitType = possiblyValidCommitType
.replace(/\s/g, "") // Remove all whitespace .replace(/\s/g, "") // Remove all whitespace
.replace(/\!/g, "") // Remove bang for notify breaking change
.replace(/()/g, "") // Remove all whitespace .replace(/()/g, "") // Remove all whitespace
.replace(/[^a-z]/g, ""); // Only leave [a-z] characters. .replace(/[^a-z]/g, ""); // Only leave [a-z] characters.