Refactor: rewrite configuration loading
Currently the configuration loading is tightly coupled with the HtmlValidate
and Engine
classes and in both Config
and ConfigLoader
relies on fs
to support traversing the filesystem to find and merge configuration files.
This is an issue when bundling with webpack and trying to run under a browser environment.
-
fs
might not be available (e.g. in a browser context) -
Config
andConfigLoader
usesfs.exists
andfs.readFile
to load files.
Suggested implementation
Decouple Config
from HtmlValidate
and Engine
. Let both Config
and ConfigLoader
be interfaces and pass a ConfigLoader
as a template argument to the HtmlValidate
class. The current config implementation should be migrated to a FileSystemConfig
but it should also provide a static configuration loader to pass a fixed config using API.
Both should be exposed and API users should be able to write their own implementations.
As for bundling the pure API should never require FileSystemConfig
but rather the CLI should be the natural consumer of that API.