Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
richardlau committed Feb 27, 2019
commit 60609b7c2e668bb288b7ee274369b9e8034716b5
2 changes: 1 addition & 1 deletion lib/rules/title-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions test/rules/title-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})