bpmnlint-plugin-camunda-compat 0.19.0 → 0.21.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,73 +1,45 @@
1
1
  const { omit } = require('min-dash');
2
2
 
3
- const camundaCloud10Rules = {
4
- 'implementation': [ 'error', { version: '1.0' } ],
3
+ const camundaCloud10Rules = withConfig({
4
+ 'implementation': 'error',
5
5
  'called-element': 'error',
6
6
  'collapsed-subprocess': 'error',
7
7
  'duplicate-task-headers': 'error',
8
- 'element-type': [ 'error', { version: '1.0' } ],
8
+ 'element-type': 'error',
9
9
  'error-reference': 'error',
10
10
  'executable-process': 'error',
11
11
  'loop-characteristics': 'error',
12
12
  'message-reference': 'error',
13
- 'no-expression': [ 'error', { version: '1.0' } ],
13
+ 'no-candidate-users': 'error',
14
+ 'no-expression': 'error',
14
15
  'no-template': 'error',
15
16
  'no-zeebe-properties': 'error',
16
17
  'sequence-flow-condition': 'error',
17
18
  'subscription': 'error',
18
- 'timer': [ 'error', { version: '1.0' } ],
19
+ 'timer': 'error',
19
20
  'user-task-form': 'error',
20
21
  'feel': 'error'
21
- };
22
+ }, { version: '1.0' });
22
23
 
23
- const camundaCloud11Rules = {
24
- ...camundaCloud10Rules,
25
- 'implementation': [ 'error', { version: '1.1' } ],
26
- 'element-type': [ 'error', { version: '1.1' } ],
27
- 'no-expression': [ 'error', { version: '1.1' } ],
28
- 'timer': [ 'error', { version: '1.1' } ]
29
- };
24
+ const camundaCloud11Rules = withConfig(camundaCloud10Rules, { version: '1.1' });
30
25
 
31
- const camundaCloud12Rules = {
32
- ...camundaCloud11Rules,
33
- 'implementation': [ 'error', { version: '1.2' } ],
34
- 'element-type': [ 'error', { version: '1.2' } ],
35
- 'no-expression': [ 'error', { version: '1.2' } ],
36
- 'timer': [ 'error', { version: '1.2' } ]
37
- };
26
+ const camundaCloud12Rules = withConfig(camundaCloud11Rules, { version: '1.2' });
38
27
 
39
- const camundaCloud13Rules = {
40
- ...camundaCloud12Rules,
41
- 'implementation': [ 'error', { version: '1.3' } ],
42
- 'element-type': [ 'error', { version: '1.3' } ],
43
- 'no-expression': [ 'error', { version: '1.3' } ],
44
- 'timer': [ 'error', { version: '1.3' } ]
45
- };
28
+ const camundaCloud13Rules = withConfig(camundaCloud12Rules, { version: '1.3' });
46
29
 
47
- const camundaCloud80Rules = {
48
- ...omit(camundaCloud13Rules, 'no-template'),
49
- 'implementation': [ 'error', { version: '8.0' } ],
50
- 'element-type': [ 'error', { version: '8.0' } ],
51
- 'no-expression': [ 'error', { version: '8.0' } ],
52
- 'timer': [ 'error', { version: '8.0' } ]
53
- };
30
+ const camundaCloud80Rules = withConfig({
31
+ ...omit(camundaCloud13Rules, 'no-template')
32
+ }, { version: '8.0' });
54
33
 
55
- const camundaCloud81Rules = {
34
+ const camundaCloud81Rules = withConfig({
56
35
  ...omit(camundaCloud80Rules, 'no-zeebe-properties'),
57
- 'implementation': [ 'error', { version: '8.1' } ],
58
- 'element-type': [ 'error', { version: '8.1' } ],
59
- 'inclusive-gateway': 'error',
60
- 'no-expression': [ 'error', { version: '8.1' } ],
61
- 'timer': [ 'error', { version: '8.1' } ]
62
- };
36
+ 'inclusive-gateway': 'error'
37
+ }, { version: '8.1' });
63
38
 
64
- const camundaCloud82Rules = {
65
- ...camundaCloud81Rules,
66
- 'implementation': [ 'error', { version: '8.2' } ],
67
- 'element-type': [ 'error', { version: '8.2' } ],
68
- 'no-expression': [ 'error', { version: '8.2' } ],
69
- 'timer': [ 'error', { version: '8.2' } ]
70
- };
39
+ const camundaCloud82Rules = withConfig({
40
+ ...omit(camundaCloud81Rules, 'no-candidate-users'),
41
+ 'escalation-reference': 'error'
42
+ }, { version: '8.2' });
71
43
 
72
44
  module.exports = {
73
45
  configs: {
@@ -93,4 +65,14 @@ module.exports = {
93
65
  rules: camundaCloud82Rules
94
66
  }
95
67
  }
96
- };
68
+ };
69
+
70
+ function withConfig(rules, config, type = 'error') {
71
+ let rulesWithConfig = {};
72
+
73
+ for (let name in rules) {
74
+ rulesWithConfig[ name ] = [ type, config ];
75
+ }
76
+
77
+ return rulesWithConfig;
78
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,7 +8,9 @@ const {
8
8
 
9
9
  const { reportErrors } = require('./utils/reporter');
10
10
 
11
- module.exports = function() {
11
+ const { skipInNonExecutableProcess } = require('./utils/rule');
12
+
13
+ module.exports = skipInNonExecutableProcess(function() {
12
14
  function check(node, reporter) {
13
15
  if (!is(node, 'bpmn:CallActivity')) {
14
16
  return;
@@ -38,4 +40,4 @@ module.exports = function() {
38
40
  return {
39
41
  check
40
42
  };
41
- };
43
+ });
@@ -4,7 +4,9 @@ const { ERROR_TYPES } = require('./utils/element');
4
4
 
5
5
  const { reportErrors } = require('./utils/reporter');
6
6
 
7
- module.exports = function() {
7
+ const { skipInNonExecutableProcess } = require('./utils/rule');
8
+
9
+ module.exports = skipInNonExecutableProcess(function() {
8
10
  function check(di, reporter) {
9
11
 
10
12
  if (!isCollapsedSubProcess(di)) {
@@ -28,11 +30,10 @@ module.exports = function() {
28
30
  return {
29
31
  check
30
32
  };
31
- };
32
-
33
+ });
33
34
 
34
35
  function isCollapsedSubProcess(di) {
35
36
  return is(di, 'bpmndi:BPMNShape') &&
36
- is(di.bpmnElement, 'bpmn:SubProcess') &&
37
+ is(di.get('bpmnElement'), 'bpmn:SubProcess') &&
37
38
  di.get('isExpanded') !== true;
38
39
  }
@@ -11,7 +11,9 @@ const {
11
11
 
12
12
  const { reportErrors } = require('./utils/reporter');
13
13
 
14
- module.exports = function() {
14
+ const { skipInNonExecutableProcess } = require('./utils/rule');
15
+
16
+ module.exports = skipInNonExecutableProcess(function() {
15
17
  function check(node, reporter) {
16
18
  if (!is(node, 'bpmn:UserTask') && !isZeebeServiceTask(node)) {
17
19
  return;
@@ -33,7 +35,7 @@ module.exports = function() {
33
35
  return {
34
36
  check
35
37
  };
36
- };
38
+ });
37
39
 
38
40
  // helpers //////////
39
41
 
@@ -12,7 +12,9 @@ const { ERROR_TYPES } = require('../utils/error-types');
12
12
 
13
13
  const { reportErrors } = require('../utils/reporter');
14
14
 
15
- module.exports = function({ version }) {
15
+ const { skipInNonExecutableProcess } = require('../utils/rule');
16
+
17
+ module.exports = skipInNonExecutableProcess(function({ version }) {
16
18
  function check(node, reporter) {
17
19
  if (!isAny(node, [ 'bpmn:FlowElement', 'bpmn:FlowElementsContainer' ])) {
18
20
  return;
@@ -99,4 +101,4 @@ module.exports = function({ version }) {
99
101
  return {
100
102
  check
101
103
  };
102
- };
104
+ });
@@ -10,7 +10,9 @@ const {
10
10
 
11
11
  const { reportErrors } = require('./utils/reporter');
12
12
 
13
- module.exports = function() {
13
+ const { skipInNonExecutableProcess } = require('./utils/rule');
14
+
15
+ module.exports = skipInNonExecutableProcess(function() {
14
16
  function check(node, reporter) {
15
17
  if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
16
18
  return;
@@ -50,4 +52,4 @@ module.exports = function() {
50
52
  return {
51
53
  check
52
54
  };
53
- };
55
+ });
@@ -0,0 +1,55 @@
1
+ const {
2
+ is,
3
+ isAny
4
+ } = require('bpmnlint-utils');
5
+
6
+ const {
7
+ getEventDefinition,
8
+ hasProperties
9
+ } = require('./utils/element');
10
+
11
+ const { reportErrors } = require('./utils/reporter');
12
+
13
+ const { skipInNonExecutableProcess } = require('./utils/rule');
14
+
15
+ module.exports = skipInNonExecutableProcess(function() {
16
+ function check(node, reporter) {
17
+ if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent' ])) {
18
+ return;
19
+ }
20
+
21
+ const eventDefinition = getEventDefinition(node);
22
+
23
+ if (!eventDefinition || !is(eventDefinition, 'bpmn:EscalationEventDefinition')) {
24
+ return;
25
+ }
26
+
27
+ let errors = hasProperties(eventDefinition, {
28
+ escalationRef: {
29
+ required: true
30
+ }
31
+ }, node);
32
+
33
+ if (errors && errors.length) {
34
+ reportErrors(node, reporter, errors);
35
+
36
+ return;
37
+ }
38
+
39
+ const escalationRef = eventDefinition.get('escalationRef');
40
+
41
+ errors = hasProperties(escalationRef, {
42
+ escalationCode: {
43
+ required: true
44
+ }
45
+ }, node);
46
+
47
+ if (errors && errors.length) {
48
+ reportErrors(node, reporter, errors);
49
+ }
50
+ }
51
+
52
+ return {
53
+ check
54
+ };
55
+ });
package/rules/feel.js CHANGED
@@ -10,7 +10,9 @@ const { reportErrors } = require('./utils/reporter');
10
10
 
11
11
  const { ERROR_TYPES } = require('./utils/error-types');
12
12
 
13
- module.exports = function() {
13
+ const { skipInNonExecutableProcess } = require('./utils/rule');
14
+
15
+ module.exports = skipInNonExecutableProcess(function() {
14
16
  function check(node, reporter) {
15
17
  if (is(node, 'bpmn:Expression')) {
16
18
  return;
@@ -62,7 +64,7 @@ module.exports = function() {
62
64
  return {
63
65
  check
64
66
  };
65
- };
67
+ });
66
68
 
67
69
  const isFeelProperty = ([ propertyName, value ]) => {
68
70
  return !isIgnoredProperty(propertyName) && isString(value) && value.startsWith('=');
@@ -19,7 +19,9 @@ const { reportErrors } = require('../utils/reporter');
19
19
 
20
20
  const { ERROR_TYPES } = require('../utils/error-types');
21
21
 
22
- module.exports = function({ version }) {
22
+ const { skipInNonExecutableProcess } = require('../utils/rule');
23
+
24
+ module.exports = skipInNonExecutableProcess(function({ version }) {
23
25
  function check(node, reporter) {
24
26
  const calledDecisionConfig = config.calledDecision[ node.$type ];
25
27
  const scriptConfig = config.script[ node.$type ];
@@ -175,7 +177,7 @@ module.exports = function({ version }) {
175
177
  return {
176
178
  check
177
179
  };
178
- };
180
+ });
179
181
 
180
182
  function isCalledDecisionAllowed(node, version) {
181
183
  const { calledDecision } = config;
@@ -4,7 +4,9 @@ const { ERROR_TYPES } = require('./utils/element');
4
4
 
5
5
  const { reportErrors } = require('./utils/reporter');
6
6
 
7
- module.exports = function() {
7
+ const { skipInNonExecutableProcess } = require('./utils/rule');
8
+
9
+ module.exports = skipInNonExecutableProcess(function() {
8
10
  function check(node, reporter) {
9
11
  if (!is(node, 'bpmn:InclusiveGateway')) {
10
12
  return;
@@ -31,4 +33,4 @@ module.exports = function() {
31
33
  return {
32
34
  check
33
35
  };
34
- };
36
+ });
@@ -8,7 +8,9 @@ const {
8
8
 
9
9
  const { reportErrors } = require('./utils/reporter');
10
10
 
11
- module.exports = function() {
11
+ const { skipInNonExecutableProcess } = require('./utils/rule');
12
+
13
+ module.exports = skipInNonExecutableProcess(function() {
12
14
  function check(node, reporter) {
13
15
  if (!is(node, 'bpmn:Activity')) {
14
16
  return;
@@ -62,4 +64,4 @@ module.exports = function() {
62
64
  return {
63
65
  check
64
66
  };
65
- };
67
+ });
@@ -10,7 +10,9 @@ const {
10
10
 
11
11
  const { reportErrors } = require('./utils/reporter');
12
12
 
13
- module.exports = function() {
13
+ const { skipInNonExecutableProcess } = require('./utils/rule');
14
+
15
+ module.exports = skipInNonExecutableProcess(function() {
14
16
  function check(node, reporter) {
15
17
  if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ReceiveTask' ])) {
16
18
  return;
@@ -56,4 +58,4 @@ module.exports = function() {
56
58
  return {
57
59
  check
58
60
  };
59
- };
61
+ });
@@ -0,0 +1,39 @@
1
+ const { is } = require('bpmnlint-utils');
2
+
3
+ const {
4
+ findExtensionElement,
5
+ hasProperties
6
+ } = require('./utils/element');
7
+
8
+ const { reportErrors } = require('./utils/reporter');
9
+
10
+ const { skipInNonExecutableProcess } = require('./utils/rule');
11
+
12
+ module.exports = skipInNonExecutableProcess(function() {
13
+ function check(node, reporter) {
14
+ if (!is(node, 'bpmn:UserTask')) {
15
+ return;
16
+ }
17
+
18
+ const assignmentDefinition = findExtensionElement(node, 'zeebe:AssignmentDefinition');
19
+
20
+ if (!assignmentDefinition) {
21
+ return;
22
+ }
23
+
24
+ const errors = hasProperties(assignmentDefinition, {
25
+ candidateUsers: {
26
+ allowed: false,
27
+ allowedVersion: '8.2'
28
+ }
29
+ }, node);
30
+
31
+ if (errors && errors.length) {
32
+ reportErrors(node, reporter, errors);
33
+ }
34
+ }
35
+
36
+ return {
37
+ check
38
+ };
39
+ });
@@ -11,6 +11,8 @@ const {
11
11
 
12
12
  const { reportErrors } = require('./utils/reporter');
13
13
 
14
+ const { skipInNonExecutableProcess } = require('./utils/rule');
15
+
14
16
  const handlersMap = {
15
17
  '1.0': [
16
18
  checkErrorCode
@@ -36,7 +38,7 @@ const handlersMap = {
36
38
  ]
37
39
  };
38
40
 
39
- module.exports = noExpressionRule;
41
+ module.exports = skipInNonExecutableProcess(noExpressionRule);
40
42
 
41
43
  /**
42
44
  * Make sure that certain properties do not contain expressions in older versions.
@@ -2,7 +2,9 @@ const { hasProperties } = require('./utils/element');
2
2
 
3
3
  const { reportErrors } = require('./utils/reporter');
4
4
 
5
- module.exports = function() {
5
+ const { skipInNonExecutableProcess } = require('./utils/rule');
6
+
7
+ module.exports = skipInNonExecutableProcess(function() {
6
8
  function check(node, reporter) {
7
9
  const errors = hasProperties(node, {
8
10
  modelerTemplate: {
@@ -19,4 +21,4 @@ module.exports = function() {
19
21
  return {
20
22
  check
21
23
  };
22
- };
24
+ });
@@ -4,7 +4,9 @@ const { hasNoExtensionElement } = require('./utils/element');
4
4
 
5
5
  const { reportErrors } = require('./utils/reporter');
6
6
 
7
- module.exports = function() {
7
+ const { skipInNonExecutableProcess } = require('./utils/rule');
8
+
9
+ module.exports = skipInNonExecutableProcess(function() {
8
10
  function check(node, reporter) {
9
11
  if (!is(node, 'zeebe:PropertiesHolder')) {
10
12
  return;
@@ -20,4 +22,4 @@ module.exports = function() {
20
22
  return {
21
23
  check
22
24
  };
23
- };
25
+ });
@@ -4,7 +4,9 @@ const { hasProperties } = require('./utils/element');
4
4
 
5
5
  const { reportErrors } = require('./utils/reporter');
6
6
 
7
- module.exports = function() {
7
+ const { skipInNonExecutableProcess } = require('./utils/rule');
8
+
9
+ module.exports = skipInNonExecutableProcess(function() {
8
10
  function check(node, reporter) {
9
11
  if (!isAny(node, [ 'bpmn:ExclusiveGateway', 'bpmn:InclusiveGateway' ])) {
10
12
  return;
@@ -32,4 +34,4 @@ module.exports = function() {
32
34
  return {
33
35
  check
34
36
  };
35
- };
37
+ });
@@ -12,7 +12,9 @@ const {
12
12
 
13
13
  const { reportErrors } = require('./utils/reporter');
14
14
 
15
- module.exports = function() {
15
+ const { skipInNonExecutableProcess } = require('./utils/rule');
16
+
17
+ module.exports = skipInNonExecutableProcess(function() {
16
18
  function check(node, reporter) {
17
19
  if (!isAny(node, [ 'bpmn:CatchEvent', 'bpmn:ThrowEvent', 'bpmn:ReceiveTask' ])
18
20
  || (is(node, 'bpmn:StartEvent') && !is(node.$parent, 'bpmn:SubProcess'))) {
@@ -61,4 +63,4 @@ module.exports = function() {
61
63
  return {
62
64
  check
63
65
  };
64
- };
66
+ });
@@ -23,7 +23,9 @@ const {
23
23
 
24
24
  const { reportErrors } = require('../utils/reporter');
25
25
 
26
- module.exports = function({ version }) {
26
+ const { skipInNonExecutableProcess } = require('../utils/rule');
27
+
28
+ module.exports = skipInNonExecutableProcess(function({ version }) {
27
29
  function check(node, reporter) {
28
30
  if (!is(node, 'bpmn:Event')) {
29
31
  return;
@@ -53,7 +55,7 @@ module.exports = function({ version }) {
53
55
  return {
54
56
  check
55
57
  };
56
- };
58
+ });
57
59
 
58
60
  function checkTimePropertyExists(eventDefinition, event) {
59
61
  if (is(event, 'bpmn:StartEvent')) {
@@ -8,7 +8,9 @@ const {
8
8
 
9
9
  const { reportErrors } = require('./utils/reporter');
10
10
 
11
- module.exports = function() {
11
+ const { skipInNonExecutableProcess } = require('./utils/rule');
12
+
13
+ module.exports = skipInNonExecutableProcess(function() {
12
14
  function check(node, reporter) {
13
15
  if (!is(node, 'bpmn:UserTask')) {
14
16
  return;
@@ -54,7 +56,7 @@ module.exports = function() {
54
56
  return {
55
57
  check
56
58
  };
57
- };
59
+ });
58
60
 
59
61
  // helpers //////////
60
62
 
@@ -0,0 +1,43 @@
1
+ const { is } = require('bpmnlint-utils');
2
+
3
+ const { greaterOrEqual } = require('./version');
4
+
5
+ function skipInNonExecutableProcess(ruleFactory) {
6
+ return function(config = {}) {
7
+ const rule = ruleFactory(config);
8
+
9
+ const { version } = config;
10
+
11
+ function check(node, reporter) {
12
+ if (version && greaterOrEqual(version, '8.2') && isNonExecutableProcess(node)) {
13
+ return false;
14
+ }
15
+
16
+ return rule.check(node, reporter);
17
+ }
18
+
19
+ return {
20
+ ...rule,
21
+ check
22
+ };
23
+ };
24
+ }
25
+
26
+ module.exports = {
27
+ skipInNonExecutableProcess
28
+ };
29
+
30
+ function isNonExecutableProcess(node) {
31
+ let process;
32
+
33
+ if (is(node, 'bpmn:Process')) {
34
+ process = node;
35
+ }
36
+
37
+ if (is(node, 'bpmndi:BPMNPlane')
38
+ && is(node.get('bpmnElement'), 'bpmn:Process')) {
39
+ process = node.get('bpmnElement');
40
+ }
41
+
42
+ return process && !process.get('isExecutable');
43
+ }