bpmnlint 11.14.1 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/bpmnlint.js +11 -416
- package/lib/linter.js +2 -542
- package/lib/product.js +6 -0
- package/lib/resolver/helper.js +1 -12
- package/lib/resolver/node-resolver.js +6 -135
- package/lib/resolver/static-resolver.js +1 -48
- package/lib/support/compile-config.js +5 -200
- package/lib/test-rule.js +1 -107
- package/lib/testers/helper.js +14 -70
- package/lib/testers/rule-tester.d.ts +10 -28
- package/lib/testers/rule-tester.js +10 -140
- package/lib/traverse.js +1 -56
- package/lib/types.d.ts +20 -81
- package/package.json +46 -12
- package/rules/no-overlapping-elements.js +88 -23
package/lib/types.d.ts
CHANGED
|
@@ -1,81 +1,20 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type EnterFn = (element: ModdleElement, reporter: Reporter) => boolean | void;
|
|
23
|
-
|
|
24
|
-
export type LeaveFn = (element: ModdleElement, reporter: Reporter) => void;
|
|
25
|
-
|
|
26
|
-
export type CheckDefinition = EnterFn | {
|
|
27
|
-
enter: EnterFn
|
|
28
|
-
} | {
|
|
29
|
-
leave: LeaveFn
|
|
30
|
-
} | {
|
|
31
|
-
enter: EnterFn,
|
|
32
|
-
leave: LeaveFn
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type RuleDefinition = {
|
|
36
|
-
meta?: {
|
|
37
|
-
documentation?: {
|
|
38
|
-
url?: string
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
check: CheckDefinition
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type RuleFactory = (ruleOptions?: any) => RuleDefinition;
|
|
45
|
-
|
|
46
|
-
export type ReportingCategoryMap = {
|
|
47
|
-
0: 'off',
|
|
48
|
-
1: 'warn',
|
|
49
|
-
2: 'error',
|
|
50
|
-
3: 'info'
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export type ReportingCategoryIndex = keyof ReportingCategoryMap;
|
|
54
|
-
export type ReportingCategory = ReportingCategoryMap[ReportingCategoryIndex];
|
|
55
|
-
|
|
56
|
-
export type RuleErrorCategory = 'rule-error';
|
|
57
|
-
|
|
58
|
-
export type RuleConfig =
|
|
59
|
-
ReportingCategoryIndex |
|
|
60
|
-
ReportingCategory |
|
|
61
|
-
[ ReportingCategoryIndex, config?: any ] |
|
|
62
|
-
[ ReportingCategory, config?: any ];
|
|
63
|
-
|
|
64
|
-
export type RuleConfigs = Record<string, RuleConfig>;
|
|
65
|
-
|
|
66
|
-
export type Config = {
|
|
67
|
-
extends?: string | string[],
|
|
68
|
-
rules?: RuleConfigs
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export type TransformRuleFn = (
|
|
72
|
-
rule: RuleDefinition,
|
|
73
|
-
options: { pkg: string, ruleName: string }
|
|
74
|
-
) => RuleDefinition;
|
|
75
|
-
|
|
76
|
-
export type Report = {
|
|
77
|
-
id?: string,
|
|
78
|
-
path?: string[],
|
|
79
|
-
message: string,
|
|
80
|
-
[key: string]: any
|
|
81
|
-
};
|
|
1
|
+
export type {
|
|
2
|
+
ModdleElement,
|
|
3
|
+
Product,
|
|
4
|
+
Reporter,
|
|
5
|
+
Resolver,
|
|
6
|
+
EnterFn,
|
|
7
|
+
LeaveFn,
|
|
8
|
+
CheckDefinition,
|
|
9
|
+
RuleDefinition,
|
|
10
|
+
RuleFactory,
|
|
11
|
+
ReportingCategoryMap,
|
|
12
|
+
ReportingCategoryIndex,
|
|
13
|
+
ReportingCategory,
|
|
14
|
+
RuleErrorCategory,
|
|
15
|
+
RuleConfig,
|
|
16
|
+
RuleConfigs,
|
|
17
|
+
Config,
|
|
18
|
+
TransformRuleFn,
|
|
19
|
+
Report
|
|
20
|
+
} from '@bpmn-io/lint-core/lib/types';
|
package/package.json
CHANGED
|
@@ -1,8 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmnlint",
|
|
3
3
|
"description": "Validate your BPMN diagrams based on configurable lint rules",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "12.0.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js",
|
|
8
|
+
"./lib/index": "./lib/index.js",
|
|
9
|
+
"./lib/index.js": "./lib/index.js",
|
|
10
|
+
"./lib/linter": "./lib/linter.js",
|
|
11
|
+
"./lib/linter.js": "./lib/linter.js",
|
|
12
|
+
"./lib/resolver/helper": "./lib/resolver/helper.js",
|
|
13
|
+
"./lib/resolver/helper.js": "./lib/resolver/helper.js",
|
|
14
|
+
"./lib/resolver/node-resolver": "./lib/resolver/node-resolver.js",
|
|
15
|
+
"./lib/resolver/node-resolver.js": "./lib/resolver/node-resolver.js",
|
|
16
|
+
"./lib/resolver/static-resolver": "./lib/resolver/static-resolver.js",
|
|
17
|
+
"./lib/resolver/static-resolver.js": "./lib/resolver/static-resolver.js",
|
|
18
|
+
"./lib/support/compile-config": "./lib/support/compile-config.js",
|
|
19
|
+
"./lib/support/compile-config.js": "./lib/support/compile-config.js",
|
|
20
|
+
"./lib/test-rule": "./lib/test-rule.js",
|
|
21
|
+
"./lib/test-rule.js": "./lib/test-rule.js",
|
|
22
|
+
"./lib/testers/helper": "./lib/testers/helper.js",
|
|
23
|
+
"./lib/testers/helper.js": "./lib/testers/helper.js",
|
|
24
|
+
"./lib/traverse": "./lib/traverse.js",
|
|
25
|
+
"./lib/traverse.js": "./lib/traverse.js",
|
|
26
|
+
"./bin/bpmnlint": "./bin/bpmnlint.js",
|
|
27
|
+
"./bin/bpmnlint.js": "./bin/bpmnlint.js",
|
|
28
|
+
"./lib/testers/rule-tester": {
|
|
29
|
+
"types": "./lib/testers/rule-tester.d.ts",
|
|
30
|
+
"default": "./lib/testers/rule-tester.js"
|
|
31
|
+
},
|
|
32
|
+
"./lib/testers/rule-tester.js": {
|
|
33
|
+
"types": "./lib/testers/rule-tester.d.ts",
|
|
34
|
+
"default": "./lib/testers/rule-tester.js"
|
|
35
|
+
},
|
|
36
|
+
"./lib/types": {
|
|
37
|
+
"types": "./lib/types.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./rules/*.js": "./rules/*.js",
|
|
40
|
+
"./rules/*": "./rules/*.js",
|
|
41
|
+
"./config/*.js": "./config/*.js",
|
|
42
|
+
"./config/*": "./config/*.js",
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
|
+
},
|
|
6
45
|
"keywords": [
|
|
7
46
|
"bpmnlint",
|
|
8
47
|
"bpmn",
|
|
@@ -23,15 +62,16 @@
|
|
|
23
62
|
}
|
|
24
63
|
],
|
|
25
64
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
65
|
+
"node": ">= 24"
|
|
27
66
|
},
|
|
28
67
|
"license": "MIT",
|
|
29
68
|
"scripts": {
|
|
30
|
-
"all": "run-s lint lint:types test-coverage",
|
|
69
|
+
"all": "run-s lint lint:types test-coverage test:perf",
|
|
31
70
|
"lint": "eslint .",
|
|
32
71
|
"lint:types": "tsc",
|
|
33
72
|
"dev": "npm test -- --watch",
|
|
34
|
-
"test": "mocha --exclude \"test/integration/*/**\" \"test/**/*.*js\"",
|
|
73
|
+
"test": "mocha --exclude \"test/integration/*/**\" --exclude \"test/performance/**\" \"test/**/*.*js\"",
|
|
74
|
+
"test:perf": "mocha \"test/performance/**/*.*js\"",
|
|
35
75
|
"test-coverage": "nyc --reporter=lcov --reporter=html npm test",
|
|
36
76
|
"generate-docs-images": "npx @bpmn-io/bpmnlint-generate-docs-images ."
|
|
37
77
|
},
|
|
@@ -39,16 +79,10 @@
|
|
|
39
79
|
"bpmnlint": "./bin/bpmnlint.js"
|
|
40
80
|
},
|
|
41
81
|
"dependencies": {
|
|
42
|
-
"@bpmn-io/
|
|
43
|
-
"ansi-colors": "^4.1.3",
|
|
82
|
+
"@bpmn-io/lint-core": "^0.1.0",
|
|
44
83
|
"bpmn-moddle": "^10.1.0",
|
|
45
84
|
"bpmnlint-utils": "^1.1.1",
|
|
46
|
-
"
|
|
47
|
-
"color-support": "^1.1.3",
|
|
48
|
-
"min-dash": "^5.1.0",
|
|
49
|
-
"mri": "^1.2.0",
|
|
50
|
-
"pluralize": "^8.0.0",
|
|
51
|
-
"tiny-glob": "^0.2.9"
|
|
85
|
+
"min-dash": "^5.1.0"
|
|
52
86
|
},
|
|
53
87
|
"devDependencies": {
|
|
54
88
|
"@bpmn-io/bpmnlint-generate-docs-images": "^1.2.0",
|
|
@@ -6,6 +6,18 @@ const {
|
|
|
6
6
|
annotateRule
|
|
7
7
|
} = require('./helper');
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @typedef { import('../lib/types.js').ModdleElement } ModdleElement
|
|
11
|
+
*
|
|
12
|
+
* @typedef { {
|
|
13
|
+
* element: ModdleElement,
|
|
14
|
+
* left: number,
|
|
15
|
+
* right: number,
|
|
16
|
+
* top: number,
|
|
17
|
+
* bottom: number
|
|
18
|
+
* } } Shape
|
|
19
|
+
*/
|
|
20
|
+
|
|
9
21
|
|
|
10
22
|
/**
|
|
11
23
|
* Rule that checks if two elements overlap except:
|
|
@@ -99,36 +111,88 @@ function checkProcess(node, elementsToReport, elementsOutsideToReport, diObjects
|
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
/**
|
|
114
|
+
* Check elements for overlap.
|
|
115
|
+
*
|
|
116
|
+
* Sweeps the shapes of the elements from left to right, so that every shape
|
|
117
|
+
* is only compared with the shapes that start before it ends.
|
|
118
|
+
*
|
|
102
119
|
* @param {Array} elements
|
|
103
120
|
* @param {Set} elementsToReport
|
|
121
|
+
* @param {Map} diObjects
|
|
104
122
|
*/
|
|
105
123
|
function checkElementsArray(elements, elementsToReport, diObjects) {
|
|
106
|
-
|
|
107
|
-
const element = elements[i];
|
|
124
|
+
const shapes = getShapes(elements, diObjects).sort((a, b) => a.left - b.left);
|
|
108
125
|
|
|
109
|
-
|
|
110
|
-
const element2 = elements[j];
|
|
126
|
+
const overlapping = new Set();
|
|
111
127
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (element.attachedToRef === element2 || element2.attachedToRef === element) {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
128
|
+
for (let i = 0; i < shapes.length; i++) {
|
|
129
|
+
const shape = shapes[i];
|
|
117
130
|
|
|
118
|
-
|
|
119
|
-
|
|
131
|
+
// shapes starting right of this one cannot overlap it
|
|
132
|
+
for (let j = i + 1; j < shapes.length && shapes[j].left <= shape.right; j++) {
|
|
133
|
+
const otherShape = shapes[j];
|
|
120
134
|
|
|
121
|
-
|
|
122
|
-
if (!bounds1 || !bounds2) {
|
|
135
|
+
if (!isCollision(shape, otherShape)) {
|
|
123
136
|
continue;
|
|
124
137
|
}
|
|
125
138
|
|
|
126
|
-
if
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
// ignore if Boundary events overlap their host
|
|
140
|
+
// but still check if they overlap other elements
|
|
141
|
+
if (shape.element.attachedToRef === otherShape.element || otherShape.element.attachedToRef === shape.element) {
|
|
142
|
+
continue;
|
|
129
143
|
}
|
|
144
|
+
|
|
145
|
+
overlapping.add(shape.element);
|
|
146
|
+
overlapping.add(otherShape.element);
|
|
130
147
|
}
|
|
131
148
|
}
|
|
149
|
+
|
|
150
|
+
// report in element order, independent of the order overlaps are detected
|
|
151
|
+
elements.forEach(element => {
|
|
152
|
+
if (overlapping.has(element)) {
|
|
153
|
+
elementsToReport.add(element);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Get the shapes of all elements with valid bounds, the only elements
|
|
160
|
+
* that can overlap.
|
|
161
|
+
*
|
|
162
|
+
* @param {Array} elements
|
|
163
|
+
* @param {Map} diObjects
|
|
164
|
+
*
|
|
165
|
+
* @return {Shape[]}
|
|
166
|
+
*/
|
|
167
|
+
function getShapes(elements, diObjects) {
|
|
168
|
+
const shapes = [];
|
|
169
|
+
|
|
170
|
+
elements.forEach(element => {
|
|
171
|
+
const bounds = diObjects.get(element)?.bounds;
|
|
172
|
+
|
|
173
|
+
if (!isValidShapeElement(bounds)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const left = bounds.x;
|
|
178
|
+
const right = bounds.x + bounds.width;
|
|
179
|
+
|
|
180
|
+
// shapes with a NaN left or right edge never collide,
|
|
181
|
+
// and a NaN left edge would break the sweep
|
|
182
|
+
if (Number.isNaN(left) || Number.isNaN(right)) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
shapes.push({
|
|
187
|
+
element,
|
|
188
|
+
left,
|
|
189
|
+
right,
|
|
190
|
+
top: bounds.y,
|
|
191
|
+
bottom: bounds.y + bounds.height
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return shapes;
|
|
132
196
|
}
|
|
133
197
|
|
|
134
198
|
/**
|
|
@@ -148,14 +212,15 @@ function isOutsideParentBoundary(childBounds, parentBounds) {
|
|
|
148
212
|
|
|
149
213
|
/**
|
|
150
214
|
* Check if two rectangle shapes collides
|
|
215
|
+
*
|
|
216
|
+
* @param {Shape} firstShape
|
|
217
|
+
* @param {Shape} secondShape
|
|
218
|
+
*
|
|
219
|
+
* @return {boolean}
|
|
151
220
|
*/
|
|
152
|
-
function isCollision(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const collisionX = firstBounds.x + firstBounds.width >= secondBounds.x && secondBounds.x + secondBounds.width >= firstBounds.x;
|
|
158
|
-
const collisionY = firstBounds.y + firstBounds.height >= secondBounds.y && secondBounds.y + secondBounds.height >= firstBounds.y;
|
|
221
|
+
function isCollision(firstShape, secondShape) {
|
|
222
|
+
const collisionX = firstShape.right >= secondShape.left && secondShape.right >= firstShape.left;
|
|
223
|
+
const collisionY = firstShape.bottom >= secondShape.top && secondShape.bottom >= firstShape.top;
|
|
159
224
|
|
|
160
225
|
// collision on both axis
|
|
161
226
|
return collisionX && collisionY;
|