Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
html-validate
Advanced tools
Offline HTML5 validator. Validates either a full document or a smaller (incomplete) template, e.g. from an AngularJS or Vue.js component.
npm install -g html-validate
html-validate [OPTIONS] [FILENAME..] [DIR..]
Create .htmlvalidate.json
:
{
"extends": [
"html-validate:recommended"
],
"rules": {
"close-order": "error",
"void": ["warn", {"style": "omit"}]
}
}
<p>
<button>Click me!</button>
<div id="show-me">
Lorem ipsum
</div>
</p>
1:1 error Element <p> is implicitly closed by adjacent <div> no-implicit-close
2:2 error Button is missing type attribute button-type
6:4 error Unexpected close-tag, expected opening tag close-order
The library comes in four flavours:
dist/cjs/main.js
)dist/cjs/browser.js
)dist/es/main.js
)dist/es/browser.js
)The browser versions contains a slimmed version without CLI dependencies. Your tooling will probably use the correct version but if needed you can import the files directly.
Do note that to run in a browser you still need to polyfill the fs
nodejs library.
Browsers and bundlers are currently not 100% supported but is possible with some tricks, see running in browser for more details.
Some files are automatically generated by the toolchain but are required by many other steps such as testing and linting.
This normally happens during npm run build
and npm install
.
If you need to manually regenerate the files use:
npm run codegen
Testing is done using jest.
npm test
or call jest
directly.
Some tests are autogenerated from documentation examples, use npm run docs
to build those before running.
Linting is done using ESLint.
npm run eslint
or call eslint
directly.
npm run build
To build documentation use:
npm run docs
The documentation can be served locally using:
npm start
8.0.0 (2023-06-04)
See {@link migration migration guide} for details.
ConfigFactory
parameter to ConfigLoader
(and its child
classes StaticConfigLoader
and FileSystemConfigLoader
) has been removed. No
replacement.If you are using this you are probably better off implementing a fully custom
loader later returning a ResolvedConfig
.
getContextualDocumentation
replaces the now deprecated
getRuleDocumentation
method. The context parameter to getRuleDocumentation
is now required and must not be omitted.For rule authors this means you can now rely on the context
parameter being
set in the documentation
callback.
For IDE integration and toolchain authors this means you should migrate to use
getContextualDocumentation
as soon as possible or if you are continuing to use
getRuleDocumentation
you are now required to pass the config
and context
field from the reported message.
Config
class. Additionally when using the
StaticConfigLoader
no modules will be resolved using require(..)
by default
any longer. Instructions for running in a browser is also updated, see below.To create a Config
instance you must now pass in a Resolver
(single or
array):
+const resolvers = [ /* ... */ ];
-const config = new Config( /* ... */ );
+const config = new Config(resolvers, /* ... */ );
This applies to calls to Config.fromObject(..)
as well.
The default resolvers for StaticConfigLoader
is StaticResolver
and for
FileSystemConfigLoader
is NodeJSResolver
. Both can optionally take a new set
of resolvers (including custom ones).
Each resolver will, in order, try to load things by name. For instance, when
using the NodeJSResolver
it uses require(..)
to load new items.
NodeJSResolver
- uses require(..)
StaticResolver
- uses a predefined set of items.HtmlValidate
class now has a Promise
based API where most
methods return a promise. The old synchronous methods are renamed.Either adapt to the new asynchronous API:
-const result = htmlvalidate.validateFile("my-awesome-file.html");
+const result = await htmlvalidate.validateFile("my-awesome-file.html");
or migrate to the synchronous API:
-const result = htmlvalidate.validateFile("my-awesome-file.html");
+const result = htmlvalidate.validateFileSync("my-awesome-file.html");
For unittesting with Jest it is recommended to make the entire test-case async:
-it("my awesome test", () => {
+it("my awesome test", async () => {
const htmlvalidate = new HtmlValidate();
- const report = htmlvalidate.validateString("...");
+ const report = await htmlvalidate.validateString("...");
expect(report).toMatchCodeFrame();
});
ConfigLoader
must return ResolvedConfig
. This change
affects API users who implements custom configuration loaders.In the simplest case this only requires to call Config.resolve()
:
-return config;
+return config.resolve();
A resolved configuration cannot further reference any new files to extend, plugins to load, etc.
TemplateExtractor
class has been moved to the
@html-validate/plugin-utils
package. This change only affects API users who
use the TemplateExtractor
class, typically this is only used when writing
plugins.disabled
removed. If you use this in your
configuration you need to update it to off
. {
"rules": {
- "my-awesome-rule": "disabled"
+ "my-awesome-rule": "off"
}
}
void
rule has been removed after being deprecated a long
time, it is replaced with the separate void-content
, void-style
and
no-self-closing
rules.ConfigLoader
must return ResolvedConfig
(d685e6a)FileSystemConfigLoader
supports passing a custom fs
-like object (fac704e)Promise
based API to HtmlValidate
class (adc7783)Resolver
classes as a mean to separate fs
from browser build (3dc1724)getContextualDocumentation
to replace getRuleDocumentation
(60c9a12)ConfigFactory
(e309d89)TemplateExtractor
in favour of @html-validate/plugin-utils
(a0a512b)void
rule (3e727d8)disabled
(6282293)FAQs
Offline html5 validator
The npm package html-validate receives a total of 96,435 weekly downloads. As such, html-validate popularity was classified as popular.
We found that html-validate demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.