remark-lint-no-html
raw JSON → 4.0.1 verified Fri May 01 auth: no javascript
A remark-lint rule that warns when raw HTML is used in Markdown documents. Version 4.0.1 is the current stable release, compatible with Node.js 16+. It is part of the remark-lint monorepo, which is maintained by the unified collective and releases updates alongside other lint rules. This rule helps enforce a pure Markdown writing style by disallowing inline HTML elements and comments, with an option to allow or disallow HTML comments. It is ESM-only and ships TypeScript types.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/remark-lint-no-html/index.js from /path/to/project not supported. ↓
cause The package is ESM-only (v4+), but you are using require() to load it in a CommonJS module.
fix
Convert your project to ESM (set type:module in package.json) or use dynamic import() with .cjs extension.
error TypeError: remarkLintNoHtml is not a function ↓
cause Attempted named import: import { remarkLintNoHtml } from 'remark-lint-no-html'. The package has no named export; only default export.
fix
Use default import: import remarkLintNoHtml from 'remark-lint-no-html'
error Cannot find module 'remark-lint-no-html' ↓
cause Package not installed or incorrect import path (e.g., missing .js extension in ESM).
fix
Install with npm install remark-lint-no-html and ensure import path is correct.
Warnings
breaking Version 4 is ESM-only, dropping CommonJS support. ↓
fix Switch to dynamic import() or migrate to an ESM project. Older versions can use require('remark-lint-no-html')
deprecated The option `allowComments` was renamed from `allowComment` in a previous version? (Not documented but check changelog). ↓
fix Use `allowComments` (boolean).
gotcha This rule is not included in any default remark-lint preset; you must add it manually. ↓
fix Add 'remark-lint-no-html' to your plugin list in unified or remark-cli config.
Install
npm install remark-lint-no-html yarn add remark-lint-no-html pnpm add remark-lint-no-html Imports
- remarkLintNoHtml wrong
const remarkLintNoHtml = require('remark-lint-no-html')correctimport remarkLintNoHtml from 'remark-lint-no-html' - Options wrong
import { Options } from 'remark-lint-no-html'correctimport type { Options } from 'remark-lint-no-html' - remarkLintNoHtml (default export) wrong
import { remarkLintNoHtml } from 'remark-lint-no-html'correctimport remarkLintNoHtml from 'remark-lint-no-html'
Quickstart
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkLint from 'remark-lint';
import remarkLintNoHtml from 'remark-lint-no-html';
import remarkStringify from 'remark-stringify';
import { reporter } from 'vfile-reporter';
const file = await unified()
.use(remarkParse)
.use(remarkLint)
.use(remarkLintNoHtml, { allowComments: false })
.use(remarkStringify)
.process('<h1>Hello</h1> <!-- comment -->');
console.error(reporter(file));
// 1:1-1:20: Unexpected HTML, use markdown instead
// 1:21-1:34: Unexpected HTML, use markdown instead