-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rules): add
duplicate-task-headers
rule
Related to camunda/linting#4 Co-authored-by: Niklas Kiefer <[email protected]>
- Loading branch information
1 parent
b815fca
commit 4eb57f1
Showing
5 changed files
with
477 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const { is } = require('bpmnlint-utils'); | ||
|
||
const { | ||
findExtensionElement, | ||
getMessageEventDefinition, | ||
hasDuplicatedPropertyValues | ||
} = require('./utils/element'); | ||
|
||
const { reportErrors } = require('./utils/reporter'); | ||
|
||
module.exports = function() { | ||
function check(node, reporter) { | ||
if (!is(node, 'bpmn:UserTask') && !isZeebeServiceTask(node)) { | ||
return; | ||
} | ||
|
||
const taskHeaders = findExtensionElement(node, 'zeebe:TaskHeaders'); | ||
|
||
if (!taskHeaders) { | ||
return; | ||
} | ||
|
||
const errors = hasDuplicatedPropertyValues(taskHeaders, 'values', 'key', node); | ||
|
||
if (errors && errors.length) { | ||
reportErrors(node, reporter, errors); | ||
} | ||
} | ||
|
||
return { | ||
check | ||
}; | ||
}; | ||
|
||
|
||
// helper /////////////// | ||
|
||
function isZeebeServiceTask(element) { | ||
if (!is(element, 'zeebe:ZeebeServiceTask')) { | ||
return false; | ||
} | ||
|
||
if (is(element, 'bpmn:EndEvent') || is(element, 'bpmn:IntermediateThrowEvent')) { | ||
return !!getMessageEventDefinition(element); | ||
} | ||
|
||
// A BusinessRuleTask is per default not a ServiceTask, only if it has a TaskDefinition | ||
// (ie. if the implementation is set to ==JobWorker) | ||
if (is(element, 'bpmn:BusinessRuleTask') && !findExtensionElement(element, 'zeebe:TaskDefinition')) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.