bpmnlint-plugin-camunda-compat 0.7.1 → 0.9.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/CHANGELOG.md +13 -1
- package/README.md +5 -6
- package/index.js +46 -37
- package/package.json +3 -4
- package/rules/{has-called-decision-or-task-definition → called-decision-or-task-definition}/config.js +0 -0
- package/rules/{has-called-decision-or-task-definition → called-decision-or-task-definition}/index.js +1 -1
- package/rules/{has-called-element.js → called-element.js} +0 -0
- package/rules/{is-element → element-type}/config.js +0 -0
- package/rules/{is-element → element-type}/index.js +0 -0
- package/rules/{has-error-reference.js → error-reference.js} +0 -0
- package/rules/{has-loop-characteristics.js → loop-characteristics.js} +0 -0
- package/rules/{has-message-reference.js → message-reference.js} +0 -0
- package/rules/no-template.js +21 -0
- package/rules/{has-subscription.js → subscription.js} +0 -0
- package/rules/user-task-form.js +93 -0
- package/rules/utils/element.js +22 -1
- package/rules/utils/error-types.js +1 -0
- package/rules/utils/reporter.js +28 -1
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.1
|
10
|
+
|
11
|
+
* `FIX`: add name to reports ([#38](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/38))
|
12
|
+
|
13
|
+
## 0.9.0
|
14
|
+
|
15
|
+
* `FEAT`: add user task forms rule ([#32](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/32))
|
16
|
+
|
17
|
+
## 0.8.0
|
18
|
+
|
19
|
+
* `FEAT`: add templates rule ([#31](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/31))
|
20
|
+
|
9
21
|
## 0.7.1
|
10
22
|
|
11
23
|
* `FIX`: lint subscription only if start event child of sub process ([#34](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/34))
|
@@ -17,7 +29,7 @@ ___Note:__ Yet to be released changes appear here._
|
|
17
29
|
|
18
30
|
### Breaking Changes
|
19
31
|
|
20
|
-
* configuration not selected based on execution platform and version anymore
|
32
|
+
* configuration not selected based on execution platform and version anymore, either configure manually or use [`@camunda/linting`](https://github.com/camunda/linting)
|
21
33
|
* error message not adjusted to be shown in Camunda Modeler anymore
|
22
34
|
* error type ELEMENT_TYPE changed to ELEMENT_TYPE_NOT_ALLOWED
|
23
35
|
* error type PROPERTY_TYPE changed to PROPERTY_TYPE_NOT_ALLOWED
|
package/README.md
CHANGED
@@ -2,25 +2,24 @@
|
|
2
2
|
|
3
3
|
[](https://github.com/camunda/bpmnlint-plugin-camunda-compat/actions?query=workflow%3ACI)
|
4
4
|
|
5
|
-
Camunda BPMN compatibility
|
5
|
+
Camunda BPMN compatibility provided as a [bpmnlint](https://github.com/bpmn-io/bpmnlint) plug-in.
|
6
6
|
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
|
10
|
-
|
10
|
+
To configure the linter dynamically based on the [execution platform and version](https://github.com/camunda/modeler-moddle), use [`@camunda/linting`](https://github.com/camunda/linting).
|
11
|
+
|
12
|
+
To configure the linter statically, add the configuration corresponding to your execution platform and version to your `.bpmnlintrc` file:
|
11
13
|
|
12
14
|
```
|
13
15
|
{
|
14
16
|
"extends": [
|
15
17
|
"bpmnlint:recommended",
|
16
|
-
"plugin:camunda-compat/
|
18
|
+
"plugin:camunda-compat/camunda-cloud-8-0"
|
17
19
|
]
|
18
20
|
}
|
19
21
|
```
|
20
22
|
|
21
|
-
To validate a diagram it must be pinned to a particular execution platform via the [`modeler`](https://github.com/camunda/modeler-moddle) BPMN 2.0 extension.
|
22
|
-
|
23
|
-
|
24
23
|
## Resources
|
25
24
|
|
26
25
|
* [Issues](https://github.com/camunda/bpmnlint-plugin-camunda-compat/issues)
|
package/index.js
CHANGED
@@ -1,61 +1,70 @@
|
|
1
|
-
const
|
2
|
-
|
1
|
+
const calledDecisionOrTaskDefinitionConfig = require('./rules/called-decision-or-task-definition/config'),
|
2
|
+
elementTypeConfig = require('./rules/element-type/config');
|
3
3
|
|
4
4
|
module.exports = {
|
5
5
|
configs: {
|
6
6
|
'camunda-cloud-1-0': {
|
7
7
|
rules: {
|
8
|
-
'
|
9
|
-
'
|
10
|
-
'
|
11
|
-
'
|
12
|
-
'
|
13
|
-
'
|
14
|
-
'
|
8
|
+
'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud10 ],
|
9
|
+
'called-element': 'error',
|
10
|
+
'element-type': [ 'error', elementTypeConfig.camundaCloud10 ],
|
11
|
+
'error-reference': 'error',
|
12
|
+
'loop-characteristics': 'error',
|
13
|
+
'message-reference': 'error',
|
14
|
+
'no-template': 'error',
|
15
|
+
'subscription': 'error',
|
16
|
+
'user-task-form': 'error'
|
15
17
|
}
|
16
18
|
},
|
17
19
|
'camunda-cloud-1-1': {
|
18
20
|
rules: {
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'
|
25
|
-
'
|
21
|
+
'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud11 ],
|
22
|
+
'called-element': 'error',
|
23
|
+
'element-type': [ 'error', elementTypeConfig.camundaCloud11 ],
|
24
|
+
'error-reference': 'error',
|
25
|
+
'loop-characteristics': 'error',
|
26
|
+
'message-reference': 'error',
|
27
|
+
'no-template': 'error',
|
28
|
+
'subscription': 'error',
|
29
|
+
'user-task-form': 'error'
|
26
30
|
}
|
27
31
|
},
|
28
32
|
'camunda-cloud-1-2': {
|
29
33
|
rules: {
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'
|
34
|
-
'
|
35
|
-
'
|
36
|
-
'
|
34
|
+
'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud12 ],
|
35
|
+
'called-element': 'error',
|
36
|
+
'element-type': [ 'error', elementTypeConfig.camundaCloud12 ],
|
37
|
+
'error-reference': 'error',
|
38
|
+
'loop-characteristics': 'error',
|
39
|
+
'message-reference': 'error',
|
40
|
+
'no-template': 'error',
|
41
|
+
'subscription': 'error',
|
42
|
+
'user-task-form': 'error'
|
37
43
|
}
|
38
44
|
},
|
39
45
|
'camunda-cloud-1-3': {
|
40
46
|
rules: {
|
41
|
-
'
|
42
|
-
'
|
43
|
-
'
|
44
|
-
'
|
45
|
-
'
|
46
|
-
'
|
47
|
-
'
|
47
|
+
'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud13 ],
|
48
|
+
'called-element': 'error',
|
49
|
+
'element-type': [ 'error', elementTypeConfig.camundaCloud12 ],
|
50
|
+
'error-reference': 'error',
|
51
|
+
'loop-characteristics': 'error',
|
52
|
+
'message-reference': 'error',
|
53
|
+
'no-template': 'error',
|
54
|
+
'subscription': 'error',
|
55
|
+
'user-task-form': 'error'
|
48
56
|
}
|
49
57
|
},
|
50
58
|
'camunda-cloud-8-0': {
|
51
59
|
rules: {
|
52
|
-
'
|
53
|
-
'
|
54
|
-
'
|
55
|
-
'
|
56
|
-
'
|
57
|
-
'
|
58
|
-
'
|
60
|
+
'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud13 ],
|
61
|
+
'called-element': 'error',
|
62
|
+
'element-type': [ 'error', elementTypeConfig.camundaCloud12 ],
|
63
|
+
'error-reference': 'error',
|
64
|
+
'loop-characteristics': 'error',
|
65
|
+
'message-reference': 'error',
|
66
|
+
'subscription': 'error',
|
67
|
+
'user-task-form': 'error'
|
59
68
|
}
|
60
69
|
}
|
61
70
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "bpmnlint-plugin-camunda-compat",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.9.1",
|
4
4
|
"description": "A bpmnlint plug-in for Camunda Platform compatibility",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -25,7 +25,6 @@
|
|
25
25
|
"devDependencies": {
|
26
26
|
"bpmn-moddle": "^7.1.2",
|
27
27
|
"bpmnlint": "^7.8.0",
|
28
|
-
"camunda-bpmn-moddle": "^6.1.1",
|
29
28
|
"chai": "^4.3.5",
|
30
29
|
"eslint": "^7.32.0",
|
31
30
|
"eslint-plugin-bpmn-io": "^0.13.0",
|
@@ -33,10 +32,10 @@
|
|
33
32
|
"modeler-moddle": "^0.1.0",
|
34
33
|
"sinon": "^13.0.1",
|
35
34
|
"sinon-chai": "^3.7.0",
|
36
|
-
"zeebe-bpmn-moddle": "^0.
|
35
|
+
"zeebe-bpmn-moddle": "^0.12.1"
|
37
36
|
},
|
38
37
|
"dependencies": {
|
39
|
-
"@
|
38
|
+
"@bpmn-io/moddle-utils": "^0.1.0",
|
40
39
|
"bpmnlint-utils": "^1.0.2",
|
41
40
|
"min-dash": "^3.8.0"
|
42
41
|
},
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
const { hasProperties } = require('./utils/element');
|
2
|
+
|
3
|
+
const { reportErrors } = require('./utils/reporter');
|
4
|
+
|
5
|
+
module.exports = function() {
|
6
|
+
function check(node, reporter) {
|
7
|
+
const errors = hasProperties(node, {
|
8
|
+
modelerTemplate: {
|
9
|
+
allowed: false
|
10
|
+
}
|
11
|
+
}, node);
|
12
|
+
|
13
|
+
if (errors && errors.length) {
|
14
|
+
reportErrors(node, reporter, errors);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
return {
|
19
|
+
check
|
20
|
+
};
|
21
|
+
};
|
File without changes
|
@@ -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
|
+
}
|
package/rules/utils/element.js
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
const {
|
2
2
|
isArray,
|
3
|
+
isDefined,
|
3
4
|
some
|
4
5
|
} = require('min-dash');
|
5
6
|
|
6
7
|
const { isAny } = require('bpmnlint-utils');
|
7
8
|
|
8
|
-
const { getPath } = require('@
|
9
|
+
const { getPath } = require('@bpmn-io/moddle-utils');
|
9
10
|
|
10
11
|
const { ERROR_TYPES } = require('./error-types');
|
11
12
|
|
@@ -39,6 +40,8 @@ function findExtensionElements(node, types) {
|
|
39
40
|
return values.filter(value => isAny(value, types));
|
40
41
|
}
|
41
42
|
|
43
|
+
module.exports.findExtensionElements = findExtensionElements;
|
44
|
+
|
42
45
|
function findExtensionElement(node, types) {
|
43
46
|
const extensionElements = findExtensionElements(node, types);
|
44
47
|
|
@@ -144,6 +147,24 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
|
|
144
147
|
];
|
145
148
|
}
|
146
149
|
|
150
|
+
if (propertyChecks.allowed === false && isDefined(propertyValue)) {
|
151
|
+
return [
|
152
|
+
...results,
|
153
|
+
{
|
154
|
+
message: `Property <${ propertyName }> not allowed`,
|
155
|
+
path: path
|
156
|
+
? [ ...path, propertyName ]
|
157
|
+
: [ propertyName ],
|
158
|
+
error: {
|
159
|
+
type: ERROR_TYPES.PROPERTY_NOT_ALLOWED,
|
160
|
+
node,
|
161
|
+
parentNode: parentNode == node ? null : parentNode,
|
162
|
+
property: propertyName
|
163
|
+
}
|
164
|
+
}
|
165
|
+
];
|
166
|
+
}
|
167
|
+
|
147
168
|
return results;
|
148
169
|
}, []);
|
149
170
|
};
|
@@ -3,6 +3,7 @@ module.exports.ERROR_TYPES = Object.freeze({
|
|
3
3
|
EXTENSION_ELEMENT_NOT_ALLOWED: 'extensionElementNotAllowed',
|
4
4
|
EXTENSION_ELEMENT_REQUIRED: 'extensionElementRequired',
|
5
5
|
PROPERTY_DEPENDEND_REQUIRED: 'propertyDependendRequired',
|
6
|
+
PROPERTY_NOT_ALLOWED: 'propertyNotAllowed',
|
6
7
|
PROPERTY_REQUIRED: 'propertyRequired',
|
7
8
|
PROPERTY_TYPE_NOT_ALLOWED: 'propertyTypeNotAllowed'
|
8
9
|
});
|
package/rules/utils/reporter.js
CHANGED
@@ -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;
|