@camunda/linting 3.10.0 → 3.11.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/lib/Linter.js CHANGED
@@ -1,174 +1,200 @@
1
- import BpmnModdle from 'bpmn-moddle';
2
-
3
- import { Linter as BpmnLinter } from 'bpmnlint';
4
- import StaticResolver from 'bpmnlint/lib/resolver/static-resolver';
5
-
6
- import Resolver from './Resolver';
7
-
8
- import { isString } from 'min-dash';
9
-
10
- import { resolver as RulesResolver } from './compiled-config';
11
-
12
- import modelerModdle from 'modeler-moddle/resources/modeler.json';
13
- import zeebeModdle from 'zeebe-bpmn-moddle/resources/zeebe.json';
14
- import camundaModdle from 'camunda-bpmn-moddle/resources/camunda.json';
15
-
16
- import { getErrorMessage } from './utils/error-messages';
17
- import { getEntryIds } from './utils/properties-panel';
18
-
19
- import { toSemverMinor } from './utils/version';
20
-
21
- import { getDocumentationUrl } from './utils/documentation';
22
-
23
- /**
24
- * @param {Object} [options]
25
- * @param {string} [options.modeler='desktop']
26
- * @param {Array<Object>} [options.plugins=[]]
27
- * @param {string} [options.type='cloud']
28
- */
29
- export class Linter {
30
- constructor(options = {}) {
31
- const {
32
- modeler = 'desktop',
33
- plugins = [],
34
- type = 'cloud'
35
- } = options;
36
-
37
- this._moddle = new BpmnModdle({
38
- modeler: modelerModdle,
39
-
40
- // Zeebe and Camunda moddle extensions can't be used together
41
- // cf. https://github.com/camunda/camunda-modeler/issues/3853#issuecomment-1731145100
42
- ...(type === 'cloud' ?
43
- { zeebe: zeebeModdle } :
44
- { camunda: camundaModdle })
45
- });
46
-
47
- this._modeler = modeler;
48
- this._plugins = plugins;
49
- }
50
-
51
- async lint(contents) {
52
- let rootElement;
53
-
54
- if (isString(contents)) {
55
- ({ rootElement } = await this._moddle.fromXML(contents));
56
- } else {
57
- rootElement = contents;
58
- }
59
-
60
- const executionPlatform = rootElement.get('modeler:executionPlatform'),
61
- executionPlatformVersion = rootElement.get('modeler:executionPlatformVersion');
62
-
63
- if (!executionPlatform || !executionPlatformVersion) {
64
- return [];
65
- }
66
-
67
- const configName = getConfigName(executionPlatform, executionPlatformVersion);
68
-
69
- const config = this._createConfig(configName);
70
-
71
- const resolver = await this._createResolver(configName);
72
-
73
- const linter = new BpmnLinter({
74
- config,
75
- resolver
76
- });
77
-
78
- const reportsByRule = await linter.lint(rootElement);
79
-
80
- return Object.entries(reportsByRule).reduce((allReports, entry) => {
81
- const [ rule, reports ] = entry;
82
-
83
- return [
84
- ...allReports,
85
- ...reports.map(report => {
86
- const entryIds = getEntryIds(report);
87
-
88
- return {
89
- ...report,
90
- executionPlatform,
91
- executionPlatformVersion,
92
- message: getErrorMessage(
93
- report,
94
- executionPlatform,
95
- executionPlatformVersion,
96
- this._modeler
97
- ),
98
- propertiesPanel: {
99
- entryIds
100
- },
101
- documentation: {
102
- url: getDocumentationUrl(rule)
103
- },
104
- rule
105
- };
106
- })
107
- ];
108
- }, []);
109
- }
110
-
111
- _createConfig(configName) {
112
- const configs = [
113
- {
114
- extends: `plugin:bpmnlint-plugin-camunda-compat/${ configName }`
115
- },
116
- ...this._plugins.map(({ config }) => config)
117
- ];
118
-
119
- return configs.reduce(
120
- (config, _config) => {
121
- let { extends: _extends = [], rules = {} } = _config;
122
-
123
- if (isString(_extends)) {
124
- _extends = [ _extends ];
125
- }
126
-
127
- return {
128
- extends: [ ...config.extends, ..._extends ],
129
- rules: {
130
- ...config.rules,
131
- ...rules
132
- }
133
- };
134
- },
135
- {
136
- extends: [],
137
- rules: {}
138
- }
139
- );
140
- }
141
-
142
- async _createResolver(configName) {
143
- const { configs } = await import('bpmnlint-plugin-camunda-compat');
144
-
145
- let { [ configName ]: config } = configs;
146
-
147
- if (!config) {
148
- config = {
149
- rules: {}
150
- };
151
- }
152
-
153
- const ConfigResolver = new StaticResolver({
154
- [ `config:bpmnlint-plugin-camunda-compat/${ configName }` ]: config
155
- });
156
-
157
- return new Resolver([
158
- ConfigResolver,
159
- RulesResolver,
160
- ...this._plugins.map(({ resolver }) => resolver)
161
- ]);
162
- }
163
- }
164
-
165
- function getConfigName(executionPlatform, executionPlatformVersion) {
166
- return [
167
- ...executionPlatform.split(' ').map(toLowerCase),
168
- ...toSemverMinor(executionPlatformVersion).split('.')
169
- ].join('-');
170
- }
171
-
172
- function toLowerCase(string) {
173
- return string.toLowerCase();
1
+ import BpmnModdle from 'bpmn-moddle';
2
+
3
+ import { Linter as BpmnLinter } from 'bpmnlint';
4
+ import StaticResolver from 'bpmnlint/lib/resolver/static-resolver';
5
+
6
+ import Resolver from './Resolver';
7
+
8
+ import { isString } from 'min-dash';
9
+
10
+ import { resolver as RulesResolver } from './compiled-config';
11
+
12
+ import modelerModdle from 'modeler-moddle/resources/modeler.json';
13
+ import zeebeModdle from 'zeebe-bpmn-moddle/resources/zeebe.json';
14
+ import camundaModdle from 'camunda-bpmn-moddle/resources/camunda.json';
15
+
16
+ import { getErrorMessage } from './utils/error-messages';
17
+ import { getEntryIds } from './utils/properties-panel';
18
+
19
+ import { toSemverMinor } from './utils/version';
20
+
21
+ import { getDocumentationUrl } from './utils/documentation';
22
+
23
+ const NoopResolver = new StaticResolver({});
24
+
25
+ /**
26
+ * @param {Object} [options]
27
+ * @param {string} [options.modeler='desktop']
28
+ * @param {Array<Object>} [options.plugins=[]]
29
+ * @param {string} [options.type='cloud']
30
+ */
31
+ export class Linter {
32
+ constructor(options = {}) {
33
+ const {
34
+ modeler = 'desktop',
35
+ plugins = [],
36
+ type = 'cloud'
37
+ } = options;
38
+
39
+ this._moddle = new BpmnModdle({
40
+ modeler: modelerModdle,
41
+
42
+ // Zeebe and Camunda moddle extensions can't be used together
43
+ // cf. https://github.com/camunda/camunda-modeler/issues/3853#issuecomment-1731145100
44
+ ...(type === 'cloud' ?
45
+ { zeebe: zeebeModdle } :
46
+ { camunda: camundaModdle })
47
+ });
48
+
49
+ this._modeler = modeler;
50
+ this._plugins = plugins;
51
+ }
52
+
53
+ async lint(contents) {
54
+ let rootElement;
55
+
56
+ if (isString(contents)) {
57
+ ({ rootElement } = await this._moddle.fromXML(contents));
58
+ } else {
59
+ rootElement = contents;
60
+ }
61
+
62
+ const executionPlatform = rootElement.get('modeler:executionPlatform'),
63
+ executionPlatformVersion = rootElement.get('modeler:executionPlatformVersion');
64
+
65
+ if (!executionPlatform || !executionPlatformVersion) {
66
+ return [];
67
+ }
68
+
69
+ const configName = getConfigName(executionPlatform, executionPlatformVersion);
70
+
71
+ const config = this._createConfig(configName);
72
+
73
+ const resolver = await this._createResolver(configName);
74
+
75
+ const linter = new BpmnLinter({
76
+ config,
77
+ resolver
78
+ });
79
+
80
+ const reportsByRule = await linter.lint(rootElement);
81
+
82
+ return Object.entries(reportsByRule).reduce((allReports, entry) => {
83
+ const [ rule, reports ] = entry;
84
+
85
+ return [
86
+ ...allReports,
87
+ ...reports.map(report => {
88
+ const entryIds = getEntryIds(report);
89
+
90
+ return {
91
+ ...report,
92
+ executionPlatform,
93
+ executionPlatformVersion,
94
+ message: getErrorMessage(
95
+ report,
96
+ executionPlatform,
97
+ executionPlatformVersion,
98
+ this._modeler
99
+ ),
100
+ propertiesPanel: {
101
+ entryIds
102
+ },
103
+ documentation: {
104
+ url: getDocumentationUrl(rule)
105
+ },
106
+ rule
107
+ };
108
+ })
109
+ ];
110
+ }, []);
111
+ }
112
+
113
+ _createConfig(configName) {
114
+ const configs = [
115
+ {
116
+ extends: `plugin:bpmnlint-plugin-camunda-compat/${ configName }`
117
+ },
118
+ ...this._plugins.map(({ config = {} }) => config)
119
+ ];
120
+
121
+ return configs.reduce(
122
+ (config, _config) => {
123
+ let { extends: _extends = [], rules = {} } = _config;
124
+
125
+ if (isString(_extends)) {
126
+ _extends = [ _extends ];
127
+ }
128
+
129
+ return {
130
+ extends: [ ...config.extends, ..._extends ],
131
+ rules: {
132
+ ...config.rules,
133
+ ...rules
134
+ }
135
+ };
136
+ },
137
+ {
138
+ extends: [],
139
+ rules: {}
140
+ }
141
+ );
142
+ }
143
+
144
+ async _createResolver(configName) {
145
+ const { configs } = await import('bpmnlint-plugin-camunda-compat');
146
+
147
+ let { [ configName ]: config } = configs;
148
+
149
+ if (!config) {
150
+ config = {
151
+ rules: {}
152
+ };
153
+ }
154
+
155
+ config.rules = addConfig(config.rules, {
156
+ modeler: this._modeler
157
+ });
158
+
159
+ const ConfigResolver = new StaticResolver({
160
+ [ `config:bpmnlint-plugin-camunda-compat/${ configName }` ]: config
161
+ });
162
+
163
+ return new Resolver([
164
+ ConfigResolver,
165
+ RulesResolver,
166
+ ...this._plugins.map(({ resolver = NoopResolver }) => resolver)
167
+ ]);
168
+ }
169
+ }
170
+
171
+ function getConfigName(executionPlatform, executionPlatformVersion) {
172
+ return [
173
+ ...executionPlatform.split(' ').map(toLowerCase),
174
+ ...toSemverMinor(executionPlatformVersion).split('.')
175
+ ].join('-');
176
+ }
177
+
178
+ function toLowerCase(string) {
179
+ return string.toLowerCase();
180
+ }
181
+
182
+ function addConfig(rules, configToAdd) {
183
+ let rulesWithConfig = {};
184
+
185
+ for (let name in rules) {
186
+ let type, config;
187
+
188
+ if (Array.isArray(rules[ name ])) {
189
+ type = rules[ name ][0];
190
+ config = rules[ name ][1] || {};
191
+ } else {
192
+ type = rules[ name ];
193
+ config = {};
194
+ }
195
+
196
+ rulesWithConfig[ name ] = [ type, { ...config, ...configToAdd } ];
197
+ }
198
+
199
+ return rulesWithConfig;
174
200
  }
@@ -57,7 +57,7 @@ const rules = {
57
57
  "camunda-compat/secrets": "error",
58
58
  "camunda-compat/sequence-flow-condition": "error",
59
59
  "camunda-compat/signal-reference": "error",
60
- "camunda-compat/start-form": "error",
60
+ "camunda-compat/start-event-form": "error",
61
61
  "camunda-compat/subscription": "error",
62
62
  "camunda-compat/task-schedule": "error",
63
63
  "camunda-compat/timer": "error",
@@ -189,9 +189,9 @@ import rule_27 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/signal-r
189
189
 
190
190
  cache['bpmnlint-plugin-camunda-compat/signal-reference'] = rule_27;
191
191
 
192
- import rule_28 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/start-form';
192
+ import rule_28 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/start-event-form';
193
193
 
194
- cache['bpmnlint-plugin-camunda-compat/start-form'] = rule_28;
194
+ cache['bpmnlint-plugin-camunda-compat/start-event-form'] = rule_28;
195
195
 
196
196
  import rule_29 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/subscription';
197
197
 
package/package.json CHANGED
@@ -1,84 +1,84 @@
1
- {
2
- "name": "@camunda/linting",
3
- "version": "3.10.0",
4
- "description": "Linting for Camunda",
5
- "main": "index.js",
6
- "scripts": {
7
- "all": "npm run lint && npm test",
8
- "dev": "npm run test:watch",
9
- "lint": "eslint .",
10
- "start": "npm run start:cloud",
11
- "start:platform": "cross-env SINGLE_START=platform npm run test:watch",
12
- "start:cloud": "cross-env SINGLE_START=cloud npm run test:watch",
13
- "test": "npm run compile-config && karma start",
14
- "test:watch": "npm test -- --auto-watch --no-single-run",
15
- "compile-config": "node tasks/compile-config.js",
16
- "prepublish": "npm run compile-config"
17
- },
18
- "keywords": [
19
- "bpmnlint",
20
- "camunda"
21
- ],
22
- "author": {
23
- "name": "Philipp Fromme",
24
- "url": "https://github.com/philippfromme"
25
- },
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/camunda/linting"
29
- },
30
- "license": "MIT",
31
- "dependencies": {
32
- "@bpmn-io/diagram-js-ui": "^0.2.2",
33
- "bpmn-moddle": "^8.0.0",
34
- "bpmnlint": "^9.2.0",
35
- "bpmnlint-plugin-camunda-compat": "^2.11.1",
36
- "bpmnlint-utils": "^1.0.2",
37
- "camunda-bpmn-moddle": "^7.0.1",
38
- "clsx": "^2.0.0",
39
- "min-dash": "^4.0.0",
40
- "min-dom": "^4.1.0",
41
- "modeler-moddle": "^0.2.0",
42
- "semver-compare": "^1.0.0",
43
- "zeebe-bpmn-moddle": "^1.0.0"
44
- },
45
- "devDependencies": {
46
- "bpmn-js": "^13.2.2",
47
- "bpmn-js-element-templates": "^1.3.0",
48
- "bpmn-js-properties-panel": "^5.6.1",
49
- "camunda-bpmn-js-behaviors": "^1.2.2",
50
- "chai": "^4.3.7",
51
- "cross-env": "^7.0.3",
52
- "eslint": "^8.45.0",
53
- "eslint-plugin-bpmn-io": "^1.0.0",
54
- "karma": "^6.4.2",
55
- "karma-chrome-launcher": "^3.2.0",
56
- "karma-debug-launcher": "0.0.5",
57
- "karma-env-preprocessor": "^0.1.1",
58
- "karma-mocha": "^2.0.1",
59
- "karma-sinon-chai": "^2.0.2",
60
- "karma-webpack": "^5.0.0",
61
- "mocha": "^10.2.0",
62
- "mocha-test-container-support": "^0.2.0",
63
- "puppeteer": "^20.9.0",
64
- "sinon": "^15.0.1",
65
- "sinon-chai": "^3.7.0",
66
- "webpack": "^5.75.0"
67
- },
68
- "peerDependencies": {
69
- "bpmn-js-properties-panel": ">= 2.0.0"
70
- },
71
- "peerDependenciesMeta": {
72
- "bpmn-js-properties-panel": {
73
- "optional": true
74
- }
75
- },
76
- "files": [
77
- "assets",
78
- "lib",
79
- "modeler.js"
80
- ],
81
- "publishConfig": {
82
- "access": "public"
83
- }
84
- }
1
+ {
2
+ "name": "@camunda/linting",
3
+ "version": "3.11.0",
4
+ "description": "Linting for Camunda",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "all": "npm run lint && npm test",
8
+ "dev": "npm run test:watch",
9
+ "lint": "eslint .",
10
+ "start": "npm run start:cloud",
11
+ "start:platform": "cross-env SINGLE_START=platform npm run test:watch",
12
+ "start:cloud": "cross-env SINGLE_START=cloud npm run test:watch",
13
+ "test": "npm run compile-config && karma start",
14
+ "test:watch": "npm test -- --auto-watch --no-single-run",
15
+ "compile-config": "node tasks/compile-config.js",
16
+ "prepublish": "npm run compile-config"
17
+ },
18
+ "keywords": [
19
+ "bpmnlint",
20
+ "camunda"
21
+ ],
22
+ "author": {
23
+ "name": "Philipp Fromme",
24
+ "url": "https://github.com/philippfromme"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/camunda/linting"
29
+ },
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "@bpmn-io/diagram-js-ui": "^0.2.2",
33
+ "bpmn-moddle": "^8.0.0",
34
+ "bpmnlint": "^9.2.0",
35
+ "bpmnlint-plugin-camunda-compat": "^2.12.0",
36
+ "bpmnlint-utils": "^1.0.2",
37
+ "camunda-bpmn-moddle": "^7.0.1",
38
+ "clsx": "^2.0.0",
39
+ "min-dash": "^4.0.0",
40
+ "min-dom": "^4.1.0",
41
+ "modeler-moddle": "^0.2.0",
42
+ "semver-compare": "^1.0.0",
43
+ "zeebe-bpmn-moddle": "^1.0.0"
44
+ },
45
+ "devDependencies": {
46
+ "bpmn-js": "^13.2.2",
47
+ "bpmn-js-element-templates": "^1.3.0",
48
+ "bpmn-js-properties-panel": "^5.6.1",
49
+ "camunda-bpmn-js-behaviors": "^1.2.2",
50
+ "chai": "^4.3.7",
51
+ "cross-env": "^7.0.3",
52
+ "eslint": "^8.45.0",
53
+ "eslint-plugin-bpmn-io": "^1.0.0",
54
+ "karma": "^6.4.2",
55
+ "karma-chrome-launcher": "^3.2.0",
56
+ "karma-debug-launcher": "0.0.5",
57
+ "karma-env-preprocessor": "^0.1.1",
58
+ "karma-mocha": "^2.0.1",
59
+ "karma-sinon-chai": "^2.0.2",
60
+ "karma-webpack": "^5.0.0",
61
+ "mocha": "^10.2.0",
62
+ "mocha-test-container-support": "^0.2.0",
63
+ "puppeteer": "^20.9.0",
64
+ "sinon": "^15.0.1",
65
+ "sinon-chai": "^3.7.0",
66
+ "webpack": "^5.75.0"
67
+ },
68
+ "peerDependencies": {
69
+ "bpmn-js-properties-panel": ">= 2.0.0"
70
+ },
71
+ "peerDependenciesMeta": {
72
+ "bpmn-js-properties-panel": {
73
+ "optional": true
74
+ }
75
+ },
76
+ "files": [
77
+ "assets",
78
+ "lib",
79
+ "modeler.js"
80
+ ],
81
+ "publishConfig": {
82
+ "access": "public"
83
+ }
84
+ }