forked from nodejs/core-validate-commit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtitle-length.js
55 lines (51 loc) · 1.04 KB
/
title-length.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict'
const id = 'title-length'
module.exports = {
id: id,
meta: {
description: 'enforce max length of commit title',
recommended: true
},
defaults: {
length: 50,
max_length: 72
},
options: {
length: 50,
max_length: 72
},
validate: (context, rule) => {
const max = rule.options.max_length
if (context.title.length > max) {
context.report({
id: id,
message: `Title must be <= ${max} columns.`,
string: context.title,
maxLength: max,
line: 0,
column: max,
level: 'fail'
})
return
}
const len = rule.options.length
if (context.title.length > len) {
context.report({
id: id,
message: `Title should be <= ${len} columns.`,
string: context.title,
maxLength: len,
line: 0,
column: len,
level: 'warn'
})
return
}
context.report({
id: id,
message: `Title is <= ${len} columns.`,
string: '',
level: 'pass'
})
}
}