Skip to content

Commit c30e75d

Browse files
committed
Improve error message for space between <TYPE> and <MODULE>
Signed-off-by: Matthew Peveler <[email protected]>
1 parent b5bfdc9 commit c30e75d

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

dist/index.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/validate.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ export function checkTitle(fullTitle: string): true {
4949
}
5050
}
5151

52+
if (/^\[[a-zA-Z0-9\\/]+:[ ]+[a-zA-Z0-9\\/]+?\]/.test(title)) {
53+
throw new Error(
54+
"Unexpected space between <TYPE> and <MODULE> (e.g. [<TYPE>: <MODULE>]), there should be no space (e.g. [<TYPE>:<MODULE>])."
55+
);
56+
}
57+
5258
if (!/^\[[a-zA-Z0-9\\/]+(?::[a-zA-Z0-9\\/]+)?\] /.test(title)) {
5359
throw new Error(
5460
`Invalid title format, must start with ${

test/validate.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ describe("validate", () => {
5252
"[SECURITY][Refactor:Autograding]foo",
5353
"Invalid title format, must start with [SECURITY][<TYPE>:<MODULE>] and have space before description.",
5454
],
55+
[
56+
"[Bugfix: Submission] xxx",
57+
"Unexpected space between <TYPE> and <MODULE> (e.g. [<TYPE>: <MODULE>]), there should be no space (e.g. [<TYPE>:<MODULE>]).",
58+
],
5559
[
5660
"[SYSADMIN ACTION][SECURITY][Refactor:Autograding]foo",
5761
"Invalid title format, must start with [SYSADMIN ACTION][SECURITY][<TYPE>:<MODULE>] and have space before description.",

0 commit comments

Comments
 (0)