This repository was archived by the owner on Jun 27, 2022. It is now read-only.
forked from nodejs/core-validate-commit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubsystem.js
144 lines (139 loc) · 2.38 KB
/
subsystem.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'use strict'
const id = 'subsystem'
const validSubsystems = [
'benchmark',
'build',
'bootstrap',
'cli',
'deps',
'doc',
'errors',
'etw',
'esm',
'gyp',
'inspector',
'lib',
'loader',
'meta',
'msi',
'node',
'node-api',
'perfctr',
'policy',
'src',
'test',
'tools',
'typings',
'wasm',
'win',
// core libs
'assert',
'async_hooks',
'buffer',
'child_process',
'cluster',
'console',
'constants',
'crypto',
'debugger',
'dgram',
'dns',
'domain',
'events',
'fs',
'http',
'http2',
'https',
'inspector',
'module',
'net',
'os',
'path',
'perf_hooks',
'process',
'punycode',
'querystring',
'quic',
'readline',
'repl',
'report',
'stream',
'string_decoder',
'sys',
'test_runner',
'timers',
'tls',
'trace_events',
'tty',
'url',
'util',
'v8',
'vm',
'wasi',
'worker',
'zlib'
]
module.exports = {
id: id,
meta: {
description: 'enforce subsystem validity',
recommended: true
},
defaults: {
subsystems: validSubsystems
},
options: {
subsystems: validSubsystems
},
validate: (context, rule) => {
const subs = rule.options.subsystems
const parsed = context.toJSON()
if (!parsed.subsystems.length) {
if (!parsed.release && !parsed.working) {
// Missing subsystem
context.report({
id: id,
message: 'Missing subsystem.',
string: parsed.title,
line: 0,
column: 0,
level: 'fail',
wanted: subs
})
} else {
context.report({
id: id,
message: 'Release commits do not have subsystems',
string: '',
level: 'skip'
})
}
} else {
let failed = false
for (const sub of parsed.subsystems) {
if (!~subs.indexOf(sub)) {
failed = true
// invalid subsystem
const column = parsed.title.indexOf(sub)
context.report({
id: id,
message: `Invalid subsystem: "${sub}"`,
string: parsed.title,
line: 0,
column: column,
level: 'fail',
wanted: subs
})
}
}
if (!failed) {
context.report({
id: id,
message: 'valid subsystems',
string: parsed.subsystems.join(','),
level: 'pass'
})
}
}
}
}