bpmnlint-plugin-camunda-compat 0.17.0 → 0.19.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 +2 -2
- package/rules/element-type/config.js +4 -0
- package/rules/no-expression.js +155 -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
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "bpmnlint-plugin-camunda-compat",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.19.0",
|
4
4
|
"description": "A bpmnlint plug-in for Camunda Platform compatibility",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
7
|
"all": "npm run lint && npm test",
|
8
8
|
"dev": "npm run test:watch",
|
9
9
|
"lint": "eslint .",
|
10
|
-
"test": "mocha test/**/*.spec.js",
|
10
|
+
"test": "mocha 'test/**/*.spec.js'",
|
11
11
|
"test:watch": "npm run test -- --watch"
|
12
12
|
},
|
13
13
|
"repository": {
|
@@ -2,6 +2,7 @@ module.exports = {
|
|
2
2
|
'bpmn:Association': '1.0',
|
3
3
|
'bpmn:BoundaryEvent': {
|
4
4
|
'bpmn:ErrorEventDefinition': '1.0',
|
5
|
+
'bpmn:EscalationEventDefinition': '8.2',
|
5
6
|
'bpmn:MessageEventDefinition': '1.0',
|
6
7
|
'bpmn:TimerEventDefinition': '1.0'
|
7
8
|
},
|
@@ -15,6 +16,7 @@ module.exports = {
|
|
15
16
|
'bpmn:EndEvent': {
|
16
17
|
'_': '1.0',
|
17
18
|
'bpmn:ErrorEventDefinition': '1.0',
|
19
|
+
'bpmn:EscalationEventDefinition': '8.2',
|
18
20
|
'bpmn:MessageEventDefinition': '1.2',
|
19
21
|
'bpmn:TerminateEventDefinition': '8.1'
|
20
22
|
},
|
@@ -29,6 +31,7 @@ module.exports = {
|
|
29
31
|
},
|
30
32
|
'bpmn:IntermediateThrowEvent': {
|
31
33
|
'_': '1.1',
|
34
|
+
'bpmn:EscalationEventDefinition': '8.2',
|
32
35
|
'bpmn:MessageEventDefinition': '1.2',
|
33
36
|
'bpmn:LinkEventDefinition': '8.2'
|
34
37
|
},
|
@@ -45,6 +48,7 @@ module.exports = {
|
|
45
48
|
'bpmn:StartEvent': {
|
46
49
|
'_': '1.0',
|
47
50
|
'bpmn:ErrorEventDefinition': '1.0',
|
51
|
+
'bpmn:EscalationEventDefinition': '8.2',
|
48
52
|
'bpmn:MessageEventDefinition': '1.0',
|
49
53
|
'bpmn:TimerEventDefinition': '1.0'
|
50
54
|
},
|
@@ -0,0 +1,155 @@
|
|
1
|
+
const {
|
2
|
+
is
|
3
|
+
} = require('bpmnlint-utils');
|
4
|
+
|
5
|
+
const { getPath } = require('@bpmn-io/moddle-utils');
|
6
|
+
|
7
|
+
const {
|
8
|
+
ERROR_TYPES,
|
9
|
+
getEventDefinition
|
10
|
+
} = require('./utils/element');
|
11
|
+
|
12
|
+
const { reportErrors } = require('./utils/reporter');
|
13
|
+
|
14
|
+
const handlersMap = {
|
15
|
+
'1.0': [
|
16
|
+
checkErrorCode
|
17
|
+
],
|
18
|
+
'1.1': [
|
19
|
+
checkErrorCode
|
20
|
+
],
|
21
|
+
'1.2': [
|
22
|
+
checkErrorCode
|
23
|
+
],
|
24
|
+
'1.3': [
|
25
|
+
checkErrorCode
|
26
|
+
],
|
27
|
+
'8.0': [
|
28
|
+
checkErrorCode
|
29
|
+
],
|
30
|
+
'8.1': [
|
31
|
+
checkErrorCode
|
32
|
+
],
|
33
|
+
'8.2': [
|
34
|
+
checkErrorCatchEvent,
|
35
|
+
checkEscalationCatchEvent
|
36
|
+
]
|
37
|
+
};
|
38
|
+
|
39
|
+
module.exports = noExpressionRule;
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Make sure that certain properties do not contain expressions in older versions.
|
43
|
+
* @param {{ version: string }} config
|
44
|
+
*/
|
45
|
+
function noExpressionRule({ version }) {
|
46
|
+
function check(node, reporter) {
|
47
|
+
const errors = checkForVersion(node, version);
|
48
|
+
|
49
|
+
if (errors && errors.length) {
|
50
|
+
reportErrors(node, reporter, errors);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
return {
|
55
|
+
check
|
56
|
+
};
|
57
|
+
}
|
58
|
+
|
59
|
+
function checkForVersion(node, version) {
|
60
|
+
const handlers = handlersMap[version];
|
61
|
+
|
62
|
+
return handlers.reduce((errors, handler) => {
|
63
|
+
const handlerErrors = handler(node) || [];
|
64
|
+
return errors.concat(handlerErrors);
|
65
|
+
}, []);
|
66
|
+
}
|
67
|
+
|
68
|
+
function noExpression(node, propertyName, parentNode, allowedVersion) {
|
69
|
+
const propertyValue = node.get(propertyName);
|
70
|
+
const path = getPath(node, parentNode);
|
71
|
+
|
72
|
+
if (!isExpression(propertyValue)) {
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
|
76
|
+
const errorMessage = allowedVersion ?
|
77
|
+
`Expression statement <${truncate(propertyValue)}> only supported by Camunda Platform ${allowedVersion} or newer` :
|
78
|
+
`Expression statement <${truncate(propertyValue)}> not supported`;
|
79
|
+
|
80
|
+
return {
|
81
|
+
message: errorMessage,
|
82
|
+
path: path
|
83
|
+
? [ ...path, propertyName ]
|
84
|
+
: [ propertyName ],
|
85
|
+
data: {
|
86
|
+
type: ERROR_TYPES.EXPRESSION_NOT_ALLOWED,
|
87
|
+
node,
|
88
|
+
parentNode: parentNode == node ? null : parentNode,
|
89
|
+
property: propertyName,
|
90
|
+
allowedVersion
|
91
|
+
}
|
92
|
+
};
|
93
|
+
}
|
94
|
+
|
95
|
+
function isExpression(value) {
|
96
|
+
return value && value.startsWith('=');
|
97
|
+
}
|
98
|
+
|
99
|
+
function checkErrorCode(node) {
|
100
|
+
if (!is(node, 'bpmn:Event')) {
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
const eventDefinition = getEventDefinition(node);
|
105
|
+
|
106
|
+
if (!eventDefinition || !is(eventDefinition, 'bpmn:ErrorEventDefinition')) {
|
107
|
+
return;
|
108
|
+
}
|
109
|
+
|
110
|
+
const errorRef = eventDefinition.get('errorRef');
|
111
|
+
|
112
|
+
if (!errorRef) {
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
|
116
|
+
if (is(node, 'bpmn:CatchEvent')) {
|
117
|
+
return noExpression(errorRef, 'errorCode', node, null);
|
118
|
+
} else {
|
119
|
+
return noExpression(errorRef, 'errorCode', node, '8.2');
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
function checkErrorCatchEvent(node) {
|
124
|
+
if (!is(node, 'bpmn:CatchEvent')) {
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
|
128
|
+
return checkErrorCode(node);
|
129
|
+
}
|
130
|
+
|
131
|
+
function checkEscalationCatchEvent(node) {
|
132
|
+
if (!is(node, 'bpmn:CatchEvent')) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
|
136
|
+
const eventDefinition = getEventDefinition(node);
|
137
|
+
|
138
|
+
if (!eventDefinition || !is(eventDefinition, 'bpmn:EscalationEventDefinition')) {
|
139
|
+
return;
|
140
|
+
}
|
141
|
+
|
142
|
+
const escalationRef = eventDefinition.get('escalationRef');
|
143
|
+
|
144
|
+
if (!escalationRef) {
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
|
148
|
+
return noExpression(escalationRef, 'escalationCode', node, null);
|
149
|
+
}
|
150
|
+
|
151
|
+
function truncate(string, maxLength = 10) {
|
152
|
+
const stringified = `${ string }`;
|
153
|
+
|
154
|
+
return stringified.length > maxLength ? `${ stringified.slice(0, maxLength) }...` : stringified;
|
155
|
+
}
|
@@ -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',
|