bpmnlint 7.7.0 → 8.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.
package/bin/bpmnlint.js CHANGED
@@ -28,7 +28,7 @@ const Table = require('cli-table');
28
28
 
29
29
  const pluralize = require('pluralize');
30
30
 
31
- const { pathStringify } = require('@philippfromme/moddle-helpers');
31
+ const { pathStringify } = require('@bpmn-io/moddle-utils');
32
32
 
33
33
  const CONFIG_NAME = '.bpmnlintrc';
34
34
 
package/lib/linter.js CHANGED
@@ -77,7 +77,7 @@ Linter.prototype.applyRule = function applyRule(moddleRoot, ruleDefinition) {
77
77
  };
78
78
 
79
79
 
80
- Linter.prototype.resolveRule = function(name) {
80
+ Linter.prototype.resolveRule = function(name, config) {
81
81
 
82
82
  const {
83
83
  pkg,
@@ -98,7 +98,7 @@ Linter.prototype.resolveRule = function(name) {
98
98
  throw new Error(`unknown rule <${name}>`);
99
99
  }
100
100
 
101
- const rule = this.cachedRules[id] = ruleFactory();
101
+ const rule = this.cachedRules[id] = ruleFactory(config);
102
102
 
103
103
  return rule;
104
104
  });
@@ -163,10 +163,11 @@ Linter.prototype.resolveRules = function(config) {
163
163
  const loaders = enabledRules.map((definition) => {
164
164
 
165
165
  const {
166
- name
166
+ name,
167
+ config
167
168
  } = definition;
168
169
 
169
- return this.resolveRule(name).then(function(rule) {
170
+ return this.resolveRule(name, config).then(function(rule) {
170
171
  return {
171
172
  ...definition,
172
173
  rule
@@ -21,19 +21,21 @@ async function compileConfig(config, resolver) {
21
21
  const resolvedRules = await linter.resolveConfiguredRules(config);
22
22
 
23
23
  // only process and serialize enabled rules
24
- const enabledRules = Object.keys(resolvedRules).reduce(function(enabledRules, key) {
24
+ const rules = Object.keys(resolvedRules).reduce(function(rules, key) {
25
25
  const value = resolvedRules[key];
26
26
 
27
27
  const { category } = linter.parseRuleValue(value);
28
28
 
29
- if (category !== 'off') {
30
- enabledRules[key] = value;
29
+ if (category === 'off') {
30
+ rules[key] = 0;
31
+ } else {
32
+ rules[key] = value;
31
33
  }
32
34
 
33
- return enabledRules;
35
+ return rules;
34
36
  }, {});
35
37
 
36
- const serializedRules = JSON.stringify(enabledRules, null, ' ');
38
+ const serializedRules = JSON.stringify(rules, null, ' ');
37
39
 
38
40
  const preambleCode = `
39
41
  const cache = {};
@@ -81,7 +83,11 @@ export { resolver, config };
81
83
  export default bundle;
82
84
  `;
83
85
 
84
- const importCode = Object.keys(enabledRules).map((key, idx) => {
86
+ const importCode = Object.entries(rules).map(([ key, value ], idx) => {
87
+
88
+ if (!value) {
89
+ return null;
90
+ }
85
91
 
86
92
  const {
87
93
  pkg, ruleName
@@ -90,7 +96,7 @@ export default bundle;
90
96
  return `
91
97
  import rule_${idx} from '${resolver.normalizePkg(pkg)}/rules/${ruleName}';
92
98
  cache['${pkg}/${ruleName}'] = rule_${idx};`;
93
- }).join('\n');
99
+ }).filter(e => e).join('\n');
94
100
 
95
101
  return `${preambleCode}\n\n${importCode}`;
96
102
  }
@@ -14,11 +14,12 @@ function expectEqual(a, b) {
14
14
  assert.deepStrictEqual(JSON.stringify(a, replacer, 2), JSON.stringify(b, replacer, 2));
15
15
  }
16
16
 
17
-
18
17
  function verify(ruleName, rule, testCases) {
19
- const linterConfig = {
20
- rules: { [ruleName]: 2 }
21
- };
18
+ function createLinterConfig(config = {}) {
19
+ return {
20
+ rules: { [ruleName]: [ 2, config ] }
21
+ };
22
+ }
22
23
 
23
24
  describe(`rules/${ruleName}`, function() {
24
25
 
@@ -33,13 +34,13 @@ function verify(ruleName, rule, testCases) {
33
34
 
34
35
  describe('should lint valid', function() {
35
36
 
36
- testCases.valid.forEach(({ moddleElement, name, it: _it }, idx) => (
37
+ testCases.valid.forEach(({ config = {}, it: _it, moddleElement, name }, idx) => (
37
38
 
38
39
  (_it || it)(getTitle(idx, name), function() {
39
40
  return (
40
41
  Promise.resolve(moddleElement)
41
42
  .then(moddleRoot => {
42
- return linter.lint(moddleRoot.root, linterConfig);
43
+ return linter.lint(moddleRoot.root, createLinterConfig(config));
43
44
  })
44
45
  .then(lintResults => {
45
46
  expectEqual(lintResults, {});
@@ -54,7 +55,7 @@ function verify(ruleName, rule, testCases) {
54
55
 
55
56
  describe('should lint invalid', function() {
56
57
 
57
- testCases.invalid.forEach(({ moddleElement, name, report, it: _it }, idx) => (
58
+ testCases.invalid.forEach(({ config = {}, it: _it, moddleElement, name, report }, idx) => (
58
59
 
59
60
  (_it || it)(getTitle(idx, name), function() {
60
61
 
@@ -78,7 +79,7 @@ function verify(ruleName, rule, testCases) {
78
79
  return (
79
80
  Promise.resolve(moddleElement)
80
81
  .then(moddleRoot => {
81
- return linter.lint(moddleRoot.root, linterConfig);
82
+ return linter.lint(moddleRoot.root, createLinterConfig(config));
82
83
  })
83
84
  .then(lintResults => {
84
85
  expectEqual(lintResults, expectedLintResults);
@@ -95,16 +96,9 @@ function verify(ruleName, rule, testCases) {
95
96
  }
96
97
 
97
98
  function getTitle(idx, name) {
98
- return `test case #${ idx + 1 }${ name ? ` ${ name }`: '' }`;
99
+ return `test case #${ idx + 1 }${ name ? ` ${ name }` : '' }`;
99
100
  }
100
101
 
101
- module.exports = {
102
- expectEqual,
103
- verify,
104
- getTitle,
105
- replacer
106
- };
107
-
108
102
  function replacer(_, value) {
109
103
  if (!value) {
110
104
  return value;
@@ -133,4 +127,11 @@ function replacer(_, value) {
133
127
  }
134
128
 
135
129
  return value;
136
- }
130
+ }
131
+
132
+ module.exports = {
133
+ expectEqual,
134
+ verify,
135
+ getTitle,
136
+ replacer
137
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bpmnlint",
3
3
  "description": "Validate your BPMN diagrams based on configurable lint rules",
4
- "version": "7.7.0",
4
+ "version": "8.0.0",
5
5
  "main": "lib/index.js",
6
6
  "keywords": [
7
7
  "bpmnlint",
@@ -23,7 +23,7 @@
23
23
  }
24
24
  ],
25
25
  "engines": {
26
- "node": ">= 10"
26
+ "node": ">= 12"
27
27
  },
28
28
  "license": "MIT",
29
29
  "scripts": {
@@ -37,27 +37,33 @@
37
37
  "bpmnlint": "./bin/bpmnlint.js"
38
38
  },
39
39
  "dependencies": {
40
- "@philippfromme/moddle-helpers": "^0.1.0",
41
- "ansi-colors": "^4.1.1",
42
- "bpmn-moddle": "^7.1.2",
40
+ "@bpmn-io/moddle-utils": "^0.1.0",
41
+ "ansi-colors": "^4.1.3",
42
+ "bpmn-moddle": "^7.1.3",
43
43
  "bpmnlint-utils": "^1.0.2",
44
- "cli-table": "^0.3.9",
44
+ "cli-table": "^0.3.11",
45
45
  "color-support": "^1.1.3",
46
- "min-dash": "^3.8.0",
46
+ "min-dash": "^3.8.1",
47
47
  "mri": "^1.2.0",
48
48
  "pluralize": "^7.0.0",
49
49
  "tiny-glob": "^0.2.9"
50
50
  },
51
51
  "devDependencies": {
52
52
  "chai": "^4.3.4",
53
- "eslint": "^7.32.0",
54
- "eslint-plugin-bpmn-io": "^0.11.0",
53
+ "eslint": "^8.23.1",
54
+ "eslint-plugin-bpmn-io": "^0.16.0",
55
55
  "esm": "^3.2.25",
56
- "execa": "^2.1.0",
57
- "install-local": "^1.0.0",
56
+ "execa": "^5.1.1",
57
+ "install-local": "^3.0.1",
58
58
  "mocha": "^8.4.0",
59
59
  "npm-run-all": "^4.1.5",
60
60
  "nyc": "^15.1.0",
61
- "strip-indent": "^2.0.0"
62
- }
61
+ "strip-indent": "^3.0.0"
62
+ },
63
+ "files": [
64
+ "bin",
65
+ "config",
66
+ "lib",
67
+ "rules"
68
+ ]
63
69
  }
@@ -53,7 +53,6 @@ module.exports = function() {
53
53
  */
54
54
  function getAllBpmnElements(rootElements) {
55
55
  return flatten(rootElements.map((rootElement) => {
56
-
57
56
  const laneSet =
58
57
  rootElement.laneSets && rootElement.laneSets[0] || rootElement.childLaneSet;
59
58
 
@@ -66,13 +65,15 @@ function getAllBpmnElements(rootElements) {
66
65
  // * nested laneSets
67
66
  // * childLaneSets
68
67
  // * nested childLaneSets
68
+ // * messageFlows
69
69
  const elements = flatten([].concat(
70
70
  rootElement.flowElements || [],
71
71
  (rootElement.flowElements && getAllBpmnElements(rootElement.flowElements.filter(hasFlowElements))) || [],
72
72
  rootElement.participants || [],
73
73
  rootElement.artifacts || [],
74
74
  laneSet && laneSet.lanes || [],
75
- laneSet && laneSet.lanes && getAllBpmnElements(laneSet.lanes.filter(hasChildLaneSet)) || []
75
+ laneSet && laneSet.lanes && getAllBpmnElements(laneSet.lanes.filter(hasChildLaneSet)) || [],
76
+ rootElement.messageFlows || []
76
77
  ));
77
78
 
78
79
  if (elements.length > 0) {
@@ -115,7 +116,7 @@ function getAllDiBpmnReferences(definitionsNode) {
115
116
  }
116
117
 
117
118
  function hasVisualRepresentation(element) {
118
- const noVisRepresentation = ['bpmn:DataObject'];
119
+ const noVisRepresentation = [ 'bpmn:DataObject' ];
119
120
 
120
121
  return noVisRepresentation.includes(element.$type) ? false : true;
121
122
  }
package/CHANGELOG.md DELETED
@@ -1,205 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to [bpmnlint](https://github.com/bpmn-io/bpmnlint) are documented here. We use [semantic versioning](http://semver.org/) for releases.
4
-
5
- ## Unreleased
6
-
7
- ___Note:__ Yet to be released changes appear here._
8
-
9
- ## 7.7.0
10
-
11
- * `FEAT`: fuzzy test for equality of nodes when using `RuleTester#verify` ([#79](https://github.com/bpmn-io/bpmnlint/pull/79/files))
12
-
13
- ## 7.6.0
14
-
15
- * `FEAT`: allow passing object as third parameter to `Reporter#report` ([#75](https://github.com/bpmn-io/bpmnlint/pull/75))
16
-
17
-
18
- ## 7.5.0
19
-
20
- * `FEAT`: add optional `path` parameter to `Reporter#report` ([#73](https://github.com/bpmn-io/bpmnlint/pull/73))
21
- * `FEAT`: add optional `name` parameter to `RuleTester#verify` ([#68](https://github.com/bpmn-io/bpmnlint/pull/68))
22
- * `CHORE`: update to `bpmn-moddle@7.1.2`
23
-
24
- ## 7.4.0
25
-
26
- * `FEAT`: resolve local package by name ([#64](https://github.com/bpmn-io/bpmnlint/pull/64))
27
-
28
- ## 7.3.0
29
-
30
- * `FEAT`: support `--version` command line flag ([#65](https://github.com/bpmn-io/bpmnlint/pull/65))
31
- * `FEAT`: allow rule testers to provide custom `it`
32
- * `FIX`: make `no-bpmndi` handle missing `LaneSet#lanes` gracefully ([#63](https://github.com/bpmn-io/bpmnlint/issues/63), [#66](https://github.com/bpmn-io/bpmnlint/pull/66))
33
-
34
- ## 7.2.1
35
-
36
- * `FIX`: exclude compensation boundary and activity in `no-disconnected` check ([#60](https://github.com/bpmn-io/bpmnlint/pull/60))
37
-
38
- ## 7.2.0
39
-
40
- * `FEAT`: add `no-bpmndi` rule ([#55](https://github.com/bpmn-io/bpmnlint/issues/55))
41
-
42
- ## 7.1.0
43
-
44
- * `FEAT`: allow rules to skip sub-tree traversal ([#53](https://github.com/bpmn-io/bpmnlint/issues/53))
45
- * `FEAT`: allow rules to hook into node `enter` and `leave` ([#52](https://github.com/bpmn-io/bpmnlint/issues/52))
46
-
47
- ## 7.0.1
48
-
49
- * `CHORE`: drop debug log statement
50
-
51
- ## 7.0.0
52
-
53
- * `CHORE`: update to `bpmn-moddle@7`
54
- * `CHORE`: reduce library footprint
55
- * `CHORE`: require `NodeJS>=10`
56
-
57
- ## 6.5.0
58
-
59
- * `FEAT`: add globbing support ([#46](https://github.com/bpmn-io/bpmnlint/issues/46))
60
- * `DOCS`: add explaination to `no-inclusive-gateway` rule
61
-
62
- ## 6.4.0
63
-
64
- * `FEAT`: add `superfluous-gateway` check ([#42](https://github.com/bpmn-io/bpmnlint/pull/42/files))
65
-
66
- ## 6.3.0
67
-
68
- * `FEAT`: support rules and configuration provided by scoped packages ([#35](https://github.com/bpmn-io/bpmnlint/issues/35))
69
- * `CHORE`: improve `Node >= 12.20` compatibility ([#37](https://github.com/bpmn-io/bpmnlint/pull/37))
70
-
71
- ## 6.2.0
72
-
73
- * `DOCS`: document existing rules ([#14](https://github.com/bpmn-io/bpmnlint/issues/14))
74
-
75
- ## 6.1.2
76
-
77
- * `FIX`: exclude event-based sub-processes from `no-disconnected` check ([#31](https://github.com/bpmn-io/bpmnlint/issues/31))
78
-
79
- ## 6.1.1
80
-
81
- * `FEAT`: allow tool to be used with `Node >= 8`
82
-
83
- ## 6.1.0
84
-
85
- * `FEAT`: resolve local rules in plug-ins without prefix ([`640e411a`](https://github.com/bpmn-io/bpmnlint/commit/640e411ac8c6045198bd09b79b5c53c6e29e251c))
86
-
87
- ## 6.0.0
88
-
89
- * `FEAT`: resolve plug-in provided rules/configuration local to working directory ([`f1bf331f`](https://github.com/bpmn-io/bpmnlint/commit/f1bf331f4bcece62de16da34bb3f8fda08182fbc))
90
- * `CHORE`: improve errors on rule/plugin resolution failures
91
- * `CHORE`: require `>= node@10.12`
92
-
93
- ## 5.3.0
94
-
95
- * `FEAT`: add `--init` option to create `.bpmnlintrc` in current working directory
96
-
97
- ## 5.2.0
98
-
99
- * `FEAT`: provide help on missing `.bpmnlintrc`
100
-
101
- ## 5.1.2
102
-
103
- * `DOCS`: add package description
104
-
105
- ## 5.1.1
106
-
107
- * `CHORE`: exclude additional development assets from distribution
108
-
109
- ## 5.1.0
110
-
111
- * `FEAT`: add `no-duplicate-sequence-flows` rule ([#22](https://github.com/bpmn-io/bpmnlint/issues/22))
112
- * `FEAT`: catch more BPMN parse errors
113
- * `FEAT`: be able to define multiple expected test results in `RuleTester`
114
- * `FIX`: make `nyc` a development dependency
115
- * `CHORE`: update to `bpmn-moddle@6`
116
-
117
- ## 5.0.0
118
-
119
- * `FEAT`: don't expose utils to rules; use `bpmnlint-utils` instead
120
-
121
- ## 4.1.0
122
-
123
- * `FEAT`: handle and report diagram import errors and warnings via CLI
124
- * `FEAT`: properly handle generic moddle elements during rule checking
125
- * `FEAT`: report rule execution errors
126
-
127
- ## 4.0.0
128
-
129
- * `FEAT`: add ability to batch lint multiple files via CLI
130
- * `FEAT`: don't resolve disabled rules ([`6c45f3f9`](https://github.com/bpmn-io/bpmnlint/commit/6c45f3f952a412dda05deb5c57861a1c76af23bb))
131
- * `CHORE`: unify messages of built-in rules
132
- * `CHORE`: adopt cli output to eslint styling
133
-
134
- ## 3.3.1
135
-
136
- * `FIX`: handle empty flow element containers in rules
137
-
138
- ## 3.3.0
139
-
140
- * `FEAT`: do not expose disabled rules when bundling `.bpmnlintrc`
141
-
142
- ## 3.2.1
143
-
144
- * `DOCS`: fix readme code snippet
145
-
146
- ## 3.2.0
147
-
148
- * `FEAT`: add ability to pass linter configuration via constructor
149
-
150
- ## 3.1.0
151
-
152
- * `FEAT`: add support script to compile `.bpmnlintrc` files to JavaScript ([`cf53a389`](https://github.com/bpmn-io/bpmnlint/commit/cf53a3894b6bd821e18ddfc7bdaa8da857356a37))
153
-
154
- ## 3.0.0
155
-
156
- #### Breaking Changes
157
-
158
- * `FEAT`: treat unprefixed rules as built-in ones
159
-
160
- ## 2.0.0
161
-
162
- #### Breaking Changes
163
-
164
- * `CHORE`: make `NodeResolver` a constructor
165
- * `CHORE`: unify file names to `dashed-case`
166
- * `CHORE`: rework `Resolver` APIs
167
-
168
- #### Other Enhancements
169
-
170
- * `FEAT`: add `StaticResolver` to load cached resources
171
- * `FEAT`: add `{ Linter }` as a library export
172
- * `CHORE`: move rule and config name resolution to linter
173
- * `CHORE`: catch all cli errors and exit accordingly
174
-
175
- ## 1.0.0
176
-
177
- * `FEAT`: add numerous new rules ([#5](https://github.com/bpmn-io/bpmnlint/issues/5))
178
- * `FEAT`: add `bpmnlint:all` configuration
179
- * `FEAT`: improve `label-required` rule ([#11](https://github.com/bpmn-io/bpmnlint/issues/11))
180
- * `FEAT`: group lint results by rule names
181
- * `FEAT`: exit cli with code=1 on lint errors
182
- * `FEAT`: add `isAny(node, [ ... types ])` method to `utils`
183
- * `CHORE`: improve / test cover existing rules
184
- * `CHORE`: include new rules in `bpmnlint:recommended` configuration
185
-
186
- ## 1.0.0-alpha6
187
-
188
- * `DOCS`: documentation simplification / improvements
189
-
190
- ## 1.0.0-alpha5
191
-
192
- _Initial stable release._
193
-
194
- * `FEAT`: configure, resolve and execute local and external rules
195
- * `FEAT`: extend external configuration via `extends`
196
- * `FEAT`: make rule and configuration resolution async
197
- * `FEAT`: provide `bpmnlint:recommended` configuration
198
- * `CHORE`: `linter` is now a constructor, offering a `#lint(moddleElement, config)` method
199
- * `CHORE`: moved library to [bpmn-io/bpmnlint](https://github.com/bpmn-io/bpmnlint)
200
- * `CHORE`: full rewrite of internals
201
- * `CHORE`: `utils` API change
202
-
203
- ## ...
204
-
205
- Check `git log` for earlier history.