remark-lint-emphasis-marker

raw JSON →
4.0.1 verified Fri May 01 auth: no javascript

remark-lint rule to warn when emphasis markers (asterisks vs underscores) violate a given or consistent style. Current stable version is 4.0.1, ESM-only, requires Node.js 16+. Part of the unified/remark ecosystem, ships TypeScript types. Integrates with remark-lint presets like `remark-preset-lint-consistent` and `remark-preset-lint-markdown-style-guide`. Distributed as a scoped package on npm. Includes CLI support via remark CLI.

error ERR_REQUIRE_ESM: require() of ES Module not supported
cause Using CommonJS require() on an ESM-only package.
fix
Switch to import syntax: import remarkLintEmphasisMarker from 'remark-lint-emphasis-marker';
error TypeError: remarkLintEmphasisMarker is not a function
cause Missing or incorrect usage with unified: possibly forgot .use() or passed options incorrectly.
fix
Ensure correct usage: unified().use(remarkLintEmphasisMarker, '*'). The function is a plugin, not a standalone linter.
error Cannot find module 'remark-lint'
cause Missing required peer dependency 'remark-lint'.
fix
Install remark-lint: npm install remark-lint
breaking Package is ESM-only starting from v4.0.0. Requires Node.js 16+ and cannot be required with CommonJS.
fix Use import syntax and ensure Node.js 16+. If you must use CommonJS, stick with v3.x.
gotcha The default option is 'consistent', which auto-detects the first emphasis marker and warns on mismatches. Explicitly setting to '*' or '_' enforces that specific marker.
fix Specify the desired marker explicitly to avoid unexpected behavior: .use(remarkLintEmphasisMarker, '*')
deprecated TypeScript type Options previously accepted arbitrary strings; now tightly typed as Marker | 'consistent'.
fix Update TypeScript usage to only use '*' | '_' | 'consistent'.
gotcha Only supports '*' and '_' markers. Other characters (like '~') are not valid for emphasis in Markdown and are ignored by this rule.
fix Use only '*' or '_' for emphasis markers in Markdown content.
npm install remark-lint-emphasis-marker
yarn add remark-lint-emphasis-marker
pnpm add remark-lint-emphasis-marker

Lint emphasis markers in a Markdown file, enforcing asterisks as the preferred marker.

import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import remarkLint from 'remark-lint';
import remarkLintEmphasisMarker from 'remark-lint-emphasis-marker';
import { read } from 'to-vfile';
import { reporter } from 'vfile-reporter';

const file = await read('example.md');

await unified()
  .use(remarkParse)
  .use(remarkLint)
  .use(remarkLintEmphasisMarker, '*')
  .use(remarkStringify)
  .process(file);

console.error(reporter(file));