bpmnlint-plugin-camunda-compat 0.10.0 → 0.11.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/index.js CHANGED
@@ -1,76 +1,62 @@
1
+ const { omit } = require('min-dash');
2
+
1
3
  const calledDecisionOrTaskDefinitionConfig = require('./rules/called-decision-or-task-definition/config'),
2
4
  elementTypeConfig = require('./rules/element-type/config');
3
5
 
6
+ const camundaCloud10Rules = {
7
+ 'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud10 ],
8
+ 'called-element': 'error',
9
+ 'duplicate-task-headers': 'error',
10
+ 'element-type': [ 'error', elementTypeConfig.camundaCloud10 ],
11
+ 'error-reference': 'error',
12
+ 'loop-characteristics': 'error',
13
+ 'message-reference': 'error',
14
+ 'no-template': 'error',
15
+ 'no-zeebe-properties': 'error',
16
+ 'subscription': 'error',
17
+ 'user-task-form': 'error'
18
+ };
19
+
20
+ const camundaCloud11Rules = {
21
+ ...camundaCloud10Rules,
22
+ 'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud11 ],
23
+ 'element-type': [ 'error', elementTypeConfig.camundaCloud11 ]
24
+ };
25
+
26
+ const camundaCloud12Rules = {
27
+ ...camundaCloud11Rules,
28
+ 'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud12 ],
29
+ 'element-type': [ 'error', elementTypeConfig.camundaCloud12 ]
30
+ };
31
+
32
+ const camundaCloud13Rules = {
33
+ ...camundaCloud12Rules,
34
+ 'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud13 ]
35
+ };
36
+
37
+ const camundaCloud80Rules = omit(camundaCloud13Rules, 'no-template');
38
+
39
+ const camundaCloud81Rules = omit(camundaCloud13Rules, 'no-zeebe-properties');
40
+
4
41
  module.exports = {
5
42
  configs: {
6
43
  'camunda-cloud-1-0': {
7
- rules: {
8
- 'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud10 ],
9
- 'called-element': 'error',
10
- 'duplicate-task-headers': 'error',
11
- 'element-type': [ 'error', elementTypeConfig.camundaCloud10 ],
12
- 'error-reference': 'error',
13
- 'loop-characteristics': 'error',
14
- 'message-reference': 'error',
15
- 'no-template': 'error',
16
- 'subscription': 'error',
17
- 'user-task-form': 'error'
18
- }
44
+ rules: camundaCloud10Rules
19
45
  },
20
46
  'camunda-cloud-1-1': {
21
- rules: {
22
- 'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud11 ],
23
- 'called-element': 'error',
24
- 'duplicate-task-headers': 'error',
25
- 'element-type': [ 'error', elementTypeConfig.camundaCloud11 ],
26
- 'error-reference': 'error',
27
- 'loop-characteristics': 'error',
28
- 'message-reference': 'error',
29
- 'no-template': 'error',
30
- 'subscription': 'error',
31
- 'user-task-form': 'error'
32
- }
47
+ rules: camundaCloud11Rules
33
48
  },
34
49
  'camunda-cloud-1-2': {
35
- rules: {
36
- 'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud12 ],
37
- 'called-element': 'error',
38
- 'duplicate-task-headers': 'error',
39
- 'element-type': [ 'error', elementTypeConfig.camundaCloud12 ],
40
- 'error-reference': 'error',
41
- 'loop-characteristics': 'error',
42
- 'message-reference': 'error',
43
- 'no-template': 'error',
44
- 'subscription': 'error',
45
- 'user-task-form': 'error'
46
- }
50
+ rules: camundaCloud12Rules
47
51
  },
48
52
  'camunda-cloud-1-3': {
49
- rules: {
50
- 'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud13 ],
51
- 'called-element': 'error',
52
- 'duplicate-task-headers': 'error',
53
- 'element-type': [ 'error', elementTypeConfig.camundaCloud12 ],
54
- 'error-reference': 'error',
55
- 'loop-characteristics': 'error',
56
- 'message-reference': 'error',
57
- 'no-template': 'error',
58
- 'subscription': 'error',
59
- 'user-task-form': 'error'
60
- }
53
+ rules: camundaCloud13Rules
61
54
  },
62
55
  'camunda-cloud-8-0': {
63
- rules: {
64
- 'called-decision-or-task-definition': [ 'error', calledDecisionOrTaskDefinitionConfig.camundaCloud13 ],
65
- 'called-element': 'error',
66
- 'duplicate-task-headers': 'error',
67
- 'element-type': [ 'error', elementTypeConfig.camundaCloud12 ],
68
- 'error-reference': 'error',
69
- 'loop-characteristics': 'error',
70
- 'message-reference': 'error',
71
- 'subscription': 'error',
72
- 'user-task-form': 'error'
73
- }
56
+ rules: camundaCloud80Rules
57
+ },
58
+ 'camunda-cloud-8-1': {
59
+ rules: camundaCloud81Rules
74
60
  }
75
61
  }
76
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,21 +23,21 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "bpmn-moddle": "^7.1.2",
26
+ "bpmn-moddle": "^7.1.3",
27
27
  "bpmnlint": "^7.8.0",
28
- "chai": "^4.3.5",
29
- "eslint": "^7.32.0",
30
- "eslint-plugin-bpmn-io": "^0.13.0",
31
- "mocha": "^5.2.0",
28
+ "chai": "^4.3.6",
29
+ "eslint": "^8.23.0",
30
+ "eslint-plugin-bpmn-io": "^0.14.1",
31
+ "mocha": "^10.0.0",
32
32
  "modeler-moddle": "^0.1.0",
33
- "sinon": "^13.0.1",
33
+ "sinon": "^14.0.0",
34
34
  "sinon-chai": "^3.7.0",
35
- "zeebe-bpmn-moddle": "^0.12.1"
35
+ "zeebe-bpmn-moddle": "^0.14.0"
36
36
  },
37
37
  "dependencies": {
38
38
  "@bpmn-io/moddle-utils": "^0.1.0",
39
39
  "bpmnlint-utils": "^1.0.2",
40
- "min-dash": "^3.8.0"
40
+ "min-dash": "^3.8.1"
41
41
  },
42
42
  "files": [
43
43
  "rules",
@@ -8,9 +8,8 @@ const { getPath } = require('@bpmn-io/moddle-utils');
8
8
  const {
9
9
  findExtensionElement,
10
10
  getEventDefinition,
11
- hasProperties,
12
- hasExtensionElementOfType,
13
- hasExtensionElementsOfTypes
11
+ hasExtensionElement,
12
+ hasProperties
14
13
  } = require('../utils/element');
15
14
 
16
15
  const { reportErrors } = require('../utils/reporter');
@@ -99,14 +98,14 @@ module.exports = function(config) {
99
98
  }
100
99
 
101
100
  if (isAny(node, elementsCalledDecision) && isAny(node, elementsTaskDefinition)) {
102
- errors = hasExtensionElementsOfTypes(node, [
101
+ errors = hasExtensionElement(node, [
103
102
  'zeebe:CalledDecision',
104
103
  'zeebe:TaskDefinition'
105
- ], node, true);
104
+ ], node);
106
105
  } else if (isAny(node, elementsCalledDecision)) {
107
- errors = hasExtensionElementOfType(node, 'zeebe:CalledDecision', node);
106
+ errors = hasExtensionElement(node, 'zeebe:CalledDecision', node);
108
107
  } else {
109
- errors = hasExtensionElementOfType(node, 'zeebe:TaskDefinition', node);
108
+ errors = hasExtensionElement(node, 'zeebe:TaskDefinition', node);
110
109
  }
111
110
 
112
111
  if (errors && errors.length) {
@@ -2,7 +2,7 @@ const { is } = require('bpmnlint-utils');
2
2
 
3
3
  const {
4
4
  findExtensionElement,
5
- hasExtensionElementOfType,
5
+ hasExtensionElement,
6
6
  hasProperties
7
7
  } = require('./utils/element');
8
8
 
@@ -14,7 +14,7 @@ module.exports = function() {
14
14
  return;
15
15
  }
16
16
 
17
- let errors = hasExtensionElementOfType(node, 'zeebe:CalledElement', node);
17
+ let errors = hasExtensionElement(node, 'zeebe:CalledElement', node);
18
18
 
19
19
  if (errors && errors.length) {
20
20
  reportErrors(node, reporter, errors);
@@ -3,7 +3,7 @@ const { is } = require('bpmnlint-utils');
3
3
  const {
4
4
  findExtensionElement,
5
5
  hasProperties,
6
- hasExtensionElementOfType
6
+ hasExtensionElement
7
7
  } = require('./utils/element');
8
8
 
9
9
  const { reportErrors } = require('./utils/reporter');
@@ -32,7 +32,7 @@ module.exports = function() {
32
32
  return;
33
33
  }
34
34
 
35
- errors = hasExtensionElementOfType(loopCharacteristics, 'zeebe:LoopCharacteristics', node);
35
+ errors = hasExtensionElement(loopCharacteristics, 'zeebe:LoopCharacteristics', node);
36
36
 
37
37
  if (errors && errors.length) {
38
38
  reportErrors(node, reporter, errors);
@@ -0,0 +1,23 @@
1
+ const { is } = require('bpmnlint-utils');
2
+
3
+ const { hasNoExtensionElement } = require('./utils/element');
4
+
5
+ const { reportErrors } = require('./utils/reporter');
6
+
7
+ module.exports = function() {
8
+ function check(node, reporter) {
9
+ if (!is(node, 'zeebe:PropertiesHolder')) {
10
+ return;
11
+ }
12
+
13
+ const errors = hasNoExtensionElement(node, 'zeebe:Properties', node);
14
+
15
+ if (errors && errors.length) {
16
+ reportErrors(node, reporter, errors);
17
+ }
18
+ }
19
+
20
+ return {
21
+ check
22
+ };
23
+ };
@@ -6,7 +6,7 @@ const {
6
6
  const {
7
7
  findExtensionElement,
8
8
  getEventDefinition,
9
- hasExtensionElementOfType,
9
+ hasExtensionElement,
10
10
  hasProperties
11
11
  } = require('./utils/element');
12
12
 
@@ -37,7 +37,7 @@ module.exports = function() {
37
37
  return;
38
38
  }
39
39
 
40
- let errors = hasExtensionElementOfType(messageRef, 'zeebe:Subscription', node);
40
+ let errors = hasExtensionElement(messageRef, 'zeebe:Subscription', node);
41
41
 
42
42
  if (errors && errors.length) {
43
43
  reportErrors(node, reporter, errors);
@@ -190,7 +190,7 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
190
190
  return [
191
191
  ...results,
192
192
  {
193
- message: `Property <${ propertyName }> of type <${ propertyValue.$type }> not allowed`,
193
+ message: `Element of type <${ node.$type }> must not have property <${ propertyName }> of type <${ propertyValue.$type }>`,
194
194
  path: path
195
195
  ? [ ...path, propertyName ]
196
196
  : [ propertyName ],
@@ -209,7 +209,7 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
209
209
  return [
210
210
  ...results,
211
211
  {
212
- message: `Property <${ propertyName }> not allowed`,
212
+ message: `Element of type <${ node.$type }> must not have property <${ propertyName }>`,
213
213
  path: path
214
214
  ? [ ...path, propertyName ]
215
215
  : [ propertyName ],
@@ -227,38 +227,21 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
227
227
  }, []);
228
228
  };
229
229
 
230
- module.exports.hasExtensionElementsOfTypes = function(node, types, parentNode = null, exclusive = false) {
231
- const extensionElements = findExtensionElements(node, types);
230
+ module.exports.hasExtensionElement = function(node, types, parentNode = null) {
231
+ const typesArray = isArray(types) ? types : [ types ];
232
232
 
233
- if (!extensionElements || !extensionElements.length) {
234
- return [
235
- {
236
- message: exclusive
237
- ? `Element of type <${ node.$type }> must have one extension element of type ${ formatTypes(types, true) }`
238
- : `Element of type <${ node.$type }> must have one or many extension elements of type ${ formatTypes(types, true) }`,
239
- path: getPath(node, parentNode),
240
- error: {
241
- type: ERROR_TYPES.EXTENSION_ELEMENT_REQUIRED,
242
- node,
243
- parentNode: parentNode == node ? null : parentNode,
244
- requiredExtensionElement: types,
245
- exclusive
246
- }
247
- }
248
- ];
249
- }
233
+ const extensionElements = findExtensionElements(node, typesArray);
250
234
 
251
- if (exclusive && extensionElements.length > 1) {
235
+ if (!extensionElements || extensionElements.length !== 1) {
252
236
  return [
253
237
  {
254
- message: `Element of type <${ node.$type }> must have one extension element of type ${ formatTypes(types, true) }`,
238
+ message: `Element of type <${ node.$type }> must have one extension element of type ${ formatTypes(typesArray, true) }`,
255
239
  path: getPath(node, parentNode),
256
240
  error: {
257
241
  type: ERROR_TYPES.EXTENSION_ELEMENT_REQUIRED,
258
242
  node,
259
243
  parentNode: parentNode == node ? null : parentNode,
260
- requiredExtensionElement: types,
261
- exclusive
244
+ requiredExtensionElement: types
262
245
  }
263
246
  }
264
247
  ];
@@ -267,19 +250,19 @@ module.exports.hasExtensionElementsOfTypes = function(node, types, parentNode =
267
250
  return [];
268
251
  };
269
252
 
270
- module.exports.hasExtensionElementOfType = function(node, type, parentNode = null) {
253
+ module.exports.hasNoExtensionElement = function(node, type, parentNode = null) {
271
254
  const extensionElement = findExtensionElement(node, type);
272
255
 
273
- if (!extensionElement) {
256
+ if (extensionElement) {
274
257
  return [
275
258
  {
276
- message: `Element of type <${ node.$type }> must have extension element of type <${ type }>`,
277
- path: getPath(node, parentNode),
259
+ message: `Element of type <${ node.$type }> must not have extension element of type <${ type }>`,
260
+ path: getPath(extensionElement, parentNode),
278
261
  error: {
279
- type: ERROR_TYPES.EXTENSION_ELEMENT_REQUIRED,
262
+ type: ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED,
280
263
  node,
281
264
  parentNode: parentNode == node ? null : parentNode,
282
- requiredExtensionElement: type
265
+ extensionElement
283
266
  }
284
267
  }
285
268
  ];
package/CHANGELOG.md DELETED
@@ -1,92 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to [bpmnlint-plugin-camunda-compat](https://github.com/camunda/bpmnlint-plugin-camunda-compat) are documented here. We use [semantic versioning](http://semver.org/) for releases.
4
-
5
- ## Unreleased
6
-
7
- ___Note:__ Yet to be released changes appear here._
8
-
9
- ## 0.10.0
10
-
11
- * `FEAT`: add duplicate task headers rule ([#41](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/41))
12
-
13
-
14
- ## 0.9.2
15
-
16
- * `FIX`: ignore null properties ([#39](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/39))
17
-
18
- ## 0.9.1
19
-
20
- * `FIX`: add name to reports ([#38](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/38))
21
-
22
- ## 0.9.0
23
-
24
- * `FEAT`: add user task forms rule ([#32](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/32))
25
-
26
- ## 0.8.0
27
-
28
- * `FEAT`: add templates rule ([#31](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/31))
29
-
30
- ## 0.7.1
31
-
32
- * `FIX`: lint subscription only if start event child of sub process ([#34](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/34))
33
-
34
- ## 0.7.0
35
-
36
- * `FEAT`: refactor plugin structure ([#29](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/29))
37
- * `DEPS`: update to `bpmnlint@7.8.0` ([#29](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/29))
38
-
39
- ### Breaking Changes
40
-
41
- * configuration not selected based on execution platform and version anymore, either configure manually or use [`@camunda/linting`](https://github.com/camunda/linting)
42
- * error message not adjusted to be shown in Camunda Modeler anymore
43
- * error type ELEMENT_TYPE changed to ELEMENT_TYPE_NOT_ALLOWED
44
- * error type PROPERTY_TYPE changed to PROPERTY_TYPE_NOT_ALLOWED
45
- * error data changed (cf. docs/ERRORS.md)
46
-
47
- ## 0.6.2
48
-
49
- * `FIX`: fix error message formatting ([#27](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/27))
50
-
51
- ## 0.6.1
52
-
53
- * `FIX`: lanes supported ([#26](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/26))
54
-
55
- ## 0.6.0
56
-
57
- * `FEAT`: adjust error messages to be more friendly ([#22](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/22))
58
- * `FEAT`: lint error code and message name ([#21](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/21))
59
- * `FIX`: task definition retries not required ([#20](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/20))
60
-
61
- ## 0.5.0
62
-
63
- * `FEAT`: update Camunda Cloud rules to lint extension elements and their properties ([#18](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/18))
64
-
65
- ## 0.4.0
66
-
67
- * `CHORE`: rename `Cloud` `1.4` to `8.0` ([#14](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/14))
68
- * `CHORE`: rename `Cloud` to `Platform`/`Zeebe` ([#15](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/15))
69
-
70
- ## 0.3.0
71
-
72
- * `FEAT`: support multiInstance for subprocesses with cloud 1.0 ([#6](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/6))
73
- * `FEAT`: add Camunda Platform rules ([#5](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/5))
74
- * `FEAT`: add Camunda Cloud 1.4 rule ([#5](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/5))
75
- * `TEST`: add Cloud 1.1, 1.2, 1.3 integration tests ([#4](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/4))
76
- * `TEST`: verify exported configs ([#5](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/5))
77
- * `DEPS`: fix security audit warnings ([#6](https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/6))
78
- * `DOCS`: update link to documentation
79
- * `DOCS`: link Camunda Cloud and Platform BPMN coverage
80
-
81
- ## 0.2.0
82
-
83
- * `FEAT`: early return if execution platform does not match
84
- * `FIX`: correct check for `bpmn:BaseElement`
85
-
86
- ## 0.1.1
87
-
88
- * `FEAT`: initial support for Camunda Cloud 1.0, 1.1, 1.2, and 1.3
89
-
90
- ## ...
91
-
92
- Check `git log` for earlier history.