Registry / testing / html-minifier-lint

html-minifier-lint

JSON →
library2.0.0jsnpmunverified

JavaScript-based HTML linter built on top of HTMLMinifier. Version 2.0.0 is the latest stable release. It checks HTML for common issues such as missing DOCTYPE, inline event handlers, deprecated attributes, and more. The library provides a simple lint function for programmatic use as well as a CLI. Unlike full-featured linters like HTMLHint or tidy, HTMLLint focuses on core validation rules from HTMLMinifier. It works with Node.js >=0.10.0 and has no required dependencies.

npm install html-minifier-lint
INSTALL
IMPORT
SIG · HTML-MINIFIER-LINT
H
html-minifier-lint
testingjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

lint
const { lint } = require('html-minifier-lint');
const lint = require('html-minifier-lint');
The default export is an object with lint function; destructure or use .lint.
lint
import { lint } from 'html-minifier-lint';
import lint from 'html-minifier-lint';
ESM import must use named import. Only works with Node >=12 or bundlers.
LintStream
const { LintStream } = require('html-minifier-lint');
LintStream is a transform stream that lints HTML chunks.

Shows how to require and use the lint function, including custom options to disable specific checks.

const { lint } = require('html-minifier-lint'); // Sample HTML with missing DOCTYPE and deprecated attribut const html = '<p title="blah" id="moo" bgcolor="red">foo</p>'; const result = lint(html); console.log(result); // Output: // - No DOCTYPE found. // - Attribute 'bgcolor' is not valid. // With options const options = { 'missing-doctype': true, 'attr-name': false }; const filtered = lint(html, options); console.log(filtered); // Only shows non-attribute issues if attr-name turned off.
Debug
Known issues
gotchaThe lint function returns a string, not a boolean or list of errors. Always check length or compare to empty string.
fix
const result = lint(html); if (result !== '') { console.log(result); }
affects: >=0.0.0
gotchaPassing an empty string or null to lint may throw an error. Always validate input.
fix
if (typeof html !== 'string') throw new TypeError('html must be a string');
affects: >=0.0.0
breakingVersion 2.0.0 removed the old CLI option '--help' short alias? Check docs.
fix
Use 'html-minifier-lint --help' (no short alias).
affects: 2.0.0
deprecatedThe 'lint' function's second argument options object may change in future. Rules are subject to deprecation.
fix
Keep rules list from documentation or test suite.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: lint is not a function
Importing the module without destructuring the exports object.
fix
const { lint } = require('html-minifier-lint'); instead of const lint = require('html-minifier-lint');
Cannot find module 'html-minifier-lint'
Package not installed or installed under different name (e.g., html-lint from git).
fix
Run 'npm install html-minifier-lint' and ensure it's in node_modules.
- No DOCTYPE found.
HTMLLint reporting missing DOCTYPE. This is a lint result, not an error.
fix
Add <!DOCTYPE html> to the HTML input to remove this warning.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
html-minifier-lint — npm install html-minifier-lint · libregistry