@camunda/linting 0.16.0 → 1.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.
@@ -43,7 +43,7 @@ export function getExecutionPlatformLabel(executionPlatform, executionPlatformVe
43
43
  return `${ executionPlatform } ${ toSemverMinor(executionPlatformVersion) }`;
44
44
  }
45
45
 
46
- function getIndefiniteArticle(type) {
46
+ function getIndefiniteArticle(type, uppercase = true) {
47
47
  if ([
48
48
  'Ad',
49
49
  'Error',
@@ -53,10 +53,10 @@ function getIndefiniteArticle(type) {
53
53
  'Intermediate',
54
54
  'Undefined'
55
55
  ].includes(type.split(' ')[ 0 ])) {
56
- return 'An';
56
+ return uppercase ? 'An' : 'an';
57
57
  }
58
58
 
59
- return 'A';
59
+ return uppercase ? 'A' : 'a';
60
60
  }
61
61
 
62
62
  export function getErrorMessage(report, executionPlatform, executionPlatformVersion, modeler = 'desktop') {
@@ -71,6 +71,10 @@ export function getErrorMessage(report, executionPlatform, executionPlatformVers
71
71
 
72
72
  const { type } = data;
73
73
 
74
+ if (type === ERROR_TYPES.CHILD_ELEMENT_TYPE_NOT_ALLOWED) {
75
+ return getChildElementTypeNotAllowedErrorMessage(report, executionPlatform, executionPlatformVersion);
76
+ }
77
+
74
78
  if (type === ERROR_TYPES.ELEMENT_COLLAPSED_NOT_ALLOWED) {
75
79
  return getElementCollapsedNotAllowedErrorMessage(report);
76
80
  }
@@ -87,8 +91,8 @@ export function getErrorMessage(report, executionPlatform, executionPlatformVers
87
91
  return getExtensionElementRequiredErrorMessage(report);
88
92
  }
89
93
 
90
- if (type === ERROR_TYPES.PROPERTY_DEPENDEND_REQUIRED) {
91
- return getPropertyDependendRequiredErrorMessage(report);
94
+ if (type === ERROR_TYPES.PROPERTY_DEPENDENT_REQUIRED) {
95
+ return getPropertyDependentRequiredErrorMessage(report);
92
96
  }
93
97
 
94
98
  if (type === ERROR_TYPES.PROPERTY_NOT_ALLOWED) {
@@ -122,6 +126,26 @@ export function getErrorMessage(report, executionPlatform, executionPlatformVers
122
126
  return message;
123
127
  }
124
128
 
129
+ function getChildElementTypeNotAllowedErrorMessage(report, executionPlatform, executionPlatformVersion) {
130
+ const { data } = report;
131
+
132
+ const {
133
+ allowedVersion,
134
+ node,
135
+ parent
136
+ } = data;
137
+
138
+ const typeString = getTypeString(node),
139
+ parentTypeString = getTypeString(parent);
140
+
141
+ return getSupportedMessage(
142
+ `${ getIndefiniteArticle(typeString) } <${ typeString }> in ${ getIndefiniteArticle(parentTypeString, false) } <${ parentTypeString }>`,
143
+ executionPlatform,
144
+ executionPlatformVersion,
145
+ allowedVersion
146
+ );
147
+ }
148
+
125
149
  function getElementCollapsedNotAllowedErrorMessage(report) {
126
150
  const {
127
151
  data,
@@ -224,6 +248,10 @@ function getExtensionElementNotAllowedErrorMessage(report, executionPlatform, ex
224
248
  return getSupportedMessage('A <Script Task> with <Implementation: FEEL expression>', executionPlatform, executionPlatformVersion, allowedVersion);
225
249
  }
226
250
 
251
+ if (is(node, 'bpmn:UserTask') && is(extensionElement, 'zeebe:TaskSchedule')) {
252
+ return getSupportedMessage('A <User Task> with <Due date> or <Follow up date>', executionPlatform, executionPlatformVersion, allowedVersion);
253
+ }
254
+
227
255
  return message;
228
256
  }
229
257
 
@@ -268,7 +296,7 @@ function getExtensionElementRequiredErrorMessage(report) {
268
296
  return message;
269
297
  }
270
298
 
271
- function getPropertyDependendRequiredErrorMessage(report) {
299
+ function getPropertyDependentRequiredErrorMessage(report) {
272
300
  const {
273
301
  data,
274
302
  message
@@ -278,16 +306,16 @@ function getPropertyDependendRequiredErrorMessage(report) {
278
306
  node,
279
307
  parentNode,
280
308
  property,
281
- dependendRequiredProperty
309
+ dependentRequiredProperty
282
310
  } = data;
283
311
 
284
312
  const typeString = getTypeString(parentNode || node);
285
313
 
286
- if (is(node, 'zeebe:LoopCharacteristics') && property === 'outputCollection' && dependendRequiredProperty === 'outputElement') {
314
+ if (is(node, 'zeebe:LoopCharacteristics') && property === 'outputCollection' && dependentRequiredProperty === 'outputElement') {
287
315
  return `${ getIndefiniteArticle(typeString) } <${ typeString }> with <Multi-instance marker> and defined <Output collection> must have a defined <Output element>`;
288
316
  }
289
317
 
290
- if (is(node, 'zeebe:LoopCharacteristics') && property === 'outputElement' && dependendRequiredProperty === 'outputCollection') {
318
+ if (is(node, 'zeebe:LoopCharacteristics') && property === 'outputElement' && dependentRequiredProperty === 'outputCollection') {
291
319
  return `${ getIndefiniteArticle(typeString) } <${ typeString }> with <Multi-instance marker> and defined <Output element> must have a defined <Output collection>`;
292
320
  }
293
321
 
@@ -369,13 +397,7 @@ function getPropertyRequiredErrorMessage(report, executionPlatform, executionPla
369
397
  }
370
398
 
371
399
  if (is(node, 'bpmn:Error') && requiredProperty === 'errorCode') {
372
-
373
- if (parentNode && is(parentNode, 'bpmn:CatchEvent')) {
374
- return getSupportedMessage(`${ getIndefiniteArticle(typeString) } <${ typeString }> without defined <Error code>`, executionPlatform, executionPlatformVersion, allowedVersion);
375
- } else if (parentNode && is(parentNode, 'bpmn:ThrowEvent')) {
376
- return `${ getIndefiniteArticle(typeString) } <${ typeString }> with <Error Reference> must have a defined <Error code>`;
377
- }
378
-
400
+ return `${ getIndefiniteArticle(typeString) } <${ typeString }> with <Error Reference> must have a defined <Error code>`;
379
401
  }
380
402
 
381
403
  if (is(node, 'bpmn:Escalation') && requiredProperty === 'escalationCode') {
@@ -435,12 +457,17 @@ function getPropertyRequiredErrorMessage(report, executionPlatform, executionPla
435
457
  return `${ getIndefiniteArticle(typeString) } <${ typeString }> must have a defined <Timer duration>`;
436
458
  }
437
459
 
460
+ if (is(node, 'bpmn:Process') && requiredProperty === 'historyTimeToLive') {
461
+ return `${ getIndefiniteArticle(typeString) } <${ typeString }> must have a defined <History time to live>`;
462
+ }
463
+
438
464
  return message;
439
465
  }
440
466
 
441
467
  function getExpressionRequiredErrorMessage(report) {
442
468
  const {
443
- data
469
+ data,
470
+ message
444
471
  } = report;
445
472
 
446
473
  const {
@@ -454,11 +481,14 @@ function getExpressionRequiredErrorMessage(report) {
454
481
  if (is(node, 'bpmn:FormalExpression') && TIMER_PROPERTIES.includes(property)) {
455
482
  return `${ getIndefiniteArticle(typeString) } <${ typeString }> must have a defined <Timer value>`;
456
483
  }
484
+
485
+ return message;
457
486
  }
458
487
 
459
488
  function getExpressionValueNotAllowedErrorMessage(report) {
460
489
  const {
461
- data
490
+ data,
491
+ message
462
492
  } = report;
463
493
 
464
494
  const {
@@ -470,16 +500,26 @@ function getExpressionValueNotAllowedErrorMessage(report) {
470
500
  const typeString = getTypeString(parentNode || node);
471
501
 
472
502
  if (is(node, 'bpmn:FormalExpression') && property === 'timeCycle') {
473
- return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Time cycle> should be an expression, an ISO 8601 repeating interval, or a cron expression (cron requires Camunda Platform 8.1 or newer)`;
503
+ return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Time cycle> must be an expression, an ISO 8601 repeating interval, or a cron expression (cron requires Camunda Platform 8.1 or newer)`;
474
504
  }
475
505
 
476
506
  if (is(node, 'bpmn:FormalExpression') && property === 'timeDate') {
477
- return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Time date> should be an expression, or an ISO 8601 date`;
507
+ return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Time date> must be an expression, or an ISO 8601 date`;
478
508
  }
479
509
 
480
510
  if (is(node, 'bpmn:FormalExpression') && property === 'timeDuration') {
481
- return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Time duration> should be an expression, or an ISO 8601 interval`;
511
+ return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Time duration> must be an expression, or an ISO 8601 interval`;
512
+ }
513
+
514
+ if (is(node, 'zeebe:TaskSchedule') && property === 'dueDate') {
515
+ return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Due date> must be an ISO 8601 date`;
482
516
  }
517
+
518
+ if (is(node, 'zeebe:TaskSchedule') && property === 'followUpDate') {
519
+ return `${ getIndefiniteArticle(typeString) } <${ typeString }> <Follow up date> must be an ISO 8601 date`;
520
+ }
521
+
522
+ return message;
483
523
  }
484
524
 
485
525
  function getSupportedMessage(prefix, executionPlatform, executionPlatformVersion, allowedVersion) {
@@ -105,11 +105,11 @@ export function getEntryIds(report) {
105
105
  return [ 'multiInstance-inputCollection' ];
106
106
  }
107
107
 
108
- if (isPropertyDependendRequiredError(data, 'outputCollection', 'zeebe:LoopCharacteristics')) {
108
+ if (isPropertyDependentRequiredError(data, 'outputCollection', 'zeebe:LoopCharacteristics')) {
109
109
  return [ 'multiInstance-outputCollection' ];
110
110
  }
111
111
 
112
- if (isPropertyDependendRequiredError(data, 'outputElement', 'zeebe:LoopCharacteristics')) {
112
+ if (isPropertyDependentRequiredError(data, 'outputElement', 'zeebe:LoopCharacteristics')) {
113
113
  return [ 'multiInstance-outputElement' ];
114
114
  }
115
115
 
@@ -217,6 +217,34 @@ export function getEntryIds(report) {
217
217
  return [ 'assignmentDefinitionCandidateUsers' ];
218
218
  }
219
219
 
220
+ if (isPropertyError(data, 'historyTimeToLive', 'bpmn:Process')) {
221
+ return [ 'historyTimeToLive' ];
222
+ }
223
+
224
+ if (isExpressionValueNotAllowedError(data, 'dueDate', 'zeebe:TaskSchedule')) {
225
+ return [ 'taskScheduleDueDate' ];
226
+ }
227
+
228
+ if (isExpressionValueNotAllowedError(data, 'followUpDate', 'zeebe:TaskSchedule')) {
229
+ return [ 'taskScheduleFollowUpDate' ];
230
+ }
231
+
232
+ if (isExtensionElementNotAllowedError(data, 'zeebe:TaskSchedule', 'bpmn:UserTask')) {
233
+ const { extensionElement: taskSchedule } = data;
234
+
235
+ let ids = [];
236
+
237
+ if (taskSchedule.get('dueDate')) {
238
+ ids = [ ...ids, 'taskScheduleDueDate' ];
239
+ }
240
+
241
+ if (taskSchedule.get('followUpDate')) {
242
+ ids = [ ...ids, 'taskScheduleFollowUpDate' ];
243
+ }
244
+
245
+ return ids;
246
+ }
247
+
220
248
  return [];
221
249
  }
222
250
 
@@ -354,6 +382,26 @@ export function getErrorMessage(id, report) {
354
382
  if (id === 'assignmentDefinitionCandidateUsers') {
355
383
  return 'Not supported.';
356
384
  }
385
+
386
+ if (id === 'historyTimeToLive') {
387
+ return 'Time to live must be defined.';
388
+ }
389
+
390
+ if (id === 'taskScheduleDueDate') {
391
+ if (data.type === ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED) {
392
+ return 'Not supported.';
393
+ } else {
394
+ return 'Must be an ISO 8601 date.';
395
+ }
396
+ }
397
+
398
+ if (id === 'taskScheduleFollowUpDate') {
399
+ if (data.type === ERROR_TYPES.EXTENSION_ELEMENT_NOT_ALLOWED) {
400
+ return 'Not supported.';
401
+ } else {
402
+ return 'Must be an ISO 8601 date.';
403
+ }
404
+ }
357
405
  }
358
406
 
359
407
  function isExtensionElementNotAllowedError(data, extensionElement, type) {
@@ -369,9 +417,9 @@ function isExtensionElementRequiredError(data, requiredExtensionElement, type) {
369
417
  && (!type || is(data.node, type));
370
418
  }
371
419
 
372
- function isPropertyDependendRequiredError(data, dependendRequiredProperty, type) {
373
- return data.type === ERROR_TYPES.PROPERTY_DEPENDEND_REQUIRED
374
- && data.dependendRequiredProperty === dependendRequiredProperty
420
+ function isPropertyDependentRequiredError(data, dependentRequiredProperty, type) {
421
+ return data.type === ERROR_TYPES.PROPERTY_DEPENDENT_REQUIRED
422
+ && data.dependentRequiredProperty === dependentRequiredProperty
375
423
  && (!type || is(data.node, type));
376
424
  }
377
425
 
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@camunda/linting",
3
- "version": "0.16.0",
3
+ "version": "1.0.0",
4
4
  "description": "Linting for Camunda Platform",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "all": "npm run lint && npm test",
8
8
  "dev": "npm run test:watch",
9
9
  "lint": "eslint .",
10
- "start": "cross-env SINGLE_START=modeler npm run test:watch",
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",
11
13
  "test": "karma start",
12
14
  "test:watch": "npm test -- --auto-watch --no-single-run"
13
15
  },
@@ -27,15 +29,16 @@
27
29
  "dependencies": {
28
30
  "bpmn-moddle": "^8.0.0",
29
31
  "bpmnlint": "^8.0.0",
30
- "bpmnlint-plugin-camunda-compat": "^0.22.0",
32
+ "bpmnlint-plugin-camunda-compat": "^1.0.1",
31
33
  "bpmnlint-utils": "^1.0.2",
32
34
  "min-dash": "^4.0.0",
33
35
  "min-dom": "^4.1.0",
34
- "zeebe-bpmn-moddle": "^0.17.0"
36
+ "zeebe-bpmn-moddle": "^0.18.0"
35
37
  },
36
38
  "devDependencies": {
37
39
  "bpmn-js": "^11.1.1",
38
- "bpmn-js-properties-panel": "^1.15.1",
40
+ "bpmn-js-properties-panel": "^1.20.0",
41
+ "camunda-bpmn-js-behaviors": "^0.5.0",
39
42
  "chai": "^4.3.7",
40
43
  "cross-env": "^7.0.3",
41
44
  "eslint": "^8.32.0",