Closed adroste closed 3 years ago
Sounds like an interesting feature request at hand. Could you be a little bit more concrete with what you consider a complex rule?
We're happy to improve the existing APIs. Exposing an additional check as you proposed could be a sensible improvement. To do that we'd need to understand the concrete problem at hand though.
I have a lot of custom rules that follow the scheme:
afterCheck
callbackAn afterCheck
callback is not necessary if you have a 2nd traversal pass hook. This could be combined with an early return/abort of the dfs traversal algorithm. See #53
https://github.com/bpmn-io/bpmnlint/pull/54 implements a simple extension to the given check
.
A rule may now be explicit about whether it would like to check a node on enter, leave, or both:
module.exports = function someRule() {
return {
check: {
enter: function(node, reporter) { ... },
leave: function(node, reporter) { ... }
}
};
}
Works for me, see https://github.com/bpmn-io/bpmnlint/pull/54#issuecomment-752307743
Is your feature request related to a problem? Please describe
Sometimes a rule is too complex to be calculated in a single pass. With workarounds it is often possible to collect and cache relevant elements/structures during a single traversal pass, but then a callback after traversal has finished is needed.
Describe the solution you'd like
Ability to hook into a 2nd traversal pass. This would be two lines inside
lib/test-rule.js
:Describe alternatives you've considered
Provide a callback after traversal finished. Would also be two lines inside
lib/test-rule.js
:Possible workarounds right now
Override the messages property on the reporter object to be a getter function.
This is obviously not a pretty solution.