This site uses cookies for analytics. By continuing to browse this site, you agree to this use.
A JS Foundation Project

HTML parser

HTML parser (@hint/parser-html)

The HTML parser is built on top of jsdom so hints can analyze HTML files.

Note: This parser is currently only needed if using the local connector. Other connectors provide their own DOM to generate events instead.

To use it you will have to install it via npm:

npm install @hint/parser-html

Note: You can make npm install it as a devDependency using the --save-dev parameter, or to install it globally, you can use the -g parameter. For other options see npm's documentation.

And then activate it via the .hintrc configuration file:

{
"connector": {...},
"formatters": [...],
"hints": {
...
},
"parsers": ["html"],
...
}

Events emitted

This parser emits the event parse::html of type HTMLParse which has the following information:

  • window: an IAsyncWindow object containing the parsed document.
  • html: a string containing the raw HTML source code.
  • resource: the parsed resource.

This parser also automatically traverses and emits events for elements in the tree (see events for details):

  • element::<element-type>
  • traverse::down
  • traverse::end
  • traverse::start
  • traverse::up
  • parse::html::end