Skip to content

Commit

Permalink
feat(rules): attach documentation URLs
Browse files Browse the repository at this point in the history
Previously we injected them via camunda/linting,
now we can use the new meta infrastructure provided by
bpmnlint itself.

Related to bpmn-io/bpmnlint#165
  • Loading branch information
nikku committed Feb 18, 2025
1 parent 3c936f0 commit 974999f
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 14 deletions.
6 changes: 4 additions & 2 deletions rules/camunda-cloud/called-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const {
hasProperties
} = require('../utils/element');

const { annotateRule } = require('../helper');

const { reportErrors } = require('../utils/reporter');

const { skipInNonExecutableProcess } = require('../utils/rule');
Expand Down Expand Up @@ -37,7 +39,7 @@ module.exports = skipInNonExecutableProcess(function() {
}
}

return {
return annotateRule('called-element', {
check
};
});
});
6 changes: 4 additions & 2 deletions rules/camunda-cloud/element-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const { reportErrors } = require('../../utils/reporter');

const { skipInNonExecutableProcess } = require('../../utils/rule');

const { annotateRule } = require('../../helper');

module.exports = skipInNonExecutableProcess(function({ version }) {
function check(node, reporter) {
if (!isAny(node, [ 'bpmn:FlowElement', 'bpmn:FlowElementsContainer' ])) {
Expand Down Expand Up @@ -128,7 +130,7 @@ module.exports = skipInNonExecutableProcess(function({ version }) {
}
}

return {
return annotateRule('element-type', {
check
};
});
});
5 changes: 3 additions & 2 deletions rules/camunda-cloud/error-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const { reportErrors } = require('../utils/reporter');
const { skipInNonExecutableProcess } = require('../utils/rule');

const { greaterOrEqual } = require('../utils/version');
const { annotateRule } = require('../helper');

const noErrorRefAllowedVersion = '8.2';

Expand Down Expand Up @@ -62,9 +63,9 @@ module.exports = skipInNonExecutableProcess(function({ version }) {
}
}

return {
return annotateRule('error-reference', {
check
};
});
});

function isNoErrorRefAllowed(node, version) {
Expand Down
5 changes: 3 additions & 2 deletions rules/camunda-cloud/escalation-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
const { reportErrors } = require('../utils/reporter');

const { skipInNonExecutableProcess } = require('../utils/rule');
const { annotateRule } = require('../helper');

module.exports = skipInNonExecutableProcess(function() {
function check(node, reporter) {
Expand Down Expand Up @@ -57,9 +58,9 @@ module.exports = skipInNonExecutableProcess(function() {
}
}

return {
return annotateRule('escalation-reference', {
check
};
});
});

function isNoEscalationRefAllowed(node) {
Expand Down
5 changes: 3 additions & 2 deletions rules/camunda-cloud/feel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { reportErrors } = require('../utils/reporter');
const { ERROR_TYPES } = require('../utils/error-types');

const { skipInNonExecutableProcess } = require('../utils/rule');
const { annotateRule } = require('../helper');

module.exports = skipInNonExecutableProcess(function() {
function check(node, reporter) {
Expand Down Expand Up @@ -64,9 +65,9 @@ module.exports = skipInNonExecutableProcess(function() {
}
}

return {
return annotateRule('feel', {
check
};
});
});

const isFeelProperty = ([ propertyName, value ]) => {
Expand Down
5 changes: 3 additions & 2 deletions rules/camunda-cloud/message-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
const { reportErrors } = require('../utils/reporter');

const { skipInNonExecutableProcess } = require('../utils/rule');
const { annotateRule } = require('../helper');

module.exports = skipInNonExecutableProcess(function() {
function check(node, reporter) {
Expand Down Expand Up @@ -55,7 +56,7 @@ module.exports = skipInNonExecutableProcess(function() {
}
}

return {
return annotateRule('message-reference', {
check
};
});
});
5 changes: 5 additions & 0 deletions rules/camunda-cloud/zeebe-user-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ module.exports = skipInNonExecutableProcess(function() {
}

return {
meta: {
documentation: {
url: 'https://docs.camunda.io/docs/next/apis-tools/migration-manuals/migrate-to-zeebe-user-tasks'
}
},
check
};
});
6 changes: 4 additions & 2 deletions rules/camunda-platform/history-time-to-live.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { is } = require('bpmnlint-utils');

const { annotateRule } = require('../helper');

const { skipInNonExecutableProcess } = require('../utils/rule');

module.exports = skipInNonExecutableProcess(function() {
Expand All @@ -14,7 +16,7 @@ module.exports = skipInNonExecutableProcess(function() {
}
}

return {
return annotateRule('history-time-to-live', {
check
};
});
});
39 changes: 39 additions & 0 deletions rules/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const modelingGuidanceBaseUrl = 'https://docs.camunda.io/docs/next/components/modeler/reference/modeling-guidance/rules';

/**
* @typedef { any } RuleDefinition
*/

/**
* Annotate a rule with core information, such as the documentation url.
*
* @param { string } ruleName
* @param { RuleDefinition } options
*
* @return { RuleDefinition }
*/
function annotateRule(ruleName, options) {

const {
meta: {
documentation = {},
...restMeta
} = {},
...restOptions
} = options;

const documentationUrl = `${modelingGuidanceBaseUrl}/${ruleName}.md`;

return {
meta: {
documentation: {
url: documentationUrl,
...documentation
},
...restMeta
},
...restOptions
};
}

module.exports.annotateRule = annotateRule;

0 comments on commit 974999f

Please sign in to comment.