remark-lint-mdash-style

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

A remark-lint rule to enforce a consistent style for em dashes (mdash) in Markdown files. Version 1.1.1 is the current stable release, with no fixed release cadence. It offers three style options: '―' (Unicode em dash, default), '-' (single hyphen), and '--' (double hyphen). Unlike general-purpose linters, this package specifically targets mdash usage, a common typographic inconsistency. It is a lightweight plugin for the remark-lint ecosystem, primarily used in Node.js environments for CI or text processing pipelines. The package has no dependencies and is ESM-compatible but requires a CommonJS or ESM project that uses remark-lint.

error Cannot find module 'remark-lint-mdash-style'
cause Package not installed or not in node_modules
fix
Run 'npm install remark-lint-mdash-style' and ensure it is in dependencies.
error Error [ERR_REQUIRE_ESM]: require() of ES Module ...
cause Trying to use require() for an ESM-only package
fix
Replace require() with import or use dynamic import: const plugin = (await import('remark-lint-mdash-style')).default;
error TypeError: remarkLintMdashStyle is not a function
cause Importing the wrong symbol (default vs named) when using older bundlers
fix
Ensure you import the default export: import remarkLintMdashStyle from 'remark-lint-mdash-style'.
error warning: Use `―` instead of `-` for mdash
cause The default style is the Unicode em dash, but the text contains a single hyphen
fix
Either change the text to use '—' or configure the rule with style: '--' or style: '-'.
breaking Package is ESM-only; CommonJS require() fails
fix Switch to import syntax or use dynamic import if in a CommonJS context.
deprecated Option style: '-' may be deprecated in future versions for clarity
fix Consider using '--' or the Unicode em dash '—' instead, as single hyphen is ambiguous with bullet lists.
gotcha Options must be passed as an object, not as a string directly
fix Use .use(plugin, { style: '--' }) instead of .use(plugin, '--').
gotcha Rule only checks text nodes; inline code blocks are excluded
fix If you need to lint inline code, consider additional remark plugins.
deprecated The default style '―' (Unicode em dash) may not be visible in all editors
fix Explicitly set a style that matches your project's conventions, e.g., '--'.
npm install remark-lint-mdash-style
yarn add remark-lint-mdash-style
pnpm add remark-lint-mdash-style

Shows how to use remark-lint-mdash-style with remark-lint in an ESM environment, including configuration and processing of a Markdown string.

import { remark } from 'remark';
import remarkLint from 'remark-lint';
import remarkLintMdashStyle from 'remark-lint-mdash-style';

const result = await remark()
  .use(remarkLint)
  .use(remarkLintMdashStyle, { style: '--' })
  .process('Some text - with hyphen instead of dash.');

if (result.messages.length > 0) {
  console.log(result.messages[0].reason);
} else {
  console.log('No lint errors');
}