-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrule.js
More file actions
30 lines (30 loc) · 922 Bytes
/
rule.js
File metadata and controls
30 lines (30 loc) · 922 Bytes
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
module.exports = {
"example-rule": {
meta: {
type: "suggestion",
severity: "warn",
docs: {
description: "number of function node < 10"
},
options: {}
},
create: function(context, ruleConfig) {
let maxFunc = 10;
if ('maxFunc' in ruleConfig) {
maxFunc = ruleConfig.maxFunc
}
return {
flow: function(flow) {
const numFunc =
[...flow.nodes.values()].filter((e)=>e.type=="function").length;
if (numFunc > maxFunc) {
context.report({
location: [flow.id],
message: "too many function nodes in a flow"
})
}
}
}
}
}
};