From 60609b7c2e668bb288b7ee274369b9e8034716b5 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Tue, 26 Feb 2019 19:11:49 -0500 Subject: [PATCH] rules: only check case of first word after subsystem The first colon denotes the subsystem(s). Any further colons are part of the title and should not be subject to the rule that the following word be in lowercase. --- lib/rules/title-format.js | 2 +- test/rules/title-format.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) 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() })