bpmnlint 11.12.1 → 11.13.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.
Files changed (47) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +203 -203
  3. package/bin/bpmnlint.js +437 -437
  4. package/config/all.js +38 -37
  5. package/config/correctness.js +12 -12
  6. package/config/recommended.js +29 -29
  7. package/lib/index.js +4 -4
  8. package/lib/linter.js +542 -542
  9. package/lib/resolver/helper.js +12 -12
  10. package/lib/resolver/node-resolver.js +135 -135
  11. package/lib/resolver/static-resolver.js +47 -47
  12. package/lib/support/compile-config.js +200 -200
  13. package/lib/test-rule.js +107 -107
  14. package/lib/testers/helper.js +72 -72
  15. package/lib/testers/rule-tester.d.ts +36 -36
  16. package/lib/testers/rule-tester.js +146 -146
  17. package/lib/traverse.js +56 -56
  18. package/lib/types.d.ts +80 -80
  19. package/package.json +74 -73
  20. package/rules/ad-hoc-sub-process.js +43 -43
  21. package/rules/conditional-event.js +51 -51
  22. package/rules/conditional-flows.js +57 -57
  23. package/rules/end-event-required.js +45 -45
  24. package/rules/event-based-gateway.js +44 -44
  25. package/rules/event-sub-process-typed-start-event.js +43 -43
  26. package/rules/fake-join.js +40 -40
  27. package/rules/global.js +145 -145
  28. package/rules/helper.js +123 -123
  29. package/rules/label-required.js +75 -75
  30. package/rules/link-event.js +106 -106
  31. package/rules/no-bpmndi.js +157 -157
  32. package/rules/no-complex-gateway.js +2 -2
  33. package/rules/no-disconnected.js +82 -82
  34. package/rules/no-duplicate-sequence-flows.js +69 -69
  35. package/rules/no-gateway-join-fork.js +35 -35
  36. package/rules/no-implicit-end.js +98 -98
  37. package/rules/no-implicit-split.js +55 -55
  38. package/rules/no-implicit-start.js +69 -69
  39. package/rules/no-inclusive-gateway.js +2 -2
  40. package/rules/no-overlapping-elements.js +196 -196
  41. package/rules/single-blank-start-event.js +47 -47
  42. package/rules/single-event-definition.js +33 -33
  43. package/rules/standard-size.js +235 -0
  44. package/rules/start-event-required.js +45 -45
  45. package/rules/sub-process-blank-start-event.js +43 -43
  46. package/rules/superfluous-gateway.js +36 -36
  47. package/rules/superfluous-termination.js +70 -70
@@ -1,12 +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
+ 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,136 +1,136 @@
1
- const path = require('node:path');
2
- const { cwd } = require('node:process');
3
-
4
- const { isString } = require('min-dash');
5
-
6
- /**
7
- * @typedef { import('../types.js').RuleFactory } RuleFactory
8
- * @typedef { import('../types.js').Config } Config
9
- */
10
-
11
- const { createScopedRequire } = require('./helper');
12
-
13
- /**
14
- * A resolver that locates rules and configurations
15
- * using node module resolution.
16
- *
17
- * @param { { require?: NodeRequire, requireLocal?: NodeRequire } } [options]
18
- */
19
- function NodeResolver(options) {
20
- this.require = options && options.require || createScopedRequire(cwd());
21
-
22
- this.requireLocal = options && options.requireLocal || require;
23
-
24
- try {
25
- this.pkg = this.require('./package.json').name;
26
- } catch (err) {
27
- this.pkg = '__unknown';
28
- }
29
- }
30
-
31
- module.exports = NodeResolver;
32
-
33
-
34
- /**
35
- * @param { string } pkg
36
- * @param { string } ruleName
37
- *
38
- * @return { RuleFactory }
39
- */
40
- NodeResolver.prototype.resolveRule = function(pkg, ruleName) {
41
-
42
- const originalPkg = pkg;
43
-
44
- pkg = this.normalizePkg(pkg);
45
-
46
- let pkgInstance;
47
-
48
- // (1) try resolving rule via $PKG.rules[$NAME]
49
- try {
50
- pkgInstance = this.require(pkg);
51
- } catch (err) {
52
-
53
- /* ignore */
54
- }
55
-
56
- if (pkgInstance) {
57
- const rules = pkgInstance.rules || {};
58
-
59
- if (ruleName in rules) {
60
- const rule = rules[ruleName];
61
-
62
- if (!isString(rule)) {
63
- throw new Error('cannot resolve rule <' + ruleName + '> from <' + originalPkg + '>: illegal rule export (expected path reference)');
64
- }
65
-
66
- // local reference, resolved relative to pkg location
67
- if (rule.startsWith('.')) {
68
- const pkgDir = path.dirname(this.require.resolve(pkg));
69
-
70
- return this.require(path.posix.normalize(`${ pkgDir }/${ rule }`));
71
- }
72
-
73
- // absolute reference
74
- return this.require(rule);
75
- }
76
- }
77
-
78
- // (2) try resolving rule via $PKG/rules/$NAME
79
- try {
80
- if (pkg === 'bpmnlint') {
81
- return this.requireLocal(`../../rules/${ruleName}`);
82
- } else {
83
- return this.require(`${pkg}/rules/${ruleName}`);
84
- }
85
- } catch (err) { /* ignore */ }
86
-
87
- throw new Error('cannot resolve rule <' + ruleName + '> from <' + originalPkg + '>');
88
- };
89
-
90
- /**
91
- * @param { string } pkg
92
- * @param { string } configName
93
- *
94
- * @return { Config }
95
- */
96
- NodeResolver.prototype.resolveConfig = function(pkg, configName) {
97
-
98
- const originalPkg = pkg;
99
-
100
- pkg = this.normalizePkg(pkg);
101
-
102
- // (1) try resolving config via $PKG.configs[$NAME]
103
- try {
104
- const instance = this.require(pkg);
105
-
106
- const configs = instance.configs || {};
107
-
108
- if (configName in configs) {
109
- return configs[configName];
110
- }
111
- } catch (err) {
112
-
113
- /* ignore */
114
- }
115
-
116
- // (2) try resolving config via $PKG/config/$NAME
117
- try {
118
- if (pkg === 'bpmnlint') {
119
- return this.requireLocal(`../../config/${configName}`);
120
- } else {
121
- return this.require(`${pkg}/config/${configName}`);
122
- }
123
- } catch (err) { /* ignore */ }
124
-
125
- throw new Error(
126
- 'cannot resolve config <' + configName + '> from <' + originalPkg + '>'
127
- );
128
- };
129
-
130
- NodeResolver.prototype.normalizePkg = function(pkg) {
131
- if (pkg !== 'bpmnlint' && pkg === this.pkg) {
132
- pkg = '.';
133
- }
134
-
135
- return pkg;
1
+ const path = require('node:path');
2
+ const { cwd } = require('node:process');
3
+
4
+ const { isString } = require('min-dash');
5
+
6
+ /**
7
+ * @typedef { import('../types.js').RuleFactory } RuleFactory
8
+ * @typedef { import('../types.js').Config } Config
9
+ */
10
+
11
+ const { createScopedRequire } = require('./helper');
12
+
13
+ /**
14
+ * A resolver that locates rules and configurations
15
+ * using node module resolution.
16
+ *
17
+ * @param { { require?: NodeRequire, requireLocal?: NodeRequire } } [options]
18
+ */
19
+ function NodeResolver(options) {
20
+ this.require = options && options.require || createScopedRequire(cwd());
21
+
22
+ this.requireLocal = options && options.requireLocal || require;
23
+
24
+ try {
25
+ this.pkg = this.require('./package.json').name;
26
+ } catch (err) {
27
+ this.pkg = '__unknown';
28
+ }
29
+ }
30
+
31
+ module.exports = NodeResolver;
32
+
33
+
34
+ /**
35
+ * @param { string } pkg
36
+ * @param { string } ruleName
37
+ *
38
+ * @return { RuleFactory }
39
+ */
40
+ NodeResolver.prototype.resolveRule = function(pkg, ruleName) {
41
+
42
+ const originalPkg = pkg;
43
+
44
+ pkg = this.normalizePkg(pkg);
45
+
46
+ let pkgInstance;
47
+
48
+ // (1) try resolving rule via $PKG.rules[$NAME]
49
+ try {
50
+ pkgInstance = this.require(pkg);
51
+ } catch (err) {
52
+
53
+ /* ignore */
54
+ }
55
+
56
+ if (pkgInstance) {
57
+ const rules = pkgInstance.rules || {};
58
+
59
+ if (ruleName in rules) {
60
+ const rule = rules[ruleName];
61
+
62
+ if (!isString(rule)) {
63
+ throw new Error('cannot resolve rule <' + ruleName + '> from <' + originalPkg + '>: illegal rule export (expected path reference)');
64
+ }
65
+
66
+ // local reference, resolved relative to pkg location
67
+ if (rule.startsWith('.')) {
68
+ const pkgDir = path.dirname(this.require.resolve(pkg));
69
+
70
+ return this.require(path.posix.normalize(`${ pkgDir }/${ rule }`));
71
+ }
72
+
73
+ // absolute reference
74
+ return this.require(rule);
75
+ }
76
+ }
77
+
78
+ // (2) try resolving rule via $PKG/rules/$NAME
79
+ try {
80
+ if (pkg === 'bpmnlint') {
81
+ return this.requireLocal(`../../rules/${ruleName}`);
82
+ } else {
83
+ return this.require(`${pkg}/rules/${ruleName}`);
84
+ }
85
+ } catch (err) { /* ignore */ }
86
+
87
+ throw new Error('cannot resolve rule <' + ruleName + '> from <' + originalPkg + '>');
88
+ };
89
+
90
+ /**
91
+ * @param { string } pkg
92
+ * @param { string } configName
93
+ *
94
+ * @return { Config }
95
+ */
96
+ NodeResolver.prototype.resolveConfig = function(pkg, configName) {
97
+
98
+ const originalPkg = pkg;
99
+
100
+ pkg = this.normalizePkg(pkg);
101
+
102
+ // (1) try resolving config via $PKG.configs[$NAME]
103
+ try {
104
+ const instance = this.require(pkg);
105
+
106
+ const configs = instance.configs || {};
107
+
108
+ if (configName in configs) {
109
+ return configs[configName];
110
+ }
111
+ } catch (err) {
112
+
113
+ /* ignore */
114
+ }
115
+
116
+ // (2) try resolving config via $PKG/config/$NAME
117
+ try {
118
+ if (pkg === 'bpmnlint') {
119
+ return this.requireLocal(`../../config/${configName}`);
120
+ } else {
121
+ return this.require(`${pkg}/config/${configName}`);
122
+ }
123
+ } catch (err) { /* ignore */ }
124
+
125
+ throw new Error(
126
+ 'cannot resolve config <' + configName + '> from <' + originalPkg + '>'
127
+ );
128
+ };
129
+
130
+ NodeResolver.prototype.normalizePkg = function(pkg) {
131
+ if (pkg !== 'bpmnlint' && pkg === this.pkg) {
132
+ pkg = '.';
133
+ }
134
+
135
+ return pkg;
136
136
  };
@@ -1,48 +1,48 @@
1
- /**
2
- * @typedef { import('../types.js').RuleFactory } RuleFactory
3
- * @typedef { import('../types.js').Config } Config
4
- */
5
-
6
-
7
- /**
8
- * A resolver that resolves rules and packages from a static cache.
9
- *
10
- * @param { any } cache
11
- */
12
- function StaticResolver(cache) {
13
- this.cache = cache;
14
- }
15
-
16
- module.exports = StaticResolver;
17
-
18
- /**
19
- * @param { string } pkg
20
- * @param { string } ruleName
21
- *
22
- * @return { RuleFactory }
23
- */
24
- StaticResolver.prototype.resolveRule = function(pkg, ruleName) {
25
- return /** @type { RuleFactory } */ (this.resolve('rule', pkg, ruleName));
26
- };
27
-
28
- /**
29
- * @param { string } pkg
30
- * @param { string } configName
31
- *
32
- * @return { Config }
33
- */
34
- StaticResolver.prototype.resolveConfig = function(pkg, configName) {
35
- return /** @type { Config } */ (this.resolve('config', pkg, configName));
36
- };
37
-
38
- StaticResolver.prototype.resolve = function(type, pkg, name) {
39
- const id = `${pkg}/${name}`;
40
-
41
- const resolved = this.cache[`${type}:${id}`];
42
-
43
- if (!resolved) {
44
- throw new Error(`unknown ${type} <${id}>`);
45
- }
46
-
47
- return resolved;
1
+ /**
2
+ * @typedef { import('../types.js').RuleFactory } RuleFactory
3
+ * @typedef { import('../types.js').Config } Config
4
+ */
5
+
6
+
7
+ /**
8
+ * A resolver that resolves rules and packages from a static cache.
9
+ *
10
+ * @param { any } cache
11
+ */
12
+ function StaticResolver(cache) {
13
+ this.cache = cache;
14
+ }
15
+
16
+ module.exports = StaticResolver;
17
+
18
+ /**
19
+ * @param { string } pkg
20
+ * @param { string } ruleName
21
+ *
22
+ * @return { RuleFactory }
23
+ */
24
+ StaticResolver.prototype.resolveRule = function(pkg, ruleName) {
25
+ return /** @type { RuleFactory } */ (this.resolve('rule', pkg, ruleName));
26
+ };
27
+
28
+ /**
29
+ * @param { string } pkg
30
+ * @param { string } configName
31
+ *
32
+ * @return { Config }
33
+ */
34
+ StaticResolver.prototype.resolveConfig = function(pkg, configName) {
35
+ return /** @type { Config } */ (this.resolve('config', pkg, configName));
36
+ };
37
+
38
+ StaticResolver.prototype.resolve = function(type, pkg, name) {
39
+ const id = `${pkg}/${name}`;
40
+
41
+ const resolved = this.cache[`${type}:${id}`];
42
+
43
+ if (!resolved) {
44
+ throw new Error(`unknown ${type} <${id}>`);
45
+ }
46
+
47
+ return resolved;
48
48
  };