bpmnlint 11.4.4 → 11.6.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/README.md +6 -0
- package/bin/bpmnlint.js +37 -7
- package/config/correctness.js +2 -1
- package/lib/resolver/helper.js +12 -0
- package/lib/resolver/node-resolver.js +2 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,12 @@ You may also extend from multiple configurations, including those provided by [c
|
|
|
75
75
|
|
|
76
76
|
This will amend core `recommended` rules with `recommended` rulesets provided by `bpmnlint-plugin-foo` and `@bar/bpmnlint-plugin-bar`, respectively.
|
|
77
77
|
|
|
78
|
+
### Available Configurations
|
|
79
|
+
|
|
80
|
+
* [`bpmnlint:all`](./config/all.js) - all rules as errors
|
|
81
|
+
* [`bpmnlint:recommended`](./config/recommended.js) - opinionated rules ("best practices") and rules enforcing BPMN compliance
|
|
82
|
+
* [`bpmnlint:correctness`](./config/correctness.js) - rules enforcing BPMN compliance
|
|
83
|
+
|
|
78
84
|
## API
|
|
79
85
|
|
|
80
86
|
Invoke the tool directly from [NodeJS](https://nodejs.org/en):
|
package/bin/bpmnlint.js
CHANGED
|
@@ -24,6 +24,7 @@ const BpmnModdle = require('bpmn-moddle');
|
|
|
24
24
|
|
|
25
25
|
const Linter = require('../lib/linter');
|
|
26
26
|
const NodeResolver = require('../lib/resolver/node-resolver');
|
|
27
|
+
const { createScopedRequire } = require('../lib/resolver/helper');
|
|
27
28
|
|
|
28
29
|
const Table = require('cli-table');
|
|
29
30
|
|
|
@@ -59,8 +60,6 @@ Usage
|
|
|
59
60
|
`;
|
|
60
61
|
|
|
61
62
|
|
|
62
|
-
const moddle = new BpmnModdle();
|
|
63
|
-
|
|
64
63
|
function boldRed(str) {
|
|
65
64
|
return bold(red(str));
|
|
66
65
|
}
|
|
@@ -81,10 +80,11 @@ function glob(files) {
|
|
|
81
80
|
* Reads XML form path and return moddle object
|
|
82
81
|
*
|
|
83
82
|
* @param {string} diagramXML
|
|
83
|
+
* @param {BpmnModdle.BPMNModdle} moddle
|
|
84
84
|
*
|
|
85
85
|
* @return { Promise<{ moddleElement: any; warnings: Error[], error?: Error }> } parseResult
|
|
86
86
|
*/
|
|
87
|
-
async function parseDiagram(diagramXML) {
|
|
87
|
+
async function parseDiagram(diagramXML, moddle) {
|
|
88
88
|
|
|
89
89
|
try {
|
|
90
90
|
const {
|
|
@@ -235,7 +235,7 @@ function printReports(filePath, results) {
|
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
async function lintDiagram(diagramPath, config) {
|
|
238
|
+
async function lintDiagram(diagramPath, config, moddle) {
|
|
239
239
|
|
|
240
240
|
let diagramXML;
|
|
241
241
|
|
|
@@ -250,7 +250,7 @@ async function lintDiagram(diagramPath, config) {
|
|
|
250
250
|
error: importError,
|
|
251
251
|
warnings: importWarnings,
|
|
252
252
|
moddleElement
|
|
253
|
-
} = await parseDiagram(diagramXML);
|
|
253
|
+
} = await parseDiagram(diagramXML, moddle);
|
|
254
254
|
|
|
255
255
|
if (importError) {
|
|
256
256
|
return printReports(diagramPath, {
|
|
@@ -307,8 +307,10 @@ async function lint(files, config, maxWarnings) {
|
|
|
307
307
|
|
|
308
308
|
console.log();
|
|
309
309
|
|
|
310
|
+
const moddle = createModdle(config);
|
|
311
|
+
|
|
310
312
|
for (let i = 0; i < files.length; i++) {
|
|
311
|
-
let results = await lintDiagram(files[i], config);
|
|
313
|
+
let results = await lintDiagram(files[i], config, moddle);
|
|
312
314
|
|
|
313
315
|
errorCount += results.errorCount;
|
|
314
316
|
warningCount += results.warningCount;
|
|
@@ -405,4 +407,32 @@ Learn more about configuring bpmnlint: https://github.com/bpmn-io/bpmnlint#confi
|
|
|
405
407
|
return lint(actualFiles, config, maxWarnings);
|
|
406
408
|
}
|
|
407
409
|
|
|
408
|
-
run().catch(errorAndExit);
|
|
410
|
+
run().catch(errorAndExit);
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Create moddle instance with extensions from the config.
|
|
414
|
+
*
|
|
415
|
+
* @param {object} config
|
|
416
|
+
* @returns {BpmnModdle.BPMNModdle}
|
|
417
|
+
*/
|
|
418
|
+
function createModdle(config) {
|
|
419
|
+
const scopedRequire = createScopedRequire(process.cwd());
|
|
420
|
+
|
|
421
|
+
const options = config.moddleExtensions || {};
|
|
422
|
+
|
|
423
|
+
for (const key in options) {
|
|
424
|
+
const extension = options[key];
|
|
425
|
+
|
|
426
|
+
try {
|
|
427
|
+
options[key] = scopedRequire(extension);
|
|
428
|
+
} catch (error) {
|
|
429
|
+
errorAndExit('Error: Could not load moddle extension <%s> from %s\n\n', key, extension, /** @type { Error } */ (error).message);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
try {
|
|
434
|
+
return new BpmnModdle(options);
|
|
435
|
+
} catch (error) {
|
|
436
|
+
errorAndExit('Error: Could not create moddle instance\n\n%s', /** @type { Error } */ (error).message);
|
|
437
|
+
}
|
|
438
|
+
}
|
package/config/correctness.js
CHANGED
|
@@ -4,6 +4,7 @@ module.exports = {
|
|
|
4
4
|
'event-sub-process-typed-start-event': 'error',
|
|
5
5
|
'link-event': 'error',
|
|
6
6
|
'no-duplicate-sequence-flows': 'warn',
|
|
7
|
-
'sub-process-blank-start-event': 'error'
|
|
7
|
+
'sub-process-blank-start-event': 'error',
|
|
8
|
+
'single-blank-start-event': 'error'
|
|
8
9
|
}
|
|
9
10
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const Module = require('node:module');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create require function for a given path.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} cwd
|
|
8
|
+
* @returns {NodeRequire}
|
|
9
|
+
*/
|
|
10
|
+
module.exports.createScopedRequire = function(cwd) {
|
|
11
|
+
return Module.createRequire(path.join(cwd, '__placeholder__.js'));
|
|
12
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const Module = require('node:module');
|
|
2
1
|
const path = require('node:path');
|
|
3
2
|
const { cwd } = require('node:process');
|
|
4
3
|
|
|
@@ -9,6 +8,7 @@ const { isString } = require('min-dash');
|
|
|
9
8
|
* @typedef { import('../types.js').Config } Config
|
|
10
9
|
*/
|
|
11
10
|
|
|
11
|
+
const { createScopedRequire } = require('./helper');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* A resolver that locates rules and configurations
|
|
@@ -133,13 +133,4 @@ NodeResolver.prototype.normalizePkg = function(pkg) {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
return pkg;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
// helpers ////////////////////
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @param {string} cwd
|
|
142
|
-
*/
|
|
143
|
-
function createScopedRequire(cwd) {
|
|
144
|
-
return Module.createRequire(path.join(cwd, '__placeholder__.js'));
|
|
145
|
-
}
|
|
136
|
+
};
|