Socket
Socket
Sign inDemoInstall

bpmnlint

Package Overview
Dependencies
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bpmnlint - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

70

bin/bpmnlint.js

@@ -36,8 +36,16 @@ #!/usr/bin/env node

return new Promise((resolve, reject) => {
moddle.fromXML(diagramXML, (err, moddleElement) => {
if (err) {
return reject(new Error('failed to parse XML', err));
moddle.fromXML(diagramXML, (error, moddleElement, context) => {
if (error) {
return resolve({
error
});
}
return resolve(moddleElement);
const warnings = context.warnings || [];
return resolve({
moddleElement,
warnings
});
});

@@ -59,3 +67,3 @@ });

return [ report.id, color(categoryMap[category] || category), report.message, report.name ];
return [ report.id || '', color(categoryMap[category] || category), report.message, report.name || '' ];
}

@@ -110,3 +118,4 @@

id,
message
message,
name: reportName
} = report;

@@ -118,3 +127,3 @@

message,
name
name: reportName || name
}));

@@ -188,5 +197,39 @@

const {
error: importError,
warnings: importWarnings,
moddleElement
} = await parseDiagram(diagramXML);
if (importError) {
return printReports(diagramPath, {
'': [
{
message: 'Parse error: ' + importError.message,
category: 'error'
}
]
});
}
const importReports = importWarnings.length ? {
'': importWarnings.map(function(warning) {
const {
element,
message
} = warning;
const id = element && element.id;
return {
id,
message: 'Import warning: ' + message.split(/\n/)[0],
category: 'error'
};
})
} : {};
try {
const moddleRoot = await parseDiagram(diagramXML);
const linter = new Linter({

@@ -197,5 +240,10 @@ config,

const lintResults = await linter.lint(moddleRoot);
const lintReports = await linter.lint(moddleElement);
return printReports(diagramPath, lintResults);
const allResults = {
...importReports,
...lintReports
};
return printReports(diagramPath, allResults);
} catch (e) {

@@ -202,0 +250,0 @@ return logAndExit(e);

10

CHANGELOG.md

@@ -9,2 +9,8 @@ # Changelog

## 4.1.0
* `FEAT`: handle and report diagram import errors and warnings via CLI
* `FEAT`: properly handle generic moddle elements during rule checking
* `FEAT`: report rule execution errors
## 4.0.0

@@ -37,3 +43,3 @@

## 3.0.0
## 3.0.0bpmnlinter

@@ -83,3 +89,3 @@ #### Breaking Changes

* `CHORE`: `linter` is now a constructor, offering a `#lint(moddleElement, config)` method
* `CHORE`: moved library to [bpmn-io/bpmnlinter](https://github.com/bpmn-io/bpmnlinter)
* `CHORE`: moved library to [bpmn-io/bpmnlint](https://github.com/bpmn-io/bpmnlint)
* `CHORE`: full rewrite of internals

@@ -86,0 +92,0 @@ * `CHORE`: `utils` API change

@@ -36,9 +36,44 @@ const testRule = require('./test-rule');

* @param {ModdleElement} moddleRoot
* @param {Rule} rule
* @param {Object} ruleConfig
*
* @return {Array<ValidationErrors>} lint results
* @param {Object} ruleDefinition.name
* @param {Object} ruleDefinition.config
* @param {Object} ruleDefinition.category
* @param {Rule} ruleDefinition.rule
*
* @return {Array<ValidationErrors>} rule reports
*/
Linter.prototype.applyRule = function applyRule(moddleRoot, rule, ruleConfig) {
return testRule({ moddleRoot, rule, ruleConfig });
Linter.prototype.applyRule = function applyRule(moddleRoot, ruleDefinition) {
const {
config,
rule,
category,
name
} = ruleDefinition;
try {
const reports = testRule({
moddleRoot,
rule,
config
});
return reports.map(function(report) {
return {
...report,
category
};
});
} catch (e) {
console.error('rule <' + name + '> failed with error: ', e);
return [
{
message: 'Rule error: ' + e.message,
category: 'error'
}
];
}
};

@@ -198,3 +233,3 @@

const finalReport = {};
const allReports = {};

@@ -204,25 +239,13 @@ ruleDefinitions.forEach((ruleDefinition) => {

const {
rule,
name,
config,
category
name
} = ruleDefinition;
const reports = this.applyRule(moddleRoot, rule, config);
const reports = this.applyRule(moddleRoot, ruleDefinition);
if (reports.length === 0) {
return;
if (reports.length) {
allReports[name] = reports;
}
const categorizedReports = reports.map(function(report) {
return {
...report,
category
};
});
finalReport[name] = categorizedReports;
});
return finalReport;
return allReports;
});

@@ -229,0 +252,0 @@ };

@@ -11,3 +11,9 @@ /**

var containedProperties = element.$descriptor.properties.filter(p => {
var descriptor = element.$descriptor;
if (descriptor.isGeneric) {
return;
}
var containedProperties = descriptor.properties.filter(p => {
return !p.isAttr && !p.isReference && p.type !== 'String';

@@ -14,0 +20,0 @@ });

{
"name": "bpmnlint",
"version": "4.0.0",
"version": "4.1.0",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "keywords": [

@@ -59,5 +59,5 @@ # bpmnlint

## Visual Linting
## Visual Feedback
Integrate the linter via [bpmn-js-bpmnlint](https://github.com/philippfromme/bpmn-js-bpmnlint) into your [next BPMN editor](https://github.com/bpmn-io/bpmn-js).
Integrate the linter via [bpmn-js-bpmnlint](https://github.com/philippfromme/bpmn-js-bpmnlint) into [bpmn-js](https://github.com/bpmn-io/bpmn-js) and get direct feedback during modeling.

@@ -64,0 +64,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc