forked from nodejs/core-validate-commit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreviewers.js
51 lines (46 loc) · 1.18 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
'use strict'
const id = 'reviewers'
module.exports = {
id: 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: id
, message: 'skipping reviewers for release commit'
, string: ''
, level: 'skip'
})
return
}
if (!Array.isArray(parsed.reviewers) || !parsed.reviewers.length) {
// See nodejs/node#5aac4c42da104c30d8f701f1042d61c2f06b7e6c
// for an example
return context.report({
id: 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: id
, message: 'reviewers are valid'
, string: ''
, level: 'pass'
})
}
}