Socket
Socket
Sign inDemoInstall

bpmn-js-bpmnlint

Package Overview
Dependencies
Maintainers
9
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bpmn-js-bpmnlint - npm Package Compare versions

Comparing version 0.18.0 to 0.18.1

4

CHANGELOG.md

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

## 0.18.1
* `FIX`: display root element warnings ([#34](https://github.com/bpmn-io/bpmn-js-bpmnlint/pull/34))
## 0.18.0

@@ -11,0 +15,0 @@

@@ -980,3 +980,2 @@ (function (global, factory) {

/**

@@ -1278,6 +1277,13 @@ * Return the business object for a given element.

// Also attach element to subprocess plane
var plane = this._elementRegistry.get(elementId + '_plane');
if (plane) {
this._createElementIssues(plane.id, elementIssues);
}
var menuPosition;
var position;
if (element === this._canvas.getRootElement()) {
var isRoot = !element.parent;
if (isRoot && is(element, 'bpmn:Process')) {
menuPosition = 'bottom-right';

@@ -1289,2 +1295,9 @@

};
} else if (isRoot && is(element, 'bpmn:SubProcess')) {
menuPosition = 'bottom-right';
position = {
top: 50,
left: 150
};
} else {

@@ -1306,3 +1319,3 @@ menuPosition = 'top-right';

childErrors = issuesByType.childerror,
childWarnings = issuesByType.childwarning;
childWarnings = issuesByType.childwarn;

@@ -1309,0 +1322,0 @@ if (!errors && !warnings && !childErrors && !childWarnings) {

2

dist/bpmn-js-bpmnlint.umd.prod.js
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).BpmnJSBpmnlint=e()}(this,(function(){"use strict";function t(t,e){var n=t.get("editorActions",!1);n&&n.register({toggleLinting:function(){e.toggle()}})}t.$inject=["injector","linting"];class e{constructor({moddleRoot:t,rule:e}){this.rule=e,this.moddleRoot=t,this.messages=[],this.report=this.report.bind(this)}report(t,e){this.messages.push({id:t,message:e})}}const n={0:"off",1:"warn",2:"error"};function r(t={}){const{config:e,resolver:n}=t;if(void 0===n)throw new Error("must provide <options.resolver>");this.config=e,this.resolver=n,this.cachedRules={},this.cachedConfigs={}}var i=r;function o(t){return"bpmnlint"===t?"bpmnlint":t.startsWith("bpmnlint-plugin-")?t:"bpmnlint-plugin-"+t}r.prototype.applyRule=function(t,n){const{config:r,rule:i,category:o,name:s}=n;try{return function({moddleRoot:t,rule:n}){const r=new e({rule:n,moddleRoot:t}),i=n.check,o=i&&i.enter||i,s=i&&i.leave;if(!o&&!s)throw new Error("no check implemented");return function t(e,n){const r=n.enter||null,i=n.leave||null,o=r&&r(e),s=e.$descriptor;if(!1!==o&&!s.isGeneric){s.properties.filter(t=>!t.isAttr&&!t.isReference&&"String"!==t.type).forEach(r=>{if(r.name in e){const i=e[r.name];r.isMany?i.forEach(e=>{t(e,n)}):t(i,n)}})}i&&i(e)}(t,{enter:o?t=>o(t,r):null,leave:s?t=>s(t,r):null}),r.messages}({moddleRoot:t,rule:i,config:r}).map((function(t){return{...t,category:o}}))}catch(t){return console.error("rule <"+s+"> failed with error: ",t),[{message:"Rule error: "+t.message,category:"error"}]}},r.prototype.resolveRule=function(t){const{pkg:e,ruleName:n}=this.parseRuleName(t),r=`${e}-${n}`,i=this.cachedRules[r];return i?Promise.resolve(i):Promise.resolve(this.resolver.resolveRule(e,n)).then(e=>{if(!e)throw new Error(`unknown rule <${t}>`);return this.cachedRules[r]=e()})},r.prototype.resolveConfig=function(t){const{pkg:e,configName:n}=this.parseConfigName(t),r=`${e}-${n}`,i=this.cachedConfigs[r];return i?Promise.resolve(i):Promise.resolve(this.resolver.resolveConfig(e,n)).then(n=>{if(!n)throw new Error(`unknown config <${t}>`);return this.cachedConfigs[r]=this.normalizeConfig(n,e)})},r.prototype.resolveRules=function(t){return this.resolveConfiguredRules(t).then(t=>{const e=Object.entries(t).map(([t,e])=>{const{category:n,config:r}=this.parseRuleValue(e);return{name:t,category:n,config:r}}).filter(t=>"off"!==t.category).map(t=>{const{name:e}=t;return this.resolveRule(e).then((function(e){return{...t,rule:e}}))});return Promise.all(e)})},r.prototype.resolveConfiguredRules=function(t){let e=t.extends;return"string"==typeof e&&(e=[e]),void 0===e&&(e=[]),Promise.all(e.map(t=>this.resolveConfig(t).then(t=>this.resolveConfiguredRules(t)))).then(e=>[...e,this.normalizeConfig(t,"bpmnlint").rules].reduce((t,e)=>({...t,...e}),{}))},r.prototype.lint=function(t,e){return e=e||this.config,this.resolveRules(e).then(e=>{const n={};return e.forEach(e=>{const{name:r}=e,i=this.applyRule(t,e);i.length&&(n[r]=i)}),n})},r.prototype.parseRuleValue=function(t){let e,r;return Array.isArray(t)?(e=t[0],r=t[1]):(e=t,r={}),"string"==typeof e&&(e=e.toLowerCase()),e=n[e]||e,{config:r,category:e}},r.prototype.parseRuleName=function(t,e="bpmnlint"){const n=/^(?:(?:(@[^/]+)\/)?([^@]{1}[^/]*)\/)?([^/]+)$/.exec(t);if(!n)throw new Error(`unparseable rule name <${t}>`);const[r,i,s,l]=n;if(!s)return{pkg:e,ruleName:l};return{pkg:`${i?i+"/":""}${o(s)}`,ruleName:l}},r.prototype.parseConfigName=function(t){const e=/^(?:(?:plugin:(?:(@[^/]+)\/)?([^@]{1}[^/]*)\/)|bpmnlint:)([^/]+)$/.exec(t);if(!e)throw new Error(`unparseable config name <${t}>`);const[n,r,i,s]=e;if(!i)return{pkg:"bpmnlint",configName:s};return{pkg:`${r?r+"/":""}${o(i)}`,configName:s}},r.prototype.getSimplePackageName=function(t){const e=/^(?:(@[^/]+)\/)?([^/]+)$/.exec(t);if(!e)throw new Error(`unparseable package name <${t}>`);const[n,r,i]=e;return`${r?r+"/":""}${function(t){if(t.startsWith("bpmnlint-plugin-"))return t.substring("bpmnlint-plugin-".length);return t}(i)}`},r.prototype.normalizeConfig=function(t,e){const n=t.rules||{},r=Object.keys(n).reduce((t,r)=>{const i=n[r],{pkg:o,ruleName:s}=this.parseRuleName(r,e);return t["bpmnlint"===o?s:`${this.getSimplePackageName(o)}/${s}`]=i,t},{});return{...t,rules:r}};var s={Linter:i},l=Object.prototype.toString,a=Object.prototype.hasOwnProperty;function c(t,e){return a.call(t,e)}function u(t,e){var n;if(void 0!==t){var r=function(t){return"[object Array]"===l.call(t)}(t)?d:h;for(var i in t)if(c(t,i)&&!1===e(n=t[i],r(i)))return n}}function p(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e=f(e),u(t,(function(t){var r=e(t)||"_",i=n[r];i||(i=n[r]=[]),i.push(t)})),n}function f(t){return e=t,"[object Function]"===(n=l.call(e))||"[object AsyncFunction]"===n||"[object GeneratorFunction]"===n||"[object AsyncGeneratorFunction]"===n||"[object Proxy]"===n?t:function(e){return e[t]};var e,n}function h(t){return t}function d(t){return Number(t)}function g(){return(g=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function v(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return g.apply(void 0,[t].concat(n))}var m,y=function(t,e){if("string"!=typeof t)throw new TypeError("String expected");e||(e=document);var n=/<([\w:]+)/.exec(t);if(!n)return e.createTextNode(t);t=t.replace(/^\s+|\s+$/g,"");var r=n[1];if("body"==r){return(i=e.createElement("html")).innerHTML=t,i.removeChild(i.lastChild)}var i,o=_[r]||_._default,s=o[0],l=o[1],a=o[2];(i=e.createElement("div")).innerHTML=l+t+a;for(;s--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);var c=e.createDocumentFragment();for(;i.firstChild;)c.appendChild(i.removeChild(i.firstChild));return c},b=!1;"undefined"!=typeof document&&((m=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',b=!m.getElementsByTagName("link").length,m=void 0);var _={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:b?[1,"X<div>","</div>"]:[0,"",""]};_.td=_.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],_.option=_.optgroup=[1,'<select multiple="multiple">',"</select>"],_.thead=_.tbody=_.colgroup=_.caption=_.tfoot=[1,"<table>","</table>"],_.polyline=_.ellipse=_.polygon=_.circle=_.text=_.line=_.path=_.rect=_.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
!function(t){var e={exports:{}};t(e,e.exports)}((function(t,e){var n;n=w,t.exports=function(t){if(t.CSS&&t.CSS.escape)return t.CSS.escape;var e=function(t){if(0==arguments.length)throw new TypeError("`CSS.escape` requires an argument.");for(var e,n=String(t),r=n.length,i=-1,o="",s=n.charCodeAt(0);++i<r;)0!=(e=n.charCodeAt(i))?o+=e>=1&&e<=31||127==e||0==i&&e>=48&&e<=57||1==i&&e>=48&&e<=57&&45==s?"\\"+e.toString(16)+" ":0==i&&1==r&&45==e||!(e>=128||45==e||95==e||e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122)?"\\"+n.charAt(i):n.charAt(i):o+="�";return o};return t.CSS||(t.CSS={}),t.CSS.escape=e,e}(n)}));var C={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function j(t){return(t=""+t)&&t.replace(/[&<>"']/g,(function(t){return C[t]}))}var E='<svg width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512"><path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path></svg>',R='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 512 512"><path fill="currentColor" d="M288 328.83c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zM207.439 57.034l11.61 204.348c.544 9.334 8.78 16.64 18.755 16.64h100.392c9.975 0 18.211-7.306 18.754-16.64l11.611-204.348c.587-10.082-7.98-18.56-18.754-18.56H226.192c-10.775 0-19.34 8.478-18.753 18.56z"/></svg>',S='<svg width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"></path></svg>',$={resolver:{resolveRule:function(){return null}},config:{}},x={error:E,warning:R,success:S,inactive:S};function L(t,e,n,r,i,o,s){this._bpmnjs=t,this._canvas=e,this._elementRegistry=r,this._eventBus=i,this._overlays=o,this._translate=s,this._issues={},this._active=n&&n.active||!1,this._linterConfig=$,this._overlayIds={};var l=this;i.on(["import.done","elements.changed","linting.configChanged","linting.toggle"],500,(function(t){l.isActive()&&l.update()})),i.on("linting.toggle",(function(t){t.active||(l._clearIssues(),l._updateButton())})),i.on("diagram.clear",(function(){l._clearIssues()}));var a=n&&n.bpmnlint;a&&i.once("diagram.init",(function(){if(l.getLinterConfig()===$)try{l.setLinterConfig(a)}catch(t){console.error("[bpmn-js-bpmnlint] Invalid lint rules configured. Please doublecheck your linting.bpmnlint configuration, cf. https://github.com/bpmn-io/bpmn-js-bpmnlint#configure-lint-rules")}})),this._init()}return L.prototype.setLinterConfig=function(t){if(!t.config||!t.resolver)throw new Error("Expected linterConfig = { config, resolver }");this._linterConfig=t,this._eventBus.fire("linting.configChanged")},L.prototype.getLinterConfig=function(){return this._linterConfig},L.prototype._init=function(){this._createButton(),this._updateButton()},L.prototype.isActive=function(){return this._active},L.prototype._formatIssues=function(t){let e=this,n=(r=function(t,e,n){return t.concat(e.map((function(t){return t.rule=n,t})))},i=[],u(t,(function(t,e){i=r(i,t,e)})),i);var r,i;const o=e._elementRegistry.filter(t=>{return e="bpmn:Participant",(n=function(t){return t&&t.businessObject||t}(t))&&"function"==typeof n.$instanceOf&&n.$instanceOf(e);var e,n}).map(t=>t.businessObject);return n=function(t,e){var n=[];return u(t,(function(t,r){n.push(e(t,r))})),n}(n,(function(t){if(!e._elementRegistry.get(t.id)){t.isChildIssue=!0,t.actualElementId=t.id;const n=o.filter(e=>e.processRef&&e.processRef.id&&e.processRef.id===t.id);n.length?t.id=n[0].id:t.id=e._canvas.getRootElement().id}return t})),n=p(n,(function(t){return t.id})),n},L.prototype.toggle=function(t){return t=void 0===t?!this.isActive():t,this._setActive(t),t},L.prototype._setActive=function(t){this._active!==t&&(this._active=t,this._eventBus.fire("linting.toggle",{active:t}))},L.prototype.update=function(){var t=this;if(this._bpmnjs.getDefinitions()){var e=this._lintStart=Math.random();this.lint().then((function(n){if(t._lintStart===e){n=t._formatIssues(n);var r={},i={},o={};for(var s in t._issues)n[s]||(r[s]=t._issues[s]);for(var l in n)t._issues[l]?n[l]!==t._issues[l]&&(i[l]=n[l]):o[l]=n[l];r=v(r,i),o=v(o,i),t._clearOverlays(),t._createIssues(o),t._issues=n,t._updateButton(),t._fireComplete(n)}}))}},L.prototype._fireComplete=function(t){this._eventBus.fire("linting.completed",{issues:t})},L.prototype._createIssues=function(t){for(var e in t)this._createElementIssues(e,t[e])},L.prototype._createElementIssues=function(t,e){var n=this._elementRegistry.get(t);if(n){var r,i;n===this._canvas.getRootElement()?(r="bottom-right",i={top:20,left:150}):(r="top-right",i={top:-7,left:-7});var o=p(e,(function(t){return(t.isChildIssue?"child":"")+t.category})),s=o.error,l=o.warn,a=o.childerror,c=o.childwarning;if(s||l||a||c){var u=y('<div class="bjsl-overlay bjsl-issues-'+r+'"></div>'),f=y(s||a?'<div class="bjsl-icon bjsl-icon-error">'+E+"</div>":'<div class="bjsl-icon bjsl-icon-warning">'+R+"</div>"),h=y('<div class="bjsl-dropdown"></div>'),d=y('<div class="bjsl-dropdown-content"></div>'),g=y('<div class="bjsl-issues"></div>'),v=y('<div class="bjsl-current-element-issues"></div>'),m=y("<ul></ul>");if(u.appendChild(f),u.appendChild(h),h.appendChild(d),d.appendChild(g),g.appendChild(v),v.appendChild(m),s&&this._addErrors(m,s),l&&this._addWarnings(m,l),a||c){var b=y('<div class="bjsl-child-issues"></div>'),_=y("<ul></ul>"),w=y('<a class="bjsl-issue-heading">Issues for child elements:</a>');if(a&&this._addErrors(_,a),c&&this._addWarnings(_,c),s||l){var C=y("<hr/>");b.appendChild(C)}b.appendChild(w),b.appendChild(_),g.appendChild(b)}this._overlayIds[t]=this._overlays.add(n,"linting",{position:i,html:u,scale:{min:.9}})}}},L.prototype._addErrors=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"error",e)}))},L.prototype._addWarnings=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"warning",e)}))},L.prototype._addEntry=function(t,e,n){var r=n.rule,i=this._translate(n.message),o=n.actualElementId,s=y('<li class="'+e+'"><span class="icon"> '+x[e]+'</span><a title="'+j(r)+": "+j(i)+'" data-rule="'+j(r)+'" data-message="'+j(i)+'">'+j(i)+"</a>"+(o?'<a class="bjsl-id-hint"><code>'+o+"</code></a>":"")+"</li>");t.appendChild(s)},L.prototype._clearOverlays=function(){this._overlays.remove({type:"linting"}),this._overlayIds={}},L.prototype._clearIssues=function(){this._issues={},this._clearOverlays()},L.prototype._setButtonState=function(t,e,n){var r=this._button,i=x[t]+"<span>"+this._translate("{errors} Errors, {warnings} Warnings",{errors:e.toString(),warnings:n.toString()})+"</span>";["error","inactive","success","warning"].forEach((function(e){t===e?r.classList.add("bjsl-button-"+e):r.classList.remove("bjsl-button-"+e)})),r.innerHTML=i},L.prototype._updateButton=function(){if(this.isActive()){var t=0,e=0;for(var n in this._issues)this._issues[n].forEach((function(n){"error"===n.category?t++:"warn"===n.category&&e++}));var r=(t?"error":e&&"warning")||"success";this._setButtonState(r,t,e)}else this._setButtonState("inactive",0,0)},L.prototype._createButton=function(){var t=this;this._button=y('<button class="bjsl-button bjsl-button-inactive" title="'+this._translate("Toggle linting")+'"></button>'),this._button.addEventListener("click",(function(){t.toggle()})),this._canvas.getContainer().appendChild(this._button)},L.prototype.lint=function(){var t=this._bpmnjs.getDefinitions();return new s.Linter(this._linterConfig).lint(t)},L.$inject=["bpmnjs","canvas","config.linting","elementRegistry","eventBus","overlays","translate"],{__init__:["linting","lintingEditorActions"],linting:["type",L],lintingEditorActions:["type",t]}}));
!function(t){var e={exports:{}};t(e,e.exports)}((function(t,e){var n;n=w,t.exports=function(t){if(t.CSS&&t.CSS.escape)return t.CSS.escape;var e=function(t){if(0==arguments.length)throw new TypeError("`CSS.escape` requires an argument.");for(var e,n=String(t),r=n.length,i=-1,o="",s=n.charCodeAt(0);++i<r;)0!=(e=n.charCodeAt(i))?o+=e>=1&&e<=31||127==e||0==i&&e>=48&&e<=57||1==i&&e>=48&&e<=57&&45==s?"\\"+e.toString(16)+" ":0==i&&1==r&&45==e||!(e>=128||45==e||95==e||e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122)?"\\"+n.charAt(i):n.charAt(i):o+="�";return o};return t.CSS||(t.CSS={}),t.CSS.escape=e,e}(n)}));var C={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function j(t){return(t=""+t)&&t.replace(/[&<>"']/g,(function(t){return C[t]}))}function E(t,e){var n=function(t){return t&&t.businessObject||t}(t);return n&&"function"==typeof n.$instanceOf&&n.$instanceOf(e)}var R='<svg width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512"><path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path></svg>',S='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 512 512"><path fill="currentColor" d="M288 328.83c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zM207.439 57.034l11.61 204.348c.544 9.334 8.78 16.64 18.755 16.64h100.392c9.975 0 18.211-7.306 18.754-16.64l11.611-204.348c.587-10.082-7.98-18.56-18.754-18.56H226.192c-10.775 0-19.34 8.478-18.753 18.56z"/></svg>',$='<svg width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"></path></svg>',x={resolver:{resolveRule:function(){return null}},config:{}},L={error:R,warning:S,success:$,inactive:$};function k(t,e,n,r,i,o,s){this._bpmnjs=t,this._canvas=e,this._elementRegistry=r,this._eventBus=i,this._overlays=o,this._translate=s,this._issues={},this._active=n&&n.active||!1,this._linterConfig=x,this._overlayIds={};var l=this;i.on(["import.done","elements.changed","linting.configChanged","linting.toggle"],500,(function(t){l.isActive()&&l.update()})),i.on("linting.toggle",(function(t){t.active||(l._clearIssues(),l._updateButton())})),i.on("diagram.clear",(function(){l._clearIssues()}));var a=n&&n.bpmnlint;a&&i.once("diagram.init",(function(){if(l.getLinterConfig()===x)try{l.setLinterConfig(a)}catch(t){console.error("[bpmn-js-bpmnlint] Invalid lint rules configured. Please doublecheck your linting.bpmnlint configuration, cf. https://github.com/bpmn-io/bpmn-js-bpmnlint#configure-lint-rules")}})),this._init()}return k.prototype.setLinterConfig=function(t){if(!t.config||!t.resolver)throw new Error("Expected linterConfig = { config, resolver }");this._linterConfig=t,this._eventBus.fire("linting.configChanged")},k.prototype.getLinterConfig=function(){return this._linterConfig},k.prototype._init=function(){this._createButton(),this._updateButton()},k.prototype.isActive=function(){return this._active},k.prototype._formatIssues=function(t){let e=this,n=(r=function(t,e,n){return t.concat(e.map((function(t){return t.rule=n,t})))},i=[],u(t,(function(t,e){i=r(i,t,e)})),i);var r,i;const o=e._elementRegistry.filter(t=>E(t,"bpmn:Participant")).map(t=>t.businessObject);return n=function(t,e){var n=[];return u(t,(function(t,r){n.push(e(t,r))})),n}(n,(function(t){if(!e._elementRegistry.get(t.id)){t.isChildIssue=!0,t.actualElementId=t.id;const n=o.filter(e=>e.processRef&&e.processRef.id&&e.processRef.id===t.id);n.length?t.id=n[0].id:t.id=e._canvas.getRootElement().id}return t})),n=p(n,(function(t){return t.id})),n},k.prototype.toggle=function(t){return t=void 0===t?!this.isActive():t,this._setActive(t),t},k.prototype._setActive=function(t){this._active!==t&&(this._active=t,this._eventBus.fire("linting.toggle",{active:t}))},k.prototype.update=function(){var t=this;if(this._bpmnjs.getDefinitions()){var e=this._lintStart=Math.random();this.lint().then((function(n){if(t._lintStart===e){n=t._formatIssues(n);var r={},i={},o={};for(var s in t._issues)n[s]||(r[s]=t._issues[s]);for(var l in n)t._issues[l]?n[l]!==t._issues[l]&&(i[l]=n[l]):o[l]=n[l];r=v(r,i),o=v(o,i),t._clearOverlays(),t._createIssues(o),t._issues=n,t._updateButton(),t._fireComplete(n)}}))}},k.prototype._fireComplete=function(t){this._eventBus.fire("linting.completed",{issues:t})},k.prototype._createIssues=function(t){for(var e in t)this._createElementIssues(e,t[e])},k.prototype._createElementIssues=function(t,e){var n=this._elementRegistry.get(t);if(n){var r,i,o=this._elementRegistry.get(t+"_plane");o&&this._createElementIssues(o.id,e);var s=!n.parent;s&&E(n,"bpmn:Process")?(r="bottom-right",i={top:20,left:150}):s&&E(n,"bpmn:SubProcess")?(r="bottom-right",i={top:50,left:150}):(r="top-right",i={top:-7,left:-7});var l=p(e,(function(t){return(t.isChildIssue?"child":"")+t.category})),a=l.error,c=l.warn,u=l.childerror,f=l.childwarn;if(a||c||u||f){var h=y('<div class="bjsl-overlay bjsl-issues-'+r+'"></div>'),d=y(a||u?'<div class="bjsl-icon bjsl-icon-error">'+R+"</div>":'<div class="bjsl-icon bjsl-icon-warning">'+S+"</div>"),g=y('<div class="bjsl-dropdown"></div>'),v=y('<div class="bjsl-dropdown-content"></div>'),m=y('<div class="bjsl-issues"></div>'),b=y('<div class="bjsl-current-element-issues"></div>'),_=y("<ul></ul>");if(h.appendChild(d),h.appendChild(g),g.appendChild(v),v.appendChild(m),m.appendChild(b),b.appendChild(_),a&&this._addErrors(_,a),c&&this._addWarnings(_,c),u||f){var w=y('<div class="bjsl-child-issues"></div>'),C=y("<ul></ul>"),j=y('<a class="bjsl-issue-heading">Issues for child elements:</a>');if(u&&this._addErrors(C,u),f&&this._addWarnings(C,f),a||c){var $=y("<hr/>");w.appendChild($)}w.appendChild(j),w.appendChild(C),m.appendChild(w)}this._overlayIds[t]=this._overlays.add(n,"linting",{position:i,html:h,scale:{min:.9}})}}},k.prototype._addErrors=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"error",e)}))},k.prototype._addWarnings=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"warning",e)}))},k.prototype._addEntry=function(t,e,n){var r=n.rule,i=this._translate(n.message),o=n.actualElementId,s=y('<li class="'+e+'"><span class="icon"> '+L[e]+'</span><a title="'+j(r)+": "+j(i)+'" data-rule="'+j(r)+'" data-message="'+j(i)+'">'+j(i)+"</a>"+(o?'<a class="bjsl-id-hint"><code>'+o+"</code></a>":"")+"</li>");t.appendChild(s)},k.prototype._clearOverlays=function(){this._overlays.remove({type:"linting"}),this._overlayIds={}},k.prototype._clearIssues=function(){this._issues={},this._clearOverlays()},k.prototype._setButtonState=function(t,e,n){var r=this._button,i=L[t]+"<span>"+this._translate("{errors} Errors, {warnings} Warnings",{errors:e.toString(),warnings:n.toString()})+"</span>";["error","inactive","success","warning"].forEach((function(e){t===e?r.classList.add("bjsl-button-"+e):r.classList.remove("bjsl-button-"+e)})),r.innerHTML=i},k.prototype._updateButton=function(){if(this.isActive()){var t=0,e=0;for(var n in this._issues)this._issues[n].forEach((function(n){"error"===n.category?t++:"warn"===n.category&&e++}));var r=(t?"error":e&&"warning")||"success";this._setButtonState(r,t,e)}else this._setButtonState("inactive",0,0)},k.prototype._createButton=function(){var t=this;this._button=y('<button class="bjsl-button bjsl-button-inactive" title="'+this._translate("Toggle linting")+'"></button>'),this._button.addEventListener("click",(function(){t.toggle()})),this._canvas.getContainer().appendChild(this._button)},k.prototype.lint=function(){var t=this._bpmnjs.getDefinitions();return new s.Linter(this._linterConfig).lint(t)},k.$inject=["bpmnjs","canvas","config.linting","elementRegistry","eventBus","overlays","translate"],{__init__:["linting","lintingEditorActions"],linting:["type",k],lintingEditorActions:["type",t]}}));

@@ -307,6 +307,13 @@ import { Linter } from 'bpmnlint';

// Also attach element to subprocess plane
var plane = this._elementRegistry.get(elementId + '_plane');
if (plane) {
this._createElementIssues(plane.id, elementIssues);
}
var menuPosition;
var position;
if (element === this._canvas.getRootElement()) {
var isRoot = !element.parent;
if (isRoot && is(element, 'bpmn:Process')) {
menuPosition = 'bottom-right';

@@ -318,2 +325,9 @@

};
} else if (isRoot && is(element, 'bpmn:SubProcess')) {
menuPosition = 'bottom-right';
position = {
top: 50,
left: 150
};
} else {

@@ -335,3 +349,3 @@ menuPosition = 'top-right';

childErrors = issuesByType.childerror,
childWarnings = issuesByType.childwarning;
childWarnings = issuesByType.childwarn;

@@ -338,0 +352,0 @@ if (!errors && !warnings && !childErrors && !childWarnings) {

@@ -309,6 +309,13 @@ 'use strict';

// Also attach element to subprocess plane
var plane = this._elementRegistry.get(elementId + '_plane');
if (plane) {
this._createElementIssues(plane.id, elementIssues);
}
var menuPosition;
var position;
if (element === this._canvas.getRootElement()) {
var isRoot = !element.parent;
if (isRoot && ModelUtil.is(element, 'bpmn:Process')) {
menuPosition = 'bottom-right';

@@ -320,2 +327,9 @@

};
} else if (isRoot && ModelUtil.is(element, 'bpmn:SubProcess')) {
menuPosition = 'bottom-right';
position = {
top: 50,
left: 150
};
} else {

@@ -337,3 +351,3 @@ menuPosition = 'top-right';

childErrors = issuesByType.childerror,
childWarnings = issuesByType.childwarning;
childWarnings = issuesByType.childwarn;

@@ -340,0 +354,0 @@ if (!errors && !warnings && !childErrors && !childWarnings) {

{
"name": "bpmn-js-bpmnlint",
"version": "0.18.0",
"version": "0.18.1",
"description": "bpmn-js integration for bpmnlint",

@@ -12,2 +12,3 @@ "main": "dist/index.js",

"lint": "eslint .",
"start": "cross-env SINGLE_START=true npm run dev",
"test": "karma start --no-auto-test --single-run",

@@ -37,3 +38,3 @@ "dev": "karma start",

"@rollup/plugin-node-resolve": "^11.0.0",
"bpmn-js": "^8.3.0",
"bpmn-js": "^9.0.1",
"bpmnlint": "^7.2.1",

@@ -43,2 +44,3 @@ "bpmnlint-loader": "^0.1.4",

"cpx": "^1.5.0",
"cross-env": "^7.0.3",
"eslint": "^7.24.0",

@@ -48,2 +50,4 @@ "eslint-plugin-bpmn-io": "^0.12.0",

"karma-chrome-launcher": "^3.1.0",
"karma-debug-launcher": "0.0.4",
"karma-env-preprocessor": "^0.1.1",
"karma-mocha": "^2.0.1",

@@ -65,3 +69,3 @@ "karma-sinon-chai": "^2.0.2",

"dependencies": {
"diagram-js": "^6.8.2",
"diagram-js": "^8.1.2",
"min-dash": "^3.5.2",

@@ -68,0 +72,0 @@ "min-dom": "^3.1.3"

@@ -19,2 +19,4 @@ # bpmn-js-bpmnlint

import 'bpmn-js-bpmnlint/dist/assets/css/bpmn-js-bpmnlint.css';
import BpmnModeler from 'bpmn-js/lib/Modeler';

@@ -21,0 +23,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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