bpmnlint-plugin-camunda-compat 1.0.0 → 1.0.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,44 +14,50 @@ const { skipInNonExecutableProcess } = require('./utils/rule');
14
14
 
15
15
  const { greaterOrEqual } = require('./utils/version');
16
16
 
17
+ const noErrorRefAllowedVersion = '8.2';
18
+
17
19
  module.exports = skipInNonExecutableProcess(function({ version }) {
18
20
  function check(node, reporter) {
19
21
  if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
20
22
  return;
21
23
  }
22
24
 
23
- if (is(node, 'bpmn:CatchEvent') && greaterOrEqual(version, '8.2')) {
24
- return;
25
- }
26
-
27
25
  const eventDefinition = getEventDefinition(node);
28
26
 
29
27
  if (!eventDefinition || !is(eventDefinition, 'bpmn:ErrorEventDefinition')) {
30
28
  return;
31
29
  }
32
30
 
33
- let errors = hasProperties(eventDefinition, {
34
- errorRef: {
35
- required: true,
36
- allowedVersion: '8.2'
37
- }
38
- }, node);
31
+ let errors = [];
39
32
 
40
- if (errors && errors.length) {
41
- reportErrors(node, reporter, errors);
33
+ if (!isNoErrorRefAllowed(node, version)) {
34
+ errors = hasProperties(eventDefinition, {
35
+ errorRef: {
36
+ required: true,
37
+ allowedVersion: '8.2'
38
+ }
39
+ }, node);
42
40
 
43
- return;
41
+ if (errors.length) {
42
+ reportErrors(node, reporter, errors);
43
+
44
+ return;
45
+ }
44
46
  }
45
47
 
46
48
  const errorRef = eventDefinition.get('errorRef');
47
49
 
50
+ if (!errorRef) {
51
+ return;
52
+ }
53
+
48
54
  errors = hasProperties(errorRef, {
49
55
  errorCode: {
50
56
  required: true
51
57
  }
52
58
  }, node);
53
59
 
54
- if (errors && errors.length) {
60
+ if (errors.length) {
55
61
  reportErrors(node, reporter, errors);
56
62
  }
57
63
  }
@@ -59,4 +65,8 @@ module.exports = skipInNonExecutableProcess(function({ version }) {
59
65
  return {
60
66
  check
61
67
  };
62
- });
68
+ });
69
+
70
+ function isNoErrorRefAllowed(node, version) {
71
+ return is(node, 'bpmn:CatchEvent') && greaterOrEqual(version, noErrorRefAllowedVersion);
72
+ }