bpmnlint-plugin-camunda-compat 2.10.0 → 2.11.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/index.js +13 -0
- package/package.json +1 -1
- package/rules/camunda-cloud/user-task-form.js +43 -8
- package/rules/utils/element.js +16 -4
package/index.js
CHANGED
@@ -64,6 +64,8 @@ const camundaCloud83Rules = withConfig({
|
|
64
64
|
'signal-reference': 'error'
|
65
65
|
}, { version: '8.3' });
|
66
66
|
|
67
|
+
const camundaCloud84Rules = withConfig(camundaCloud83Rules, { version: '8.4' });
|
68
|
+
|
67
69
|
const camundaPlatform719Rules = withConfig({
|
68
70
|
'history-time-to-live': 'error'
|
69
71
|
}, {
|
@@ -76,6 +78,11 @@ const camundaPlatform720Rules = withConfig(camundaPlatform719Rules, {
|
|
76
78
|
version: '7.20'
|
77
79
|
});
|
78
80
|
|
81
|
+
const camundaPlatform721Rules = withConfig(camundaPlatform720Rules, {
|
82
|
+
platform: 'camunda-platform',
|
83
|
+
version: '7.21'
|
84
|
+
});
|
85
|
+
|
79
86
|
const rules = {
|
80
87
|
'element-type': './rules/camunda-cloud/element-type',
|
81
88
|
'called-element': './rules/camunda-cloud/called-element',
|
@@ -138,12 +145,18 @@ module.exports = {
|
|
138
145
|
'camunda-cloud-8-3': {
|
139
146
|
rules: camundaCloud83Rules
|
140
147
|
},
|
148
|
+
'camunda-cloud-8-4': {
|
149
|
+
rules: camundaCloud84Rules
|
150
|
+
},
|
141
151
|
'camunda-platform-7-19': {
|
142
152
|
rules: camundaPlatform719Rules
|
143
153
|
},
|
144
154
|
'camunda-platform-7-20': {
|
145
155
|
rules: camundaPlatform720Rules
|
146
156
|
},
|
157
|
+
'camunda-platform-7-21': {
|
158
|
+
rules: camundaPlatform721Rules
|
159
|
+
},
|
147
160
|
'all': {
|
148
161
|
rules: Object.keys(rules).reduce((allRules, rule) => {
|
149
162
|
return {
|
package/package.json
CHANGED
@@ -4,14 +4,19 @@ const {
|
|
4
4
|
findExtensionElement,
|
5
5
|
findExtensionElements,
|
6
6
|
findParent,
|
7
|
-
hasProperties
|
7
|
+
hasProperties,
|
8
|
+
hasProperty
|
8
9
|
} = require('../utils/element');
|
9
10
|
|
10
11
|
const { reportErrors } = require('../utils/reporter');
|
11
12
|
|
12
13
|
const { skipInNonExecutableProcess } = require('../utils/rule');
|
13
14
|
|
14
|
-
|
15
|
+
const { greaterOrEqual } = require('../utils/version');
|
16
|
+
|
17
|
+
const formIdAllowedVersion = '8.4';
|
18
|
+
|
19
|
+
module.exports = skipInNonExecutableProcess(function({ version }) {
|
15
20
|
function check(node, reporter) {
|
16
21
|
if (!is(node, 'bpmn:UserTask')) {
|
17
22
|
return;
|
@@ -23,13 +28,39 @@ module.exports = skipInNonExecutableProcess(function() {
|
|
23
28
|
return;
|
24
29
|
}
|
25
30
|
|
26
|
-
let errors =
|
27
|
-
|
28
|
-
|
31
|
+
let errors = [];
|
32
|
+
|
33
|
+
if (isFormIdAllowed(version)) {
|
34
|
+
|
35
|
+
// Camunda 8.3 and newer
|
36
|
+
errors = hasProperty(formDefinition, [
|
37
|
+
'formKey',
|
38
|
+
'formId'
|
39
|
+
], node);
|
40
|
+
} else {
|
41
|
+
|
42
|
+
// Camunda 8.2 and older
|
43
|
+
errors = hasProperties(formDefinition, {
|
44
|
+
formId: {
|
45
|
+
allowed: false,
|
46
|
+
allowedVersion: formIdAllowedVersion
|
47
|
+
}
|
48
|
+
}, node);
|
49
|
+
|
50
|
+
if (errors.length) {
|
51
|
+
reportErrors(node, reporter, errors);
|
52
|
+
|
53
|
+
return;
|
29
54
|
}
|
30
|
-
}, node);
|
31
55
|
|
32
|
-
|
56
|
+
errors = hasProperties(formDefinition, {
|
57
|
+
formKey: {
|
58
|
+
required: true
|
59
|
+
}
|
60
|
+
}, node);
|
61
|
+
}
|
62
|
+
|
63
|
+
if (errors.length) {
|
33
64
|
reportErrors(node, reporter, errors);
|
34
65
|
|
35
66
|
return;
|
@@ -49,7 +80,7 @@ module.exports = skipInNonExecutableProcess(function() {
|
|
49
80
|
}
|
50
81
|
}, node);
|
51
82
|
|
52
|
-
if (errors
|
83
|
+
if (errors.length) {
|
53
84
|
reportErrors(node, reporter, errors);
|
54
85
|
}
|
55
86
|
}
|
@@ -77,4 +108,8 @@ function findUserTaskForm(node, formKey) {
|
|
77
108
|
return `camunda-forms:bpmn:${ id }` === formKey;
|
78
109
|
});
|
79
110
|
}
|
111
|
+
}
|
112
|
+
|
113
|
+
function isFormIdAllowed(version) {
|
114
|
+
return greaterOrEqual(version, formIdAllowedVersion);
|
80
115
|
}
|
package/rules/utils/element.js
CHANGED
@@ -4,6 +4,8 @@ const {
|
|
4
4
|
isFunction,
|
5
5
|
isNil,
|
6
6
|
isObject,
|
7
|
+
isString,
|
8
|
+
isUndefined,
|
7
9
|
some
|
8
10
|
} = require('min-dash');
|
9
11
|
|
@@ -141,7 +143,7 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
|
|
141
143
|
|
142
144
|
const propertyValue = node.get(propertyName);
|
143
145
|
|
144
|
-
if (propertyChecks.required &&
|
146
|
+
if (propertyChecks.required && isEmptyValue(propertyValue)) {
|
145
147
|
return [
|
146
148
|
...results,
|
147
149
|
{
|
@@ -164,7 +166,7 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
|
|
164
166
|
if (propertyChecks.dependentRequired) {
|
165
167
|
const dependency = node.get(propertyChecks.dependentRequired);
|
166
168
|
|
167
|
-
if (dependency &&
|
169
|
+
if (dependency && isEmptyValue(propertyValue)) {
|
168
170
|
return [
|
169
171
|
...results,
|
170
172
|
{
|
@@ -303,7 +305,9 @@ function findProperties(node, propertyNames) {
|
|
303
305
|
const properties = [];
|
304
306
|
|
305
307
|
for (const propertyName of propertyNames) {
|
306
|
-
|
308
|
+
const propertyValue = node.get(propertyName);
|
309
|
+
|
310
|
+
if (!isEmptyValue(propertyValue)) {
|
307
311
|
properties.push(node.get(propertyName));
|
308
312
|
}
|
309
313
|
}
|
@@ -470,4 +474,12 @@ function findParent(node, type) {
|
|
470
474
|
return findParent(parent, type);
|
471
475
|
}
|
472
476
|
|
473
|
-
module.exports.findParent = findParent;
|
477
|
+
module.exports.findParent = findParent;
|
478
|
+
|
479
|
+
function isEmptyString(value) {
|
480
|
+
return isString(value) && value.trim() === '';
|
481
|
+
}
|
482
|
+
|
483
|
+
function isEmptyValue(value) {
|
484
|
+
return isUndefined(value) || isNil(value) || isEmptyString(value);
|
485
|
+
}
|