bpmnlint-plugin-camunda-compat 0.17.0 → 0.18.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/README.md +15 -7
- package/index.js +7 -0
- package/package.json +1 -1
- package/rules/no-expression.js +117 -0
- package/rules/utils/error-types.js +1 -0
package/README.md
CHANGED
@@ -2,28 +2,36 @@
|
|
2
2
|
|
3
3
|
[](https://github.com/camunda/bpmnlint-plugin-camunda-compat/actions?query=workflow%3ACI)
|
4
4
|
|
5
|
-
|
5
|
+
A [bpmnlint](https://github.com/bpmn-io/bpmnlint) plug-in that checks whether a given BPMN process can be executed with [Camunda](https://camunda.com/).
|
6
6
|
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
|
10
|
-
|
10
|
+
Add configuration corresponding to your execution platform and version to your [`.bpmnlintrc` configuration](https://github.com/bpmn-io/bpmnlint#configuration):
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
```
|
12
|
+
```json
|
15
13
|
{
|
16
14
|
"extends": [
|
17
15
|
"bpmnlint:recommended",
|
18
16
|
"plugin:camunda-compat/camunda-cloud-8-0"
|
19
|
-
]
|
17
|
+
],
|
18
|
+
"rules": {
|
19
|
+
"camunda-compat/timer": "off"
|
20
|
+
}
|
20
21
|
}
|
21
22
|
```
|
22
23
|
|
24
|
+
Use [`@camunda/linting`](https://github.com/camunda/linting) to configure the linter dynamically based on the [execution platform and version](https://github.com/camunda/modeler-moddle).
|
25
|
+
|
26
|
+
|
23
27
|
## Resources
|
24
28
|
|
25
29
|
* [Issues](https://github.com/camunda/bpmnlint-plugin-camunda-compat/issues)
|
26
|
-
|
30
|
+
|
31
|
+
|
32
|
+
## Related
|
33
|
+
|
34
|
+
* BPMN coverage for [Camunda 8](https://docs.camunda.io/docs/reference/bpmn-processes/bpmn-coverage/) and [Camunda 7](https://docs.camunda.org/manual/latest/reference/bpmn20/)
|
27
35
|
|
28
36
|
|
29
37
|
## License
|
package/index.js
CHANGED
@@ -10,6 +10,7 @@ const camundaCloud10Rules = {
|
|
10
10
|
'executable-process': 'error',
|
11
11
|
'loop-characteristics': 'error',
|
12
12
|
'message-reference': 'error',
|
13
|
+
'no-expression': [ 'error', { version: '1.0' } ],
|
13
14
|
'no-template': 'error',
|
14
15
|
'no-zeebe-properties': 'error',
|
15
16
|
'sequence-flow-condition': 'error',
|
@@ -23,6 +24,7 @@ const camundaCloud11Rules = {
|
|
23
24
|
...camundaCloud10Rules,
|
24
25
|
'implementation': [ 'error', { version: '1.1' } ],
|
25
26
|
'element-type': [ 'error', { version: '1.1' } ],
|
27
|
+
'no-expression': [ 'error', { version: '1.1' } ],
|
26
28
|
'timer': [ 'error', { version: '1.1' } ]
|
27
29
|
};
|
28
30
|
|
@@ -30,6 +32,7 @@ const camundaCloud12Rules = {
|
|
30
32
|
...camundaCloud11Rules,
|
31
33
|
'implementation': [ 'error', { version: '1.2' } ],
|
32
34
|
'element-type': [ 'error', { version: '1.2' } ],
|
35
|
+
'no-expression': [ 'error', { version: '1.2' } ],
|
33
36
|
'timer': [ 'error', { version: '1.2' } ]
|
34
37
|
};
|
35
38
|
|
@@ -37,6 +40,7 @@ const camundaCloud13Rules = {
|
|
37
40
|
...camundaCloud12Rules,
|
38
41
|
'implementation': [ 'error', { version: '1.3' } ],
|
39
42
|
'element-type': [ 'error', { version: '1.3' } ],
|
43
|
+
'no-expression': [ 'error', { version: '1.3' } ],
|
40
44
|
'timer': [ 'error', { version: '1.3' } ]
|
41
45
|
};
|
42
46
|
|
@@ -44,6 +48,7 @@ const camundaCloud80Rules = {
|
|
44
48
|
...omit(camundaCloud13Rules, 'no-template'),
|
45
49
|
'implementation': [ 'error', { version: '8.0' } ],
|
46
50
|
'element-type': [ 'error', { version: '8.0' } ],
|
51
|
+
'no-expression': [ 'error', { version: '8.0' } ],
|
47
52
|
'timer': [ 'error', { version: '8.0' } ]
|
48
53
|
};
|
49
54
|
|
@@ -52,6 +57,7 @@ const camundaCloud81Rules = {
|
|
52
57
|
'implementation': [ 'error', { version: '8.1' } ],
|
53
58
|
'element-type': [ 'error', { version: '8.1' } ],
|
54
59
|
'inclusive-gateway': 'error',
|
60
|
+
'no-expression': [ 'error', { version: '8.1' } ],
|
55
61
|
'timer': [ 'error', { version: '8.1' } ]
|
56
62
|
};
|
57
63
|
|
@@ -59,6 +65,7 @@ const camundaCloud82Rules = {
|
|
59
65
|
...camundaCloud81Rules,
|
60
66
|
'implementation': [ 'error', { version: '8.2' } ],
|
61
67
|
'element-type': [ 'error', { version: '8.2' } ],
|
68
|
+
'no-expression': [ 'error', { version: '8.2' } ],
|
62
69
|
'timer': [ 'error', { version: '8.2' } ]
|
63
70
|
};
|
64
71
|
|
package/package.json
CHANGED
@@ -0,0 +1,117 @@
|
|
1
|
+
const {
|
2
|
+
is,
|
3
|
+
isAny
|
4
|
+
} = require('bpmnlint-utils');
|
5
|
+
|
6
|
+
const { getPath } = require('@bpmn-io/moddle-utils');
|
7
|
+
|
8
|
+
const {
|
9
|
+
ERROR_TYPES,
|
10
|
+
getEventDefinition
|
11
|
+
} = require('./utils/element');
|
12
|
+
|
13
|
+
const { reportErrors } = require('./utils/reporter');
|
14
|
+
|
15
|
+
const handlersMap = {
|
16
|
+
'1.0': [
|
17
|
+
checkErrorCode
|
18
|
+
],
|
19
|
+
'1.1': [
|
20
|
+
checkErrorCode
|
21
|
+
],
|
22
|
+
'1.2': [
|
23
|
+
checkErrorCode
|
24
|
+
],
|
25
|
+
'1.3': [
|
26
|
+
checkErrorCode
|
27
|
+
],
|
28
|
+
'8.0': [
|
29
|
+
checkErrorCode
|
30
|
+
],
|
31
|
+
'8.1': [
|
32
|
+
checkErrorCode
|
33
|
+
],
|
34
|
+
'8.2': []
|
35
|
+
};
|
36
|
+
|
37
|
+
module.exports = noExpressionRule;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Make sure that certain properties do not contain expressions in older versions.
|
41
|
+
* @param {{ version: string }} config
|
42
|
+
*/
|
43
|
+
function noExpressionRule({ version }) {
|
44
|
+
function check(node, reporter) {
|
45
|
+
const errors = checkForVersion(node, version);
|
46
|
+
|
47
|
+
if (errors && errors.length) {
|
48
|
+
reportErrors(node, reporter, errors);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
return {
|
53
|
+
check
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
function checkForVersion(node, version) {
|
58
|
+
const handlers = handlersMap[version];
|
59
|
+
|
60
|
+
return handlers.reduce((errors, handler) => {
|
61
|
+
const handlerErrors = handler(node, version) || [];
|
62
|
+
return errors.concat(handlerErrors);
|
63
|
+
}, []);
|
64
|
+
}
|
65
|
+
|
66
|
+
function noExpression(node, propertyName, parentNode, allowedVersion) {
|
67
|
+
const propertyValue = node.get(propertyName);
|
68
|
+
const path = getPath(node, parentNode);
|
69
|
+
|
70
|
+
if (!isExpression(propertyValue)) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
|
74
|
+
return {
|
75
|
+
message: `Expression statement <${truncate(propertyValue)}> only supported by Camunda Platform 8.2 or newer`,
|
76
|
+
path: path
|
77
|
+
? [ ...path, propertyName ]
|
78
|
+
: [ propertyName ],
|
79
|
+
data: {
|
80
|
+
type: ERROR_TYPES.EXPRESSION_NOT_ALLOWED,
|
81
|
+
node,
|
82
|
+
parentNode: parentNode == node ? null : parentNode,
|
83
|
+
property: propertyName,
|
84
|
+
allowedVersion
|
85
|
+
}
|
86
|
+
};
|
87
|
+
}
|
88
|
+
|
89
|
+
function isExpression(value) {
|
90
|
+
return value && value.startsWith('=');
|
91
|
+
}
|
92
|
+
|
93
|
+
function checkErrorCode(node) {
|
94
|
+
if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
|
98
|
+
const eventDefinition = getEventDefinition(node);
|
99
|
+
|
100
|
+
if (!eventDefinition || !is(eventDefinition, 'bpmn:ErrorEventDefinition')) {
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
const errorRef = eventDefinition.get('errorRef');
|
105
|
+
|
106
|
+
if (!errorRef) {
|
107
|
+
return;
|
108
|
+
}
|
109
|
+
|
110
|
+
return errorRef && noExpression(errorRef, 'errorCode', node, '8.2');
|
111
|
+
}
|
112
|
+
|
113
|
+
function truncate(string, maxLength = 10) {
|
114
|
+
const stringified = `${ string }`;
|
115
|
+
|
116
|
+
return stringified.length > maxLength ? `${ stringified.slice(0, maxLength) }...` : stringified;
|
117
|
+
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module.exports.ERROR_TYPES = Object.freeze({
|
2
2
|
ELEMENT_COLLAPSED_NOT_ALLOWED: 'camunda.elementCollapsedNotAllowed',
|
3
3
|
ELEMENT_TYPE_NOT_ALLOWED: 'camunda.elementTypeNotAllowed',
|
4
|
+
EXPRESSION_NOT_ALLOWED: 'camunda.expressionNotAllowed',
|
4
5
|
EXPRESSION_REQUIRED: 'camunda.expressionRequired',
|
5
6
|
EXPRESSION_VALUE_NOT_ALLOWED: 'camunda.expressionValueNotAllowed',
|
6
7
|
EXTENSION_ELEMENT_NOT_ALLOWED: 'camunda.extensionElementNotAllowed',
|