Open philippfromme opened 2 years ago
Root causing this:
foo
to the actual package foo
but would always assume it is called bpmnlint-plugin-foo
There should be documentation or an example of configuring the linter without a plugin.
I'd be interested in a short summary, what you're trying to do: How do you want to configure / consume rules outside of a plug-in and how would you assume this works?
Created a simple example to reproduce this case.
I want to customize the rules, but I don't know how to add the custom rules to the cache of bpmnlint
@JessYan0913 Thanks for sharing your use-case. We want to look into this some time in the future.
Thanks for sharing your use-case. We want to look into this some time in the future. I think it's OK to add the custom check method to the cache, but can the cache be added by
setlinterconfig()
?
No. The cache is internal and not meant to fiddle around with.
Instead: Consider how you mark your rules as local in .bpmnlintrc
. Allow the parse to recognize these local rules.
No. The cache is internal and not meant to fiddle around with.
Instead: Consider how you mark your rules as local in
.bpmnlintrc
. Allow the parse to recognize these local rules.
How should i make it .bpmnlinter
recognizes local rules
Instead: Consider how you mark your rules as local in .bpmnlintrc. Allow the parse to recognize these local rules
Not you should consider it, but we have to build it. It is a missing feature.
As a workaround you have to define your rules in a dedicated bpmnlint plug-in. Local rules are not supported at the moment.
Instead: Consider how you mark your rules as local in .bpmnlintrc. Allow the parse to recognize these local rules
Not you should consider it, but we have to build it. It is a missing feature.
As a workaround you have to define your rules in a dedicated bpmnlint plug-in. Local rules are not supported at the moment.
OK, I hope I can use it as soon as possible 😂
@JessYan0913 hello, I currently have the same need as you. I need to supplement with my own rules. If you were able to add them, could you please share your experience on how you managed to do so?
Maybe you can override requireLocal option to load your custom rules
const config = {
config: {
extends: ['bpmnlint:myrules']
},
resolver: new NodeResolver({
requireLocal:(path) => {
if (path.includes('config/myrules')) {
const mrequire = createRequire(import.meta.url);
return mrequire("/app/config/myrules");
}
if (path.includes('rules')) {
//extract rule name from path
const ruleName = path.split('/').pop();
const mrequire = createRequire(import.meta.url);
return mrequire("/app/rules/"+ruleName);
}
return null;
}
})
};
const linter = new Linter(config);
I have not tested through, but a similar technique has used to load on a nextjs app.
Folks I apprechiate your input on this topic! To drive this forward I propose that someone contributes a "local rules" setup to our integration tests. We could then go ahead and turn the nobs to make it happen:
Is your feature request related to a problem? Please describe
The linter can be configured using
NodeResolver
,StaticResolver
or a custom one. Figuring out how to do this is quite difficult (cf. https://github.com/camunda/web-modeler/pull/1249#issuecomment-1125971172). In fact defining local rules is impossible at the moment.Describe the solution you'd like
There should be a well documented way how to configure a custom lint rule outside of a plug-in:
Describe alternatives you've considered
Using the source code and the tests I eventually figured out how to configure the linter but it took me quite long, and I don't know if I did it the way it's intended (cf. https://github.com/camunda/camunda-modeler/pull/2958).