bpmnlint-plugin-camunda-compat 2.1.0 → 2.3.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/index.js CHANGED
@@ -44,6 +44,7 @@ const camundaCloud82Rules = withConfig({
44
44
  'no-candidate-users',
45
45
  'no-task-schedule'
46
46
  ]),
47
+ 'escalation-boundary-event-attached-to-ref': 'error',
47
48
  'escalation-reference': 'error',
48
49
  'no-signal-event-sub-process': 'error',
49
50
  'task-schedule': 'error'
@@ -72,6 +73,7 @@ const rules = {
72
73
  'collapsed-subprocess': './rules/camunda-cloud/collapsed-subprocess',
73
74
  'duplicate-task-headers': './rules/camunda-cloud/duplicate-task-headers',
74
75
  'error-reference': './rules/camunda-cloud/error-reference',
76
+ 'escalation-boundary-event-attached-to-ref': './rules/camunda-cloud/escalation-boundary-event-attached-to-ref',
75
77
  'escalation-reference': './rules/camunda-cloud/escalation-reference',
76
78
  'event-based-gateway-target': './rules/camunda-cloud/event-based-gateway-target',
77
79
  'executable-process': './rules/camunda-cloud/executable-process',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,7 +16,7 @@ module.exports = skipInNonExecutableProcess(function() {
16
16
  const node = di.bpmnElement;
17
17
 
18
18
  const error = {
19
- message: `A <${ node.$type }> must be expanded.`,
19
+ message: `A <${ node.$type }> must be expanded`,
20
20
  data: {
21
21
  type: ERROR_TYPES.ELEMENT_COLLAPSED_NOT_ALLOWED,
22
22
  node: node,
@@ -0,0 +1,48 @@
1
+ const {
2
+ is,
3
+ isAny
4
+ } = require('bpmnlint-utils');
5
+
6
+ const {
7
+ getEventDefinition,
8
+ isAnyExactly
9
+ } = require('../utils/element');
10
+
11
+ const { ERROR_TYPES } = require('../utils/error-types');
12
+
13
+ const { reportErrors } = require('../utils/reporter');
14
+
15
+ const { skipInNonExecutableProcess } = require('../utils/rule');
16
+
17
+ module.exports = skipInNonExecutableProcess(function() {
18
+ function check(node, reporter) {
19
+ if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
20
+ return;
21
+ }
22
+
23
+ const eventDefinition = getEventDefinition(node);
24
+
25
+ if (!eventDefinition || !is(eventDefinition, 'bpmn:EscalationEventDefinition')) {
26
+ return;
27
+ }
28
+
29
+ const attachedToRef = node.get('attachedToRef');
30
+
31
+ if (attachedToRef && !isAnyExactly(attachedToRef, [ 'bpmn:CallActivity', 'bpmn:SubProcess' ])) {
32
+ reportErrors(node, reporter, {
33
+ message: `Element of type <bpmn:BoundaryEvent> with event definition of type <bpmn:EscalationEventDefinition> is not allowed to be attached to element of type <${ attachedToRef.$type }>`,
34
+ path: null,
35
+ data: {
36
+ type: ERROR_TYPES.ATTACHED_TO_REF_ELEMENT_TYPE_NOT_ALLOWED,
37
+ node,
38
+ parentNode: null,
39
+ attachedToRef
40
+ }
41
+ });
42
+ }
43
+ }
44
+
45
+ return {
46
+ check
47
+ };
48
+ });
@@ -24,27 +24,35 @@ module.exports = skipInNonExecutableProcess(function() {
24
24
  return;
25
25
  }
26
26
 
27
- let errors = hasProperties(eventDefinition, {
28
- escalationRef: {
29
- required: true
30
- }
31
- }, node);
27
+ let errors = [];
32
28
 
33
- if (errors && errors.length) {
34
- reportErrors(node, reporter, errors);
29
+ if (!isNoEscalationRefAllowed(node)) {
30
+ errors = hasProperties(eventDefinition, {
31
+ escalationRef: {
32
+ required: true
33
+ }
34
+ }, node);
35
35
 
36
- return;
36
+ if (errors.length) {
37
+ reportErrors(node, reporter, errors);
38
+
39
+ return;
40
+ }
37
41
  }
38
42
 
39
43
  const escalationRef = eventDefinition.get('escalationRef');
40
44
 
45
+ if (!escalationRef) {
46
+ return;
47
+ }
48
+
41
49
  errors = hasProperties(escalationRef, {
42
50
  escalationCode: {
43
51
  required: true
44
52
  }
45
53
  }, node);
46
54
 
47
- if (errors && errors.length) {
55
+ if (errors.length) {
48
56
  reportErrors(node, reporter, errors);
49
57
  }
50
58
  }
@@ -53,3 +61,7 @@ module.exports = skipInNonExecutableProcess(function() {
53
61
  check
54
62
  };
55
63
  });
64
+
65
+ function isNoEscalationRefAllowed(node, version) {
66
+ return is(node, 'bpmn:BoundaryEvent');
67
+ }
@@ -10,6 +10,7 @@ module.exports.ERROR_TYPES = Object.freeze({
10
10
  EXTENSION_ELEMENT_NOT_ALLOWED: 'camunda.extensionElementNotAllowed',
11
11
  EXTENSION_ELEMENT_REQUIRED: 'camunda.extensionElementRequired',
12
12
  FEEL_EXPRESSION_INVALID: 'camunda.feelExpressionInvalid',
13
+ ATTACHED_TO_REF_ELEMENT_TYPE_NOT_ALLOWED: 'camunda.attachedToRefElementTypeNotAllowed',
13
14
  PROPERTY_DEPENDENT_REQUIRED: 'camunda.propertyDependentRequired',
14
15
  PROPERTY_NOT_ALLOWED: 'camunda.propertyNotAllowed',
15
16
  PROPERTY_REQUIRED: 'camunda.propertyRequired',