Skip to main content
Version: 8.3

Custom lint rules

Through Camunda Modeler plugins, you can add custom lint rules and configure or disable existing rules. bpmnlint is used to validate BPMN diagrams, so the plugins have to be bpmnlint plugins at the core.

Getting started

Get started with the custom-linter-rules-plugin template and take the following steps:

  1. Clone or fork the repository:
git clone https://github.com/camunda/camunda-modeler-custom-linter-rules-plugin.git

The plugin starter project comes with a client folder referenced in the plugin entry point. It contains the script that adds a bpmnlint plugin to the modeler. Since this is a client plugin, you must bundle it.

  1. Install the dependencies with the following command:
npm install
  1. Add a custom rule. To do this, add it to the bpmnlint-plugin-custom/rules folder. The example project contains a no-manual-task.js file which implements a custom rule.

Every rule must export a function that returns an object with a check function:

/**
* Rule that reports manual tasks being used.
*/
module.exports = function () {
function check(node, reporter) {
if (is(node, "bpmn:ManualTask")) {
reporter.report(node.id, "Element has disallowed type bpmn:ManualTask");
}
}

return {
check: check,
};
};

This function is called for every node when bpmnlint traverses the model.

  1. Change the configuration. Through the configuration in .bpmnlintrc, you can add the custom rules you implemented in bpmnlint-plugin-custom/rules.
{
"extends": [
"bpmnlint:recommended",
"plugin:custom/recommended"
],
"rules": {
"label-required": "off",
"custom/no-manual-task": "warn"
}
}

The example configuration adds all rules specified in the recommended configuration of the bpmnlint plugin. It also adds all the rules that come with bpmnlint and configures two rules.

  1. Bundle your plugin by running the following command:
npm run build

The custom lint rules and configuration will be used when validating a BPMN diagram.

Camunda Modeler with custom lint rule

Additional resources