bpmnlint 7.7.0 → 7.8.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/CHANGELOG.md +5 -0
- package/lib/linter.js +5 -4
- package/lib/testers/rule-tester.js +17 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,11 @@ All notable changes to [bpmnlint](https://github.com/bpmn-io/bpmnlint) are docum
|
|
|
6
6
|
|
|
7
7
|
___Note:__ Yet to be released changes appear here._
|
|
8
8
|
|
|
9
|
+
## 7.8.0
|
|
10
|
+
|
|
11
|
+
* `FEAT`: be able to configure rules ([#82](https://github.com/bpmn-io/bpmnlint/pull/82))
|
|
12
|
+
* `FEAT`: be able to configure rules when testing ([#83](https://github.com/bpmn-io/bpmnlint/pull/83))
|
|
13
|
+
|
|
9
14
|
## 7.7.0
|
|
10
15
|
|
|
11
16
|
* `FEAT`: fuzzy test for equality of nodes when using `RuleTester#verify` ([#79](https://github.com/bpmn-io/bpmnlint/pull/79/files))
|
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
|
|
@@ -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
|
-
|
|
20
|
-
|
|
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(({
|
|
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,
|
|
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(({
|
|
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,
|
|
82
|
+
return linter.lint(moddleRoot.root, createLinterConfig(config));
|
|
82
83
|
})
|
|
83
84
|
.then(lintResults => {
|
|
84
85
|
expectEqual(lintResults, expectedLintResults);
|
|
@@ -98,13 +99,6 @@ function getTitle(idx, name) {
|
|
|
98
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
|
+
};
|