bpmnlint 11.9.0 → 11.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/all.js +1 -0
- package/config/correctness.js +1 -0
- package/package.json +1 -1
- package/rules/conditional-event.js +52 -0
- package/rules/helper.js +16 -0
package/config/all.js
CHANGED
package/config/correctness.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const {
|
|
2
|
+
is
|
|
3
|
+
} = require('bpmnlint-utils');
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
annotateRule,
|
|
7
|
+
isInExecutableProcess
|
|
8
|
+
} = require('./helper');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Ensures that a conditional event has a condition specified.
|
|
13
|
+
*
|
|
14
|
+
* @type { import('../lib/types.js').RuleFactory }
|
|
15
|
+
*/
|
|
16
|
+
module.exports = function() {
|
|
17
|
+
|
|
18
|
+
function check(node, reporter) {
|
|
19
|
+
|
|
20
|
+
if (!isInExecutableProcess(node)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const eventDefinition = getConditionalEventDefinition(node);
|
|
25
|
+
|
|
26
|
+
if (!eventDefinition) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!hasCondition(eventDefinition)) {
|
|
31
|
+
reporter.report(node.id, 'Conditional event is missing a condition', [ 'condition' ]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return annotateRule('conditional-event', {
|
|
36
|
+
check
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function getConditionalEventDefinition(node) {
|
|
42
|
+
if (!is(node, 'bpmn:Event')) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const eventDefinitions = node.eventDefinitions || [];
|
|
47
|
+
return eventDefinitions.find(def => is(def, 'bpmn:ConditionalEventDefinition'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function hasCondition(eventDefinition) {
|
|
51
|
+
return !!eventDefinition.condition?.body;
|
|
52
|
+
}
|
package/rules/helper.js
CHANGED
|
@@ -71,6 +71,22 @@ function findParent(node, type) {
|
|
|
71
71
|
module.exports.findParent = findParent;
|
|
72
72
|
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Check if the node is inside of an executable process.
|
|
76
|
+
*
|
|
77
|
+
* @param { ModdleElement } node
|
|
78
|
+
*
|
|
79
|
+
* @return { boolean }
|
|
80
|
+
*/
|
|
81
|
+
function isInExecutableProcess(node) {
|
|
82
|
+
const process = findParent(node, 'bpmn:Process');
|
|
83
|
+
|
|
84
|
+
return process && process.isExecutable;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports.isInExecutableProcess = isInExecutableProcess;
|
|
88
|
+
|
|
89
|
+
|
|
74
90
|
const documentationBaseUrl = 'https://github.com/bpmn-io/bpmnlint/blob/main/docs/rules';
|
|
75
91
|
|
|
76
92
|
/**
|