BREAKING: feat(htmlvalidate)!: use `StaticConfigLoader` by default
BREAKING CHANGE: This change only affects API users, the CLI tool continues to work as before.
The default configuration loader has changed from FileSystemConfigLoader
to
StaticConfigLoader
, i.e. the directory traversal looking for
.htmlvalidate.json
configuration files must now be explicitly enabled.
This will reduce the dependency on the NodeJS fs
module and make it easier to
use the library in browsers.
To restore the previous behaviour you must now enable FileSystemConfigLoader
:
import { HtmlValidate, FileSystemConfigLoader } from "html-validate";
-const htmlvalidate = new HtmlValidate();
+const loader = new FileSystemConfigLoader();
+const htmlvalidate = new HtmlValidate(loader);
If you pass configuration to the constructor you now pass it to the loader instead:
import { HtmlValidate, FileSystemConfigLoader } from "html-validate";
-const htmlvalidate = new HtmlValidate({ ... });
+const loader = new FileSystemConfigLoader({ ... });
+const htmlvalidate = new HtmlValidate(loader);
If you use the root
property as a workaround for the directory traversal you
can now drop the workaround and rely on StaticConfigLoader
:
import { HtmlValidate } from "html-validate";
-const htmlvalidate = new HtmlValidate({
- root: true,
-});
+const htmlvalidate = new HtmlValidate();
The CLI class is not affected as it will enable FileSystemConfigLoader
automatically, so the following code will continue to work as expected:
const cli = new CLI();
const htmlvalidate = cli.getValidator();
Checklist
-
Documentation updated -
Change covered by a testcase -
Commit history cleaned (no WIP, fixups, etc)