Open atkinchris opened 1 month ago
hey, thanks for raising this issue. It was done intentionally if devs want to use the library with custom rules only. But I realize that the README does not reflect that requirement indeed. Do you think this process is problematic? Maybe we should just update the readme to clarify the situation
Wouldn the loadOne
API satisfy the need to use custom rules? The import side effect registers them, but in the fix proposed doesn't load them.
This adds an explicit import for the rules index file, to trigger the registration side effects of each rule being imported. Each rule file module runs
register
- and unless imported, that registration will not happen.This was already happening in the CLI, as it uses
autoload.ts
- which contained an explicit import for the rules module index. However, when using the library programmatically,rules.loadAll
would not have any registered rules to load.Work around
You can work around this issue at the moment by using
import '@specfy/stack-analyser/dist/autoload.js'
, or includingimport '@specfy/stack-analyser/dist/rules/index.js'
before runningrules.loadAll
.