bpmnlint 9.2.0 → 10.1.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/config/all.js CHANGED
@@ -9,8 +9,8 @@ const allRules = [
9
9
  'no-disconnected',
10
10
  'no-duplicate-sequence-flows',
11
11
  'no-gateway-join-fork',
12
- 'no-implicit-split',
13
12
  'no-implicit-end',
13
+ 'no-implicit-split',
14
14
  'no-implicit-start',
15
15
  'no-inclusive-gateway',
16
16
  'no-overlapping-elements',
@@ -18,7 +18,8 @@ const allRules = [
18
18
  'single-event-definition',
19
19
  'start-event-required',
20
20
  'sub-process-blank-start-event',
21
- 'superfluous-gateway'
21
+ 'superfluous-gateway',
22
+ 'superfluous-termination'
22
23
  ];
23
24
 
24
25
 
@@ -19,6 +19,7 @@ module.exports = {
19
19
  'single-event-definition': 'error',
20
20
  'start-event-required': 'error',
21
21
  'sub-process-blank-start-event': 'error',
22
- 'superfluous-gateway': 'warn'
22
+ 'superfluous-gateway': 'warn',
23
+ 'superfluous-termination': 'warn'
23
24
  }
24
25
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bpmnlint",
3
3
  "description": "Validate your BPMN diagrams based on configurable lint rules",
4
- "version": "9.2.0",
4
+ "version": "10.1.0",
5
5
  "main": "lib/index.js",
6
6
  "keywords": [
7
7
  "bpmnlint",
@@ -23,14 +23,14 @@
23
23
  }
24
24
  ],
25
25
  "engines": {
26
- "node": ">= 12"
26
+ "node": ">= 16"
27
27
  },
28
28
  "license": "MIT",
29
29
  "scripts": {
30
30
  "all": "run-s lint test-coverage",
31
31
  "lint": "eslint .",
32
32
  "dev": "npm test -- --watch",
33
- "test": "mocha -r esm --exclude 'test/integration/*/**' 'test/**/*.js'",
33
+ "test": "mocha --exclude 'test/integration/*/**' 'test/**/*.*js'",
34
34
  "test-coverage": "nyc --reporter=lcov --reporter=html npm test",
35
35
  "generate-docs-images": "npx @bpmn-io/bpmnlint-generate-docs-images ."
36
36
  },
@@ -38,7 +38,7 @@
38
38
  "bpmnlint": "./bin/bpmnlint.js"
39
39
  },
40
40
  "dependencies": {
41
- "@bpmn-io/moddle-utils": "^0.2.0",
41
+ "@bpmn-io/moddle-utils": "^0.2.1",
42
42
  "ansi-colors": "^4.1.3",
43
43
  "bpmn-moddle": "^8.0.1",
44
44
  "bpmnlint-utils": "^1.1.1",
@@ -51,13 +51,13 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@bpmn-io/bpmnlint-generate-docs-images": "^0.4.0",
54
- "chai": "^4.3.7",
55
- "eslint": "^8.44.0",
54
+ "bpmnlint": ".",
55
+ "chai": "^4.3.8",
56
+ "eslint": "^8.49.0",
56
57
  "eslint-plugin-bpmn-io": "^1.0.0",
57
- "esm": "^3.2.25",
58
- "execa": "^5.1.1",
58
+ "execa": "^8.0.1",
59
59
  "install-local": "^3.0.1",
60
- "mocha": "^8.4.0",
60
+ "mocha": "^10.2.0",
61
61
  "npm-run-all": "^4.1.5",
62
62
  "nyc": "^15.1.0",
63
63
  "strip-indent": "^3.0.0"
@@ -14,7 +14,7 @@ module.exports = function() {
14
14
  function check(node, reporter) {
15
15
 
16
16
  if (!isAny(node, [
17
- 'bpmn:Task',
17
+ 'bpmn:Activity',
18
18
  'bpmn:Event'
19
19
  ])) {
20
20
  return;
@@ -15,7 +15,7 @@ module.exports = function() {
15
15
  function check(node, reporter) {
16
16
 
17
17
  if (!isAny(node, [
18
- 'bpmn:Task',
18
+ 'bpmn:Activity',
19
19
  'bpmn:Event'
20
20
  ])) {
21
21
  return;
@@ -0,0 +1,63 @@
1
+ const {
2
+ is, isAny
3
+ } = require('bpmnlint-utils');
4
+
5
+ /**
6
+ * A rule that checks, whether a gateway has only one source and target.
7
+ *
8
+ * Those gateways are superfluous since they don't do anything.
9
+ */
10
+ module.exports = function() {
11
+
12
+ function check(node, reporter) {
13
+
14
+ if (!isAny(node, [ 'bpmn:Process', 'bpmn:SubProcess' ])) {
15
+ return;
16
+ }
17
+
18
+ const flowElements = node.flowElements || [];
19
+
20
+ const ends = flowElements.filter(
21
+ element => is(element, 'bpmn:FlowNode') && (element.outgoing || []).length === 0
22
+ );
23
+
24
+ const terminateEnds = ends.filter(isTerminateEnd);
25
+
26
+ if (terminateEnds.length !== 1) {
27
+
28
+ // TODO(nikku): only detect basic cases, do not
29
+ // do any kinds of elaborate flow analysis
30
+ return;
31
+ }
32
+
33
+ const superfluous = ends.every(
34
+ (end) => isInterruptingEventSub(end) || isTerminateEnd(end)
35
+ );
36
+
37
+ if (superfluous) {
38
+
39
+ for (const node of terminateEnds) {
40
+ reporter.report(node.id, 'Termination is superfluous.');
41
+ }
42
+ }
43
+ }
44
+
45
+ return {
46
+ check
47
+ };
48
+
49
+ };
50
+
51
+ function isTerminateEnd(element) {
52
+ return is(element, 'bpmn:EndEvent') && (element.eventDefinitions || []).some(
53
+ eventDefinition => is(eventDefinition, 'bpmn:TerminateEventDefinition')
54
+ );
55
+ }
56
+
57
+ function isInterruptingEventSub(element) {
58
+ const isEventSub = is(element, 'bpmn:SubProcess') && element.triggeredByEvent;
59
+
60
+ return isEventSub && (element.flowElements || []).some(
61
+ element => is(element, 'bpmn:StartEvent') && element.isInterrupting
62
+ );
63
+ }