-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathreviewers.js
59 lines (55 loc) · 1.42 KB
/
reviewers.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
56
57
58
59
const id = 'reviewers'
export default {
id,
meta: {
description: 'enforce having reviewers',
recommended: true
},
defaults: {},
options: {},
validate: (context, rule) => {
const parsed = context.toJSON()
// release commits generally won't have any reviewers
if (parsed.release) {
context.report({
id,
message: 'skipping reviewers for release commit',
string: '',
level: 'skip'
})
return
}
if (rule.options.expectsMissing) {
return context.report({
id,
message: 'Commit must not have any reviewer.',
string: null,
line: 0,
column: 0,
level: parsed.reviewers.length ? 'fail' : 'pass'
})
}
if (!Array.isArray(parsed.reviewers) || !parsed.reviewers.length) {
// See nodejs/node#5aac4c42da104c30d8f701f1042d61c2f06b7e6c
// for an example
return context.report({
id,
message: 'Commit must have at least 1 reviewer.',
string: null,
line: 0,
column: 0,
level: 'fail'
})
}
// TODO(evanlucas) verify that each reviewer is a collaborator
// This will probably be easier to do once we move gitlint-parser-node
// over to using an array of objects with parsed reviewers vs an array
// of strings
context.report({
id,
message: 'reviewers are valid',
string: '',
level: 'pass'
})
}
}