diff --git a/lib/rules/title-format.js b/lib/rules/title-format.js index 79b8ffd..9a8753c 100644 --- a/lib/rules/title-format.js +++ b/lib/rules/title-format.js @@ -52,7 +52,7 @@ module.exports = { } } - const result = /^(.+?): [A-Z]/.exec(context.title) + const result = /^([^:]+?): [A-Z]/.exec(context.title) if (result) { context.report({ id: id diff --git a/test/rules/title-format.js b/test/rules/title-format.js index 2cbe31b..dcbe3d0 100644 --- a/test/rules/title-format.js +++ b/test/rules/title-format.js @@ -77,5 +77,43 @@ test('rule: title-format', (t) => { tt.end() }) + t.test('first word after subsystem should be in lowercase', (tt) => { + tt.plan(2) + const context = makeCommit('test: Some message') + + context.report = (opts) => { + tt.pass('called report') + tt.strictSame(opts, { + id: 'title-format' + , message: 'First word after subsystem(s) in title should be lowercase.' + , string: 'test: Some message' + , line: 0 + , column: 7 + , level: 'fail' + }) + } + + Rule.validate(context) + tt.end() + }) + + t.test('colon in message followed by uppercase word', (tt) => { + tt.plan(2) + const context = makeCommit('test: some message: Message') + + context.report = (opts) => { + tt.pass('called report') + tt.strictSame(opts, { + id: 'title-format' + , message: 'Title is formatted correctly.' + , string: '' + , level: 'pass' + }) + } + + Rule.validate(context) + tt.end() + }) + t.end() })