bpmnlint-plugin-camunda-compat 0.18.0 → 0.19.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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "all": "npm run lint && npm test",
8
8
  "dev": "npm run test:watch",
9
9
  "lint": "eslint .",
10
- "test": "mocha test/**/*.spec.js",
10
+ "test": "mocha 'test/**/*.spec.js'",
11
11
  "test:watch": "npm run test -- --watch"
12
12
  },
13
13
  "repository": {
@@ -2,6 +2,7 @@ module.exports = {
2
2
  'bpmn:Association': '1.0',
3
3
  'bpmn:BoundaryEvent': {
4
4
  'bpmn:ErrorEventDefinition': '1.0',
5
+ 'bpmn:EscalationEventDefinition': '8.2',
5
6
  'bpmn:MessageEventDefinition': '1.0',
6
7
  'bpmn:TimerEventDefinition': '1.0'
7
8
  },
@@ -15,6 +16,7 @@ module.exports = {
15
16
  'bpmn:EndEvent': {
16
17
  '_': '1.0',
17
18
  'bpmn:ErrorEventDefinition': '1.0',
19
+ 'bpmn:EscalationEventDefinition': '8.2',
18
20
  'bpmn:MessageEventDefinition': '1.2',
19
21
  'bpmn:TerminateEventDefinition': '8.1'
20
22
  },
@@ -29,6 +31,7 @@ module.exports = {
29
31
  },
30
32
  'bpmn:IntermediateThrowEvent': {
31
33
  '_': '1.1',
34
+ 'bpmn:EscalationEventDefinition': '8.2',
32
35
  'bpmn:MessageEventDefinition': '1.2',
33
36
  'bpmn:LinkEventDefinition': '8.2'
34
37
  },
@@ -45,6 +48,7 @@ module.exports = {
45
48
  'bpmn:StartEvent': {
46
49
  '_': '1.0',
47
50
  'bpmn:ErrorEventDefinition': '1.0',
51
+ 'bpmn:EscalationEventDefinition': '8.2',
48
52
  'bpmn:MessageEventDefinition': '1.0',
49
53
  'bpmn:TimerEventDefinition': '1.0'
50
54
  },
@@ -1,6 +1,5 @@
1
1
  const {
2
- is,
3
- isAny
2
+ is
4
3
  } = require('bpmnlint-utils');
5
4
 
6
5
  const { getPath } = require('@bpmn-io/moddle-utils');
@@ -31,7 +30,10 @@ const handlersMap = {
31
30
  '8.1': [
32
31
  checkErrorCode
33
32
  ],
34
- '8.2': []
33
+ '8.2': [
34
+ checkErrorCatchEvent,
35
+ checkEscalationCatchEvent
36
+ ]
35
37
  };
36
38
 
37
39
  module.exports = noExpressionRule;
@@ -58,7 +60,7 @@ function checkForVersion(node, version) {
58
60
  const handlers = handlersMap[version];
59
61
 
60
62
  return handlers.reduce((errors, handler) => {
61
- const handlerErrors = handler(node, version) || [];
63
+ const handlerErrors = handler(node) || [];
62
64
  return errors.concat(handlerErrors);
63
65
  }, []);
64
66
  }
@@ -71,8 +73,12 @@ function noExpression(node, propertyName, parentNode, allowedVersion) {
71
73
  return;
72
74
  }
73
75
 
76
+ const errorMessage = allowedVersion ?
77
+ `Expression statement <${truncate(propertyValue)}> only supported by Camunda Platform ${allowedVersion} or newer` :
78
+ `Expression statement <${truncate(propertyValue)}> not supported`;
79
+
74
80
  return {
75
- message: `Expression statement <${truncate(propertyValue)}> only supported by Camunda Platform 8.2 or newer`,
81
+ message: errorMessage,
76
82
  path: path
77
83
  ? [ ...path, propertyName ]
78
84
  : [ propertyName ],
@@ -91,7 +97,7 @@ function isExpression(value) {
91
97
  }
92
98
 
93
99
  function checkErrorCode(node) {
94
- if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
100
+ if (!is(node, 'bpmn:Event')) {
95
101
  return;
96
102
  }
97
103
 
@@ -107,7 +113,39 @@ function checkErrorCode(node) {
107
113
  return;
108
114
  }
109
115
 
110
- return errorRef && noExpression(errorRef, 'errorCode', node, '8.2');
116
+ if (is(node, 'bpmn:CatchEvent')) {
117
+ return noExpression(errorRef, 'errorCode', node, null);
118
+ } else {
119
+ return noExpression(errorRef, 'errorCode', node, '8.2');
120
+ }
121
+ }
122
+
123
+ function checkErrorCatchEvent(node) {
124
+ if (!is(node, 'bpmn:CatchEvent')) {
125
+ return;
126
+ }
127
+
128
+ return checkErrorCode(node);
129
+ }
130
+
131
+ function checkEscalationCatchEvent(node) {
132
+ if (!is(node, 'bpmn:CatchEvent')) {
133
+ return;
134
+ }
135
+
136
+ const eventDefinition = getEventDefinition(node);
137
+
138
+ if (!eventDefinition || !is(eventDefinition, 'bpmn:EscalationEventDefinition')) {
139
+ return;
140
+ }
141
+
142
+ const escalationRef = eventDefinition.get('escalationRef');
143
+
144
+ if (!escalationRef) {
145
+ return;
146
+ }
147
+
148
+ return noExpression(escalationRef, 'escalationCode', node, null);
111
149
  }
112
150
 
113
151
  function truncate(string, maxLength = 10) {