bpmnlint-plugin-camunda-compat 0.8.0 → 0.9.2

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/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ All notable changes to [bpmnlint-plugin-camunda-compat](https://github.com/camun
6
6
 
7
7
  ___Note:__ Yet to be released changes appear here._
8
8
 
9
+ ## 0.9.2
10
+
11
+ * `FIX`: ignore null properties ([#39](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/39))
12
+
13
+ ## 0.9.1
14
+
15
+ * `FIX`: add name to reports ([#38](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/38))
16
+
17
+ ## 0.9.0
18
+
19
+ * `FEAT`: add user task forms rule ([#32](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/32))
20
+
9
21
  ## 0.8.0
10
22
 
11
23
  * `FEAT`: add templates rule ([#31](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/31))
package/index.js CHANGED
@@ -12,7 +12,8 @@ module.exports = {
12
12
  'loop-characteristics': 'error',
13
13
  'message-reference': 'error',
14
14
  'no-template': 'error',
15
- 'subscription': 'error'
15
+ 'subscription': 'error',
16
+ 'user-task-form': 'error'
16
17
  }
17
18
  },
18
19
  'camunda-cloud-1-1': {
@@ -24,7 +25,8 @@ module.exports = {
24
25
  'loop-characteristics': 'error',
25
26
  'message-reference': 'error',
26
27
  'no-template': 'error',
27
- 'subscription': 'error'
28
+ 'subscription': 'error',
29
+ 'user-task-form': 'error'
28
30
  }
29
31
  },
30
32
  'camunda-cloud-1-2': {
@@ -36,7 +38,8 @@ module.exports = {
36
38
  'loop-characteristics': 'error',
37
39
  'message-reference': 'error',
38
40
  'no-template': 'error',
39
- 'subscription': 'error'
41
+ 'subscription': 'error',
42
+ 'user-task-form': 'error'
40
43
  }
41
44
  },
42
45
  'camunda-cloud-1-3': {
@@ -48,7 +51,8 @@ module.exports = {
48
51
  'loop-characteristics': 'error',
49
52
  'message-reference': 'error',
50
53
  'no-template': 'error',
51
- 'subscription': 'error'
54
+ 'subscription': 'error',
55
+ 'user-task-form': 'error'
52
56
  }
53
57
  },
54
58
  'camunda-cloud-8-0': {
@@ -59,7 +63,8 @@ module.exports = {
59
63
  'error-reference': 'error',
60
64
  'loop-characteristics': 'error',
61
65
  'message-reference': 'error',
62
- 'subscription': 'error'
66
+ 'subscription': 'error',
67
+ 'user-task-form': 'error'
63
68
  }
64
69
  }
65
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.8.0",
3
+ "version": "0.9.2",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "zeebe-bpmn-moddle": "^0.12.1"
36
36
  },
37
37
  "dependencies": {
38
- "@philippfromme/moddle-helpers": "^0.1.0",
38
+ "@bpmn-io/moddle-utils": "^0.1.0",
39
39
  "bpmnlint-utils": "^1.0.2",
40
40
  "min-dash": "^3.8.0"
41
41
  },
@@ -3,7 +3,7 @@ const {
3
3
  isAny
4
4
  } = require('bpmnlint-utils');
5
5
 
6
- const { getPath } = require('@philippfromme/moddle-helpers');
6
+ const { getPath } = require('@bpmn-io/moddle-utils');
7
7
 
8
8
  const {
9
9
  findExtensionElement,
@@ -0,0 +1,93 @@
1
+ const { is } = require('bpmnlint-utils');
2
+
3
+ const {
4
+ findExtensionElement,
5
+ findExtensionElements,
6
+ hasProperties
7
+ } = require('./utils/element');
8
+
9
+ const { reportErrors } = require('./utils/reporter');
10
+
11
+ module.exports = function() {
12
+ function check(node, reporter) {
13
+ if (!is(node, 'bpmn:UserTask')) {
14
+ return;
15
+ }
16
+
17
+ const formDefinition = findExtensionElement(node, 'zeebe:FormDefinition');
18
+
19
+ if (!formDefinition) {
20
+ return;
21
+ }
22
+
23
+ let errors = hasProperties(formDefinition, {
24
+ formKey: {
25
+ required: true
26
+ }
27
+ }, node);
28
+
29
+ if (errors && errors.length) {
30
+ reportErrors(node, reporter, errors);
31
+
32
+ return;
33
+ }
34
+
35
+ const formKey = formDefinition.get('formKey');
36
+
37
+ const userTaskForm = findUserTaskForm(node, formKey);
38
+
39
+ if (!userTaskForm) {
40
+ return;
41
+ }
42
+
43
+ errors = hasProperties(userTaskForm, {
44
+ body: {
45
+ required: true
46
+ }
47
+ }, node);
48
+
49
+ if (errors && errors.length) {
50
+ reportErrors(node, reporter, errors);
51
+ }
52
+ }
53
+
54
+ return {
55
+ check
56
+ };
57
+ };
58
+
59
+ function findUserTaskForm(node, formKey) {
60
+ const process = findParent(node, 'bpmn:Process');
61
+
62
+ if (!process) {
63
+ return;
64
+ }
65
+
66
+ const userTaskForms = findExtensionElements(process, 'zeebe:UserTaskForm');
67
+
68
+ if (userTaskForms && userTaskForms.length) {
69
+ return userTaskForms.find(userTaskForm => {
70
+ const id = userTaskForm.get('id');
71
+
72
+ return `camunda-forms:bpmn:${ id }` === formKey;
73
+ });
74
+ }
75
+ }
76
+
77
+ function findParent(node, type) {
78
+ if (!node) {
79
+ return null;
80
+ }
81
+
82
+ const parent = node.$parent;
83
+
84
+ if (!parent) {
85
+ return node;
86
+ }
87
+
88
+ if (is(parent, type)) {
89
+ return parent;
90
+ }
91
+
92
+ return findParent(parent, type);
93
+ }
@@ -1,12 +1,13 @@
1
1
  const {
2
2
  isArray,
3
3
  isDefined,
4
+ isNil,
4
5
  some
5
6
  } = require('min-dash');
6
7
 
7
8
  const { isAny } = require('bpmnlint-utils');
8
9
 
9
- const { getPath } = require('@philippfromme/moddle-helpers');
10
+ const { getPath } = require('@bpmn-io/moddle-utils');
10
11
 
11
12
  const { ERROR_TYPES } = require('./error-types');
12
13
 
@@ -40,6 +41,8 @@ function findExtensionElements(node, types) {
40
41
  return values.filter(value => isAny(value, types));
41
42
  }
42
43
 
44
+ module.exports.findExtensionElements = findExtensionElements;
45
+
43
46
  function findExtensionElement(node, types) {
44
47
  const extensionElements = findExtensionElements(node, types);
45
48
 
@@ -145,7 +148,7 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
145
148
  ];
146
149
  }
147
150
 
148
- if (propertyChecks.allowed === false && isDefined(propertyValue)) {
151
+ if (propertyChecks.allowed === false && isDefined(propertyValue) && !isNil(propertyValue)) {
149
152
  return [
150
153
  ...results,
151
154
  {
@@ -1,3 +1,5 @@
1
+ const { is } = require('bpmnlint-utils');
2
+
1
3
  const { isArray } = require('min-dash');
2
4
 
3
5
  module.exports.reportErrors = function(node, reporter, errors) {
@@ -6,6 +8,31 @@ module.exports.reportErrors = function(node, reporter, errors) {
6
8
  }
7
9
 
8
10
  errors.forEach(({ message, ...options }) => {
11
+ const name = getName(node);
12
+
13
+ if (name) {
14
+ options = {
15
+ ...options,
16
+ name
17
+ };
18
+ }
19
+
9
20
  reporter.report(node.get('id'), message, options);
10
21
  });
11
- };
22
+ };
23
+
24
+ function getName(node) {
25
+ if (is(node, 'bpmn:TextAnnotation')) {
26
+ return node.get('text');
27
+ }
28
+
29
+ if (is(node, 'bpmn:Group')) {
30
+ const categoryValueRef = node.get('categoryValueRef');
31
+
32
+ return categoryValueRef && categoryValueRef.get('value');
33
+ }
34
+
35
+ return node.get('name');
36
+ }
37
+
38
+ module.exports.getName = getName;