Registry / testing / metalsmith-html-linter

metalsmith-html-linter

JSON →
library2.0.13jsnpmunverified

A Metalsmith plugin to lint HTML for syntax and semantics using linthtml/htmllint. Current stable version is 2.0.13, compatible with Metalsmith ^2.5.0 and Node >=20.18.1. It catches HTML violations during the build process, stopping the build on errors. Default rules ban deprecated attributes and tags, with options for custom lint config, ignored tags, and parallelism. Supports both ESM and TypeScript.

npm install metalsmith-html-linter
INSTALL
IMPORT
SIG · METALSMITH-HTML-LI
M
metalsmith-html-linter
testingjavascriptv2.0.13
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.

linter
import linter from 'metalsmith-html-linter'
const linter = require('metalsmith-html-linter')
Package is ESM-only since Node >=20.18.1; CommonJS require will fail.
Metalsmith
import Metalsmith from 'metalsmith'
const Metalsmith = require('metalsmith')
Metalsmith itself is also ESM-only in recent versions.
default export
import linter from 'metalsmith-html-linter'
import { linter } from 'metalsmith-html-linter'
The plugin is a default export, not a named export.

Shows basic usage of metalsmith-html-linter plugin with custom linthtml options, ignoring tags, and parallelism.

import Metalsmith from 'metalsmith'; import linter from 'metalsmith-html-linter'; Metalsmith(__dirname) .source('./src') .destination('./build') .use(linter({ html: '**/*.html', linthtml: { 'attr-bans': ['align', 'bgcolor', 'border'], 'doctype-first': true, 'tag-bans': ['font', 'center'] }, ignoreTags: ['code', 'pre', 'svg', 'textarea'], parallelism: 4 })) .build((err) => { if (err) throw err; });
Debug
Known issues
gotchaPackage requires Node >=20.18.1 and is ESM-only; older Node versions or CommonJS require will fail.
fix
Update Node to >=20.18.1 and use ESM imports exclusively.
affects: >=2.0.0
gotchaDefault linthtml rules are not HTML5-compliant; many deprecated attributes are banned by default.
fix
Override default rules in the `linthtml` option to suit your project's standards.
affects: >=1.0.0
deprecatedThe `htmllint` option is deprecated in favor of `linthtml`; future versions may drop support.
fix
Use `linthtml` option instead of `htmllint`.
affects: >=2.0.0
gotchaIgnored tags (code, pre, svg, textarea) are removed before linting; their content will not be flagged.
fix
Adjust `ignoreTags` if you want linting inside those elements.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
Trying to use require() on an ESM-only package.
fix
Use ESM imports (import linter from 'metalsmith-html-linter').
TypeError: linter is not a function
Importing a named export instead of default.
fix
Use import linter from 'metalsmith-html-linter' (no braces).
Unhandled rejection: Error: Build cancelled due to HTML lint errors
HTML files violate configured lint rules.
fix
Fix HTML errors or adjust linthtml options to be less strict.
Upgrade
Version history
2.0.13latest on npm
Audit
Dependencies
metalsmithrequiredpeer dependency required for plugin context
Agent activity
2 hits · last 30 days
node
2
Resources
metalsmith-html-linter — npm install metalsmith-html-linter · libregistry