Skip to content

Commit c254d28

Browse files
committed
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.
1 parent a941be3 commit c254d28

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

lib/rules/title-format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports = {
5252
}
5353
}
5454

55-
const result = /^(.+?): [A-Z]/.exec(context.title)
55+
const result = /^([^:]+?): [A-Z]/.exec(context.title)
5656
if (result) {
5757
context.report({
5858
id: id

test/rules/title-format.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,43 @@ test('rule: title-format', (t) => {
7777
tt.end()
7878
})
7979

80+
t.test('first word after subsystem should be in lowercase', (tt) => {
81+
tt.plan(2)
82+
const context = makeCommit('test: Some message')
83+
84+
context.report = (opts) => {
85+
tt.pass('called report')
86+
tt.strictSame(opts, {
87+
id: 'title-format'
88+
, message: 'First word after subsystem(s) in title should be lowercase.'
89+
, string: 'test: Some message'
90+
, line: 0
91+
, column: 7
92+
, level: 'fail'
93+
})
94+
}
95+
96+
Rule.validate(context)
97+
tt.end()
98+
})
99+
100+
t.test('colon in message followed by uppercase word', (tt) => {
101+
tt.plan(2)
102+
const context = makeCommit('test: some message: Message')
103+
104+
context.report = (opts) => {
105+
tt.pass('called report')
106+
tt.strictSame(opts, {
107+
id: 'title-format'
108+
, message: 'Title is formatted correctly.'
109+
, string: ''
110+
, level: 'pass'
111+
})
112+
}
113+
114+
Rule.validate(context)
115+
tt.end()
116+
})
117+
80118
t.end()
81119
})

0 commit comments

Comments
 (0)