@camunda/linting 3.41.0 → 3.43.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.
@@ -1,96 +1,96 @@
1
- import { groupBy } from 'min-dash';
2
-
3
- import { domify } from 'min-dom';
4
-
5
- import { renderOverlay } from './OverlayComponent';
6
- import { is } from 'bpmn-js/lib/util/ModelUtil';
7
-
8
-
9
- export default class LintingAnnotations {
10
- constructor(canvas, elementRegistry, eventBus, overlays) {
11
- this._canvas = canvas;
12
- this._elementRegistry = elementRegistry;
13
- this._eventBus = eventBus;
14
- this._overlays = overlays;
15
-
16
- this._reportsByElement = {};
17
-
18
- this._overlayIds = {};
19
- }
20
-
21
- setErrors(reports) {
22
- this._reportsByElement = groupBy(reports.filter(report => report.category !== 'rule-error'), 'id');
23
-
24
- this._update();
25
- }
26
-
27
- _update(reportsByElement) {
28
- if (!reportsByElement) {
29
- reportsByElement = this._reportsByElement;
30
- }
31
-
32
- this._overlays.remove({ type: 'linting' });
33
-
34
- Object.entries(reportsByElement).forEach(([ id, reports ]) => {
35
- const element = this._elementRegistry.get(id);
36
-
37
- if (!element || element === this._canvas.getRootElement()) {
38
- return;
39
- }
40
-
41
- const html = domify(`
42
- <div class="cl-overlay-root"></div>
43
- `);
44
-
45
- renderOverlay(html, {
46
- reports,
47
- onClick: () => {
48
- this._eventBus.fire('lintingAnnotations.click', { report: reports[ 0 ] });
49
- }
50
- });
51
-
52
- const position = getAnnotationPosition(element);
53
-
54
- const overlayId = this._overlays.add(element, 'linting', {
55
- position,
56
- html,
57
- scale: {
58
- min: .7
59
- }
60
- });
61
-
62
- this._overlayIds[ id ] = overlayId;
63
- });
64
- }
65
- }
66
-
67
- LintingAnnotations.$inject = [
68
- 'canvas',
69
- 'elementRegistry',
70
- 'eventBus',
71
- 'overlays'
72
- ];
73
-
74
-
75
- function getAnnotationPosition(element) {
76
-
77
- if (!element.parent) {
78
-
79
- if (is(element, 'bpmn:SubProcess')) {
80
- return {
81
- top: 50,
82
- left: 150
83
- };
84
- }
85
-
86
- return {
87
- top: 20,
88
- left: 150
89
- };
90
- }
91
-
92
- return {
93
- bottom: 14,
94
- left: -6
95
- };
1
+ import { groupBy } from 'min-dash';
2
+
3
+ import { domify } from 'min-dom';
4
+
5
+ import { renderOverlay } from './OverlayComponent';
6
+ import { is } from 'bpmn-js/lib/util/ModelUtil';
7
+
8
+
9
+ export default class LintingAnnotations {
10
+ constructor(canvas, elementRegistry, eventBus, overlays) {
11
+ this._canvas = canvas;
12
+ this._elementRegistry = elementRegistry;
13
+ this._eventBus = eventBus;
14
+ this._overlays = overlays;
15
+
16
+ this._reportsByElement = {};
17
+
18
+ this._overlayIds = {};
19
+ }
20
+
21
+ setErrors(reports) {
22
+ this._reportsByElement = groupBy(reports.filter(report => report.category !== 'rule-error'), 'id');
23
+
24
+ this._update();
25
+ }
26
+
27
+ _update(reportsByElement) {
28
+ if (!reportsByElement) {
29
+ reportsByElement = this._reportsByElement;
30
+ }
31
+
32
+ this._overlays.remove({ type: 'linting' });
33
+
34
+ Object.entries(reportsByElement).forEach(([ id, reports ]) => {
35
+ const element = this._elementRegistry.get(id);
36
+
37
+ if (!element || element === this._canvas.getRootElement()) {
38
+ return;
39
+ }
40
+
41
+ const html = domify(`
42
+ <div class="cl-overlay-root"></div>
43
+ `);
44
+
45
+ renderOverlay(html, {
46
+ reports,
47
+ onClick: () => {
48
+ this._eventBus.fire('lintingAnnotations.click', { report: reports[ 0 ] });
49
+ }
50
+ });
51
+
52
+ const position = getAnnotationPosition(element);
53
+
54
+ const overlayId = this._overlays.add(element, 'linting', {
55
+ position,
56
+ html,
57
+ scale: {
58
+ min: .7
59
+ }
60
+ });
61
+
62
+ this._overlayIds[ id ] = overlayId;
63
+ });
64
+ }
65
+ }
66
+
67
+ LintingAnnotations.$inject = [
68
+ 'canvas',
69
+ 'elementRegistry',
70
+ 'eventBus',
71
+ 'overlays'
72
+ ];
73
+
74
+
75
+ function getAnnotationPosition(element) {
76
+
77
+ if (!element.parent) {
78
+
79
+ if (is(element, 'bpmn:SubProcess')) {
80
+ return {
81
+ top: 50,
82
+ left: 150
83
+ };
84
+ }
85
+
86
+ return {
87
+ top: 20,
88
+ left: 150
89
+ };
90
+ }
91
+
92
+ return {
93
+ bottom: 14,
94
+ left: -6
95
+ };
96
96
  }
@@ -1,61 +1,61 @@
1
- import {
2
- render as renderComponent,
3
- html
4
- } from '@bpmn-io/diagram-js-ui';
5
-
6
- import classNames from 'clsx';
7
-
8
- const errorSvg = html`
9
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
10
- <path d="M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M21.4,23L16,17.6L10.6,23L9,21.4l5.4-5.4L9,10.6L10.6,9
11
- l5.4,5.4L21.4,9l1.6,1.6L17.6,16l5.4,5.4L21.4,23z" fill="currentColor" />
12
- </svg>
13
- `;
14
-
15
- const warningSvg = html`
16
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
17
- <path d="M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14C30,8.3,23.7,2,16,2z M14.9,8h2.2v11h-2.2V8z M16,25
18
- c-0.8,0-1.5-0.7-1.5-1.5S15.2,22,16,22c0.8,0,1.5,0.7,1.5,1.5S16.8,25,16,25z" fill="currentColor" />
19
- </svg>
20
- `;
21
-
22
- const infoSvg = html`
23
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
24
- <path d="M16,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,6a1.5,1.5,0,1,1-1.5,1.5A1.5,1.5,0,0,1,16,8Zm4,16.125H12v-2.25h2.875v-5.75H13v-2.25h4.125v8H20Z" fill="currentColor" />
25
- </svg>
26
- `;
27
-
28
- const icons = {
29
- error: errorSvg,
30
- warn: warningSvg,
31
- info: infoSvg
32
- };
33
-
34
- export function OverlayComponent(props) {
35
-
36
- const {
37
- onClick = () => {},
38
- reports
39
- } = props;
40
-
41
- const category =
42
- reports.find(({ category }) => category === 'error')
43
- ? 'error'
44
- : reports.find(({ category }) => category === 'warn')
45
- ? 'warn'
46
- : 'info';
47
-
48
- return html`
49
- <div
50
- class=${ classNames('cl-icon',`cl-icon-${category}`) }
51
- onClick=${ onClick }
52
- title="Click to show issue"
53
- >
54
- ${ icons[category] }
55
- </div>
56
- `;
57
- }
58
-
59
- export function renderOverlay(el, props) {
60
- return renderComponent(html`<${OverlayComponent} ...${props} />`, el);
1
+ import {
2
+ render as renderComponent,
3
+ html
4
+ } from '@bpmn-io/diagram-js-ui';
5
+
6
+ import classNames from 'clsx';
7
+
8
+ const errorSvg = html`
9
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
10
+ <path d="M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M21.4,23L16,17.6L10.6,23L9,21.4l5.4-5.4L9,10.6L10.6,9
11
+ l5.4,5.4L21.4,9l1.6,1.6L17.6,16l5.4,5.4L21.4,23z" fill="currentColor" />
12
+ </svg>
13
+ `;
14
+
15
+ const warningSvg = html`
16
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
17
+ <path d="M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14C30,8.3,23.7,2,16,2z M14.9,8h2.2v11h-2.2V8z M16,25
18
+ c-0.8,0-1.5-0.7-1.5-1.5S15.2,22,16,22c0.8,0,1.5,0.7,1.5,1.5S16.8,25,16,25z" fill="currentColor" />
19
+ </svg>
20
+ `;
21
+
22
+ const infoSvg = html`
23
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
24
+ <path d="M16,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,6a1.5,1.5,0,1,1-1.5,1.5A1.5,1.5,0,0,1,16,8Zm4,16.125H12v-2.25h2.875v-5.75H13v-2.25h4.125v8H20Z" fill="currentColor" />
25
+ </svg>
26
+ `;
27
+
28
+ const icons = {
29
+ error: errorSvg,
30
+ warn: warningSvg,
31
+ info: infoSvg
32
+ };
33
+
34
+ export function OverlayComponent(props) {
35
+
36
+ const {
37
+ onClick = () => {},
38
+ reports
39
+ } = props;
40
+
41
+ const category =
42
+ reports.find(({ category }) => category === 'error')
43
+ ? 'error'
44
+ : reports.find(({ category }) => category === 'warn')
45
+ ? 'warn'
46
+ : 'info';
47
+
48
+ return html`
49
+ <div
50
+ class=${ classNames('cl-icon',`cl-icon-${category}`) }
51
+ onClick=${ onClick }
52
+ title="Click to show issue"
53
+ >
54
+ ${ icons[category] }
55
+ </div>
56
+ `;
57
+ }
58
+
59
+ export function renderOverlay(el, props) {
60
+ return renderComponent(html`<${OverlayComponent} ...${props} />`, el);
61
61
  }
@@ -1,11 +1,11 @@
1
- import Linting from './Linting';
2
- import LintingAnnotations from './LintingAnnotations';
3
-
4
- export default {
5
- __init__: [
6
- 'linting',
7
- 'lintingAnnotations'
8
- ],
9
- linting: [ 'type', Linting ],
10
- lintingAnnotations: [ 'type', LintingAnnotations ]
1
+ import Linting from './Linting';
2
+ import LintingAnnotations from './LintingAnnotations';
3
+
4
+ export default {
5
+ __init__: [
6
+ 'linting',
7
+ 'lintingAnnotations'
8
+ ],
9
+ linting: [ 'type', Linting ],
10
+ lintingAnnotations: [ 'type', LintingAnnotations ]
11
11
  };
@@ -1,11 +1,11 @@
1
- import StaticResolver from 'bpmnlint/lib/resolver/static-resolver';
2
- import rule from 'bpmnlint/rules/no-bpmndi';
3
-
4
- export default {
5
- config: {
6
- rules: {
7
- 'bpmnlint/no-bpmndi': 'warn'
8
- }
9
- },
10
- resolver: new StaticResolver({ 'rule:bpmnlint/no-bpmndi': rule })
1
+ import StaticResolver from 'bpmnlint/lib/resolver/static-resolver';
2
+ import rule from 'bpmnlint/rules/no-bpmndi';
3
+
4
+ export default {
5
+ config: {
6
+ rules: {
7
+ 'bpmnlint/no-bpmndi': 'warn'
8
+ }
9
+ },
10
+ resolver: new StaticResolver({ 'rule:bpmnlint/no-bpmndi': rule })
11
11
  };
@@ -1,5 +1,5 @@
1
- import bpmnLintPlugin from './bpmnLintPlugin';
2
-
3
- export default [
4
- bpmnLintPlugin
1
+ import bpmnLintPlugin from './bpmnLintPlugin';
2
+
3
+ export default [
4
+ bpmnLintPlugin
5
5
  ];