bpmnlint 11.8.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 CHANGED
@@ -1,5 +1,6 @@
1
1
  const allRules = [
2
2
  'ad-hoc-sub-process',
3
+ 'conditional-event',
3
4
  'conditional-flows',
4
5
  'end-event-required',
5
6
  'event-based-gateway',
@@ -1,6 +1,7 @@
1
1
  module.exports = {
2
2
  rules: {
3
3
  'ad-hoc-sub-process': 'error',
4
+ 'conditional-event': 'error',
4
5
  'event-based-gateway': 'error',
5
6
  'event-sub-process-typed-start-event': 'error',
6
7
  'link-event': 'error',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bpmnlint",
3
3
  "description": "Validate your BPMN diagrams based on configurable lint rules",
4
- "version": "11.8.0",
4
+ "version": "11.10.0",
5
5
  "main": "lib/index.js",
6
6
  "keywords": [
7
7
  "bpmnlint",
@@ -39,7 +39,7 @@
39
39
  "bpmnlint": "./bin/bpmnlint.js"
40
40
  },
41
41
  "dependencies": {
42
- "@bpmn-io/moddle-utils": "^0.2.1",
42
+ "@bpmn-io/moddle-utils": "^0.3.0",
43
43
  "ansi-colors": "^4.1.3",
44
44
  "bpmn-moddle": "^10.0.0",
45
45
  "bpmnlint-utils": "^1.1.1",
@@ -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
  /**