diff --git a/ruoyi-ui/bpmnlint-plugin-local/.gitignore b/ruoyi-ui/bpmnlint-plugin-local/.gitignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/ruoyi-ui/bpmnlint-plugin-local/README.md b/ruoyi-ui/bpmnlint-plugin-local/README.md new file mode 100644 index 00000000..7f584d7e --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/README.md @@ -0,0 +1,39 @@ +# bpmnlint-plugin-local + +A bpmlint plug-in based on the [bpmnlint plug-in example](https://github.com/bpmn-io/bpmnlint-plugin-example). + + +## About + +This plugin contributes [rules](#add-rules) and [configuration](#add-configuration) under the `local` prefix to bpmnlint. + + +## Add Rules + +The [`./rules`](./rules) folder contains rules that are made available via +this plug-in. Configure them with the `local` prefix in your `.bpmnlintrc`: + +```json +{ + "rules": { + "local/no-manual-task": "warn" + } +} +``` + +Checkout [`./test.js`](./test.js) to learn how to test your rules. + + +## Add Configuration + +As part of the [`./index.js`](./index.js) the plug-in exposes configurations +to extend from using `extends` in the bpmnlint configuration: + +```json +{ + "extends": [ + "bpmnlint:recommended", + "plugin:local/recommended" + ] +} +``` \ No newline at end of file diff --git a/ruoyi-ui/bpmnlint-plugin-local/docs/rules/examples/no-manual-task-correct.bpmn b/ruoyi-ui/bpmnlint-plugin-local/docs/rules/examples/no-manual-task-correct.bpmn new file mode 100644 index 00000000..5544a762 --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/docs/rules/examples/no-manual-task-correct.bpmn @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/ruoyi-ui/bpmnlint-plugin-local/docs/rules/examples/no-manual-task-incorrect.bpmn b/ruoyi-ui/bpmnlint-plugin-local/docs/rules/examples/no-manual-task-incorrect.bpmn new file mode 100644 index 00000000..f95464ec --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/docs/rules/examples/no-manual-task-incorrect.bpmn @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/ruoyi-ui/bpmnlint-plugin-local/docs/rules/no-manual-task.md b/ruoyi-ui/bpmnlint-plugin-local/docs/rules/no-manual-task.md new file mode 100644 index 00000000..b48c20d3 --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/docs/rules/no-manual-task.md @@ -0,0 +1,16 @@ +# No Manual Task (no-manual-task) + +Checks that the diagram does not contain manual tasks that have no execution semantics. + +Example of __incorrect__ usage of this rule: + +![Incorrect usage example](./examples/no-manual-task-incorrect.png) + +Cf. [`no-manual-task-incorrect.bpmn`](./examples/no-manual-task-incorrect.bpmn). + + +Example of __correct__ usage of this rule: + +![Correct usage example](./examples/no-manual-task-correct.png) + +Cf. [`no-manual-task-correct.bpmn`](./examples/no-manual-task-correct.bpmn). diff --git a/ruoyi-ui/bpmnlint-plugin-local/index.js b/ruoyi-ui/bpmnlint-plugin-local/index.js new file mode 100644 index 00000000..68fd2f0e --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/index.js @@ -0,0 +1,15 @@ +module.exports = { + configs: { + recommended: { + rules: { + 'target-namespace': 'error' + } + }, + all: { + rules: { + 'target-namespace': 'warn', + 'no-manual-task': 'warn' + } + } + } +} \ No newline at end of file diff --git a/ruoyi-ui/bpmnlint-plugin-local/package.json b/ruoyi-ui/bpmnlint-plugin-local/package.json new file mode 100644 index 00000000..ebb7d200 --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/package.json @@ -0,0 +1,26 @@ +{ + "name": "bpmnlint-plugin-local", + "version": "0.0.0", + "description": "The bpmnlint local plug-in", + "main": "index.js", + "scripts": { + "all": "npm test", + "test": "mocha test.js" + }, + "keywords": [ + "bpmnlint", + "plugin" + ], + "devDependencies": { + "bpmnlint": "^7.2.1", + "chai": "^4.2.0", + "mocha": "^9.1.3" + }, + "dependencies": { + "bpmnlint-utils": "^1.0.2" + }, + "files": [ + "rules", + "index.js" + ] +} diff --git a/ruoyi-ui/bpmnlint-plugin-local/rules/no-manual-task.js b/ruoyi-ui/bpmnlint-plugin-local/rules/no-manual-task.js new file mode 100644 index 00000000..0877a2d4 --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/rules/no-manual-task.js @@ -0,0 +1,20 @@ +const { + is +} = require('bpmnlint-utils'); + + +/** + * 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 + }; +}; diff --git a/ruoyi-ui/bpmnlint-plugin-local/rules/target-namespace.js b/ruoyi-ui/bpmnlint-plugin-local/rules/target-namespace.js new file mode 100644 index 00000000..1d1a7ea2 --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/rules/target-namespace.js @@ -0,0 +1,20 @@ +const { + is +} = require('bpmnlint-utils'); + + +/** + * Rule that reports missing targetNamespace on bpmn:Definitions. + */ +module.exports = function() { + + function check(node, reporter) { + if (is(node, 'bpmn:Definitions') && !node.targetNamespace) { + reporter.report(node.id, 'Element is missing targetNamespace'); + } + } + + return { + check: check + }; +}; diff --git a/ruoyi-ui/bpmnlint-plugin-local/test.js b/ruoyi-ui/bpmnlint-plugin-local/test.js new file mode 100644 index 00000000..295416ad --- /dev/null +++ b/ruoyi-ui/bpmnlint-plugin-local/test.js @@ -0,0 +1,55 @@ +const { expect } = require('chai'); + +const { createModdle } = require('bpmnlint/lib/testers/helper'); + +const RuleTester = require('bpmnlint/lib/testers/rule-tester'); + +const manualTaskRule = require('./rules/no-manual-task'); +const targetNamespaceRule = require('./rules/target-namespace'); + + +RuleTester.verify('no-manual-task', manualTaskRule, { + valid: [ + { + moddleElement: createModdle( + '', + 'bpmn:StartEvent' + ) + } + ], + invalid: [ + { + moddleElement: createModdle( + '', + 'bpmn:ManualTask' + ), + report: { + id: 'manualTask', + message: 'Element has disallowed type bpmn:ManualTask' + } + } + ] +}); + + +RuleTester.verify('target-namespace', targetNamespaceRule, { + valid: [ + { + moddleElement: createModdle( + '', + ) + } + ], + invalid: [ + { + moddleElement: createModdle( + '', + ), + report: { + id: 'definitions', + message: 'Element is missing targetNamespace' + } + } + ] +}); + diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 1479925b..b7394e23 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -66,7 +66,8 @@ "vue-router": "3.4.9", "vuedraggable": "2.24.3", "vuex": "3.6.0", - "xcrud": "^0.4.19" + "xcrud": "^0.4.19", + "bpmnlint-plugin-local": "file:bpmnlint-plugin-local" }, "devDependencies": { "@babel/parser": "^7.20.5", diff --git a/ruoyi-ui/src/components/Process/.bpmnlintrc b/ruoyi-ui/src/components/Process/.bpmnlintrc index 0c1faae1..a5f1665a 100644 --- a/ruoyi-ui/src/components/Process/.bpmnlintrc +++ b/ruoyi-ui/src/components/Process/.bpmnlintrc @@ -1,3 +1,9 @@ { - "extends": "bpmnlint:recommended" + "extends": [ + "bpmnlint:recommended", + "plugin:local/recommended" + ], + "rules": { + "local/no-manual-task": "warn" + } }