From 773ee205e40e6b1204c16beb7ed8b07f2a5e3f22 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Fri, 22 Nov 2024 15:05:33 +0100 Subject: [PATCH 1/3] fix: remove `zeebe-user-task` rule The rule was added too early as the feature is still supported in all versions of Camunda. Related to https://github.com/camunda/camunda-modeler/issues/4718 --- index.js | 4 +- rules/camunda-cloud/zeebe-user-task.js | 25 ------- .../integration/zeebe-user-task-errors.bpmn | 15 ---- .../integration/zeebe-user-task.bpmn | 17 ----- .../integration/zeebe-user-task.spec.js | 68 ------------------- test/camunda-cloud/zeebe-user-task.spec.js | 50 -------------- test/config/configs.spec.js | 6 +- 7 files changed, 3 insertions(+), 182 deletions(-) delete mode 100644 rules/camunda-cloud/zeebe-user-task.js delete mode 100644 test/camunda-cloud/integration/zeebe-user-task-errors.bpmn delete mode 100644 test/camunda-cloud/integration/zeebe-user-task.bpmn delete mode 100644 test/camunda-cloud/integration/zeebe-user-task.spec.js delete mode 100644 test/camunda-cloud/zeebe-user-task.spec.js diff --git a/index.js b/index.js index d23aeee..6fdc492 100644 --- a/index.js +++ b/index.js @@ -96,7 +96,6 @@ const camundaCloud86Rules = withConfig({ const camundaCloud87Rules = withConfig({ ...omit(camundaCloud86Rules, [ 'no-task-listeners' ]), - 'zeebe-user-task': 'error', 'task-listener': 'error' }, { version: '8.7' }); @@ -174,8 +173,7 @@ const rules = { 'user-task-definition': './rules/camunda-cloud/user-task-definition', 'user-task-form': './rules/camunda-cloud/user-task-form', 'version-tag': './rules/camunda-cloud/version-tag', - 'wait-for-completion': './rules/camunda-cloud/wait-for-completion', - 'zeebe-user-task': './rules/camunda-cloud/zeebe-user-task' + 'wait-for-completion': './rules/camunda-cloud/wait-for-completion' }; const configs = { diff --git a/rules/camunda-cloud/zeebe-user-task.js b/rules/camunda-cloud/zeebe-user-task.js deleted file mode 100644 index 97e1f7f..0000000 --- a/rules/camunda-cloud/zeebe-user-task.js +++ /dev/null @@ -1,25 +0,0 @@ -const { is } = require('bpmnlint-utils'); - -const { reportErrors } = require('../utils/reporter'); - -const { skipInNonExecutableProcess } = require('../utils/rule'); - -const { hasExtensionElement } = require('../utils/element'); - -module.exports = skipInNonExecutableProcess(function() { - function check(node, reporter) { - if (!is(node, 'bpmn:UserTask')) { - return; - } - - const errors = hasExtensionElement(node, 'zeebe:UserTask', node); - - if (errors && errors.length) { - reportErrors(node, reporter, errors); - } - } - - return { - check - }; -}); diff --git a/test/camunda-cloud/integration/zeebe-user-task-errors.bpmn b/test/camunda-cloud/integration/zeebe-user-task-errors.bpmn deleted file mode 100644 index 36293b7..0000000 --- a/test/camunda-cloud/integration/zeebe-user-task-errors.bpmn +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/camunda-cloud/integration/zeebe-user-task.bpmn b/test/camunda-cloud/integration/zeebe-user-task.bpmn deleted file mode 100644 index c5dcc1d..0000000 --- a/test/camunda-cloud/integration/zeebe-user-task.bpmn +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/camunda-cloud/integration/zeebe-user-task.spec.js b/test/camunda-cloud/integration/zeebe-user-task.spec.js deleted file mode 100644 index db37395..0000000 --- a/test/camunda-cloud/integration/zeebe-user-task.spec.js +++ /dev/null @@ -1,68 +0,0 @@ -const { expect } = require('chai'); - -const Linter = require('bpmnlint/lib/linter'); - -const NodeResolver = require('bpmnlint/lib/resolver/node-resolver'); - -const { readModdle } = require('../../helper'); - -const versions = [ - '8.7' -]; - -describe('integration - zeebe-user-task', function() { - - versions.forEach(function(version) { - - let linter; - - beforeEach(function() { - linter = new Linter({ - config: { - extends: `plugin:camunda-compat/camunda-cloud-${ version.replace('.', '-') }` - }, - resolver: new NodeResolver() - }); - }); - - - describe(`Camunda Cloud ${ version }`, function() { - - describe('no errors', function() { - - it('should not have errors', async function() { - - // given - const { root } = await readModdle('test/camunda-cloud/integration/zeebe-user-task.bpmn'); - - // when - const reports = await linter.lint(root); - - // then - expect(reports[ 'camunda-compat/zeebe-user-task' ]).not.to.exist; - }); - - }); - - - describe('errors', function() { - - it('should have errors', async function() { - - // given - const { root } = await readModdle('test/camunda-cloud/integration/zeebe-user-task-errors.bpmn'); - - // when - const reports = await linter.lint(root); - - // then - expect(reports[ 'camunda-compat/zeebe-user-task' ]).to.exist; - }); - - }); - - }); - - }); - -}); \ No newline at end of file diff --git a/test/camunda-cloud/zeebe-user-task.spec.js b/test/camunda-cloud/zeebe-user-task.spec.js deleted file mode 100644 index 3f1cdbe..0000000 --- a/test/camunda-cloud/zeebe-user-task.spec.js +++ /dev/null @@ -1,50 +0,0 @@ -const RuleTester = require('bpmnlint/lib/testers/rule-tester'); - -const rule = require('../../rules/camunda-cloud/zeebe-user-task'); - -const { - createModdle, - createProcess -} = require('../helper'); - -const { ERROR_TYPES } = require('../../rules/utils/element'); - -const valid = [ - { - name: 'zeebe user task (Camunda 8.7)', - config: { version: '8.7' }, - moddleElement: createModdle(createProcess(` - - - - - - `)) - } -]; - -const invalid = [ - { - name: 'job worker user task (Camunda 8.7)', - config: { version: '8.7' }, - moddleElement: createModdle(createProcess(` - - `)), - report: { - id: 'UserTask_1', - message: 'Element of type must have one extension element of type ', - path: [], - data: { - type: ERROR_TYPES.EXTENSION_ELEMENT_REQUIRED, - node: 'UserTask_1', - parentNode: null, - requiredExtensionElement: 'zeebe:UserTask' - } - } - } -]; - -RuleTester.verify('zeebe-user-task', rule, { - valid, - invalid -}); \ No newline at end of file diff --git a/test/config/configs.spec.js b/test/config/configs.spec.js index c6b446c..290536b 100644 --- a/test/config/configs.spec.js +++ b/test/config/configs.spec.js @@ -431,8 +431,7 @@ describe('configs', function() { 'user-task-definition': [ 'warn', { version: '8.7' } ], 'user-task-form': [ 'error', { version: '8.7' } ], 'version-tag': [ 'error', { version: '8.7' } ], - 'wait-for-completion': [ 'error', { version: '8.7' } ], - 'zeebe-user-task': [ 'error', { version: '8.7' } ] + 'wait-for-completion': [ 'error', { version: '8.7' } ] })); @@ -507,8 +506,7 @@ describe('configs', function() { 'user-task-definition': 'warn', 'user-task-form': 'error', 'version-tag': 'error', - 'wait-for-completion': 'error', - 'zeebe-user-task': 'error' + 'wait-for-completion': 'error' })); }); From 56fb877c5288f28389fedb8bf21c263c18aa2173 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Fri, 22 Nov 2024 15:14:43 +0100 Subject: [PATCH 2/3] fix: do not mark job worker user task as incorrect Related to https://github.com/camunda/camunda-modeler/issues/4718 --- rules/camunda-cloud/task-listener.js | 12 ++++++------ test/camunda-cloud/task-listener.spec.js | 14 +++++++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/rules/camunda-cloud/task-listener.js b/rules/camunda-cloud/task-listener.js index 2a8c468..6fa2fd0 100644 --- a/rules/camunda-cloud/task-listener.js +++ b/rules/camunda-cloud/task-listener.js @@ -17,18 +17,18 @@ module.exports = skipInNonExecutableProcess(function() { return; } - let errors = hasExtensionElement(node, 'zeebe:UserTask', node); - - if (errors && errors.length) { - reportErrors(node, reporter, errors); - } - const taskListeners = findExtensionElement(node, 'zeebe:TaskListeners'); if (!taskListeners) { return; } + let errors = hasExtensionElement(node, 'zeebe:UserTask'); + + if (errors && errors.length) { + reportErrors(node, reporter, errors); + } + const listeners = taskListeners.get('listeners'); errors = listeners.flatMap(listener => hasProperties(listener, { type: { diff --git a/test/camunda-cloud/task-listener.spec.js b/test/camunda-cloud/task-listener.spec.js index be539ef..be1b7e3 100644 --- a/test/camunda-cloud/task-listener.spec.js +++ b/test/camunda-cloud/task-listener.spec.js @@ -23,6 +23,13 @@ const valid = [ `)) + }, + { + name: 'job worker user task without tasklisteners', + config: { version: '8.7' }, + moddleElement: createModdle(createProcess(` + + `)) } ]; @@ -42,7 +49,12 @@ const invalid = [ report: { id: 'UserTask_1', message: 'Element of type must have one extension element of type ', - path: [], + path: [ + 'rootElements', + 0, + 'flowElements', + 0 + ], data: { type: ERROR_TYPES.EXTENSION_ELEMENT_REQUIRED, node: 'UserTask_1', From f6313a1eea27e78a31a4ddc5ddfbab797598eb7f Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Fri, 22 Nov 2024 16:29:14 +0100 Subject: [PATCH 3/3] fix: relax `task-listener` to not check implementation type This is to not lint a situation which can be achieved via manual XML modification. Related to https://github.com/camunda/bpmnlint-plugin-camunda-compat/pull/182#discussion_r1854107263 --- rules/camunda-cloud/task-listener.js | 11 ++------- test/camunda-cloud/task-listener.spec.js | 29 ------------------------ 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/rules/camunda-cloud/task-listener.js b/rules/camunda-cloud/task-listener.js index 6fa2fd0..e04bd32 100644 --- a/rules/camunda-cloud/task-listener.js +++ b/rules/camunda-cloud/task-listener.js @@ -2,8 +2,7 @@ const { is } = require('bpmnlint-utils'); const { findExtensionElement, - hasProperties, - hasExtensionElement + hasProperties } = require('../utils/element'); const { reportErrors } = require('../utils/reporter'); @@ -23,14 +22,8 @@ module.exports = skipInNonExecutableProcess(function() { return; } - let errors = hasExtensionElement(node, 'zeebe:UserTask'); - - if (errors && errors.length) { - reportErrors(node, reporter, errors); - } - const listeners = taskListeners.get('listeners'); - errors = listeners.flatMap(listener => hasProperties(listener, { + const errors = listeners.flatMap(listener => hasProperties(listener, { type: { required: true } diff --git a/test/camunda-cloud/task-listener.spec.js b/test/camunda-cloud/task-listener.spec.js index be1b7e3..5eea42f 100644 --- a/test/camunda-cloud/task-listener.spec.js +++ b/test/camunda-cloud/task-listener.spec.js @@ -34,35 +34,6 @@ const valid = [ ]; const invalid = [ - { - name: 'task listener not in zeebe:UserTask', - config: { version: '8.7' }, - moddleElement: createModdle(createProcess(` - - - - - - - - `)), - report: { - id: 'UserTask_1', - message: 'Element of type must have one extension element of type ', - path: [ - 'rootElements', - 0, - 'flowElements', - 0 - ], - data: { - type: ERROR_TYPES.EXTENSION_ELEMENT_REQUIRED, - node: 'UserTask_1', - parentNode: null, - requiredExtensionElement: 'zeebe:UserTask' - } - } - }, { name: 'task listener with empty type', config: { version: '8.7' },