remark-lint-no-heading-punctuation

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

A remark-lint rule that warns when headings end in illegal characters such as punctuation marks. The current stable version is 4.0.1. It is part of the remark-lint ecosystem and is included in presets like `remark-preset-lint-markdown-style-guide`. It supports configurable options via a RegExp or string, allowing customization of which characters are flagged. This package is ESM-only and ships TypeScript types. It is actively maintained as part of the remark-lint monorepo.

error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
cause Attempting to use CommonJS require() on an ESM-only package.
fix
Use import remarkLintNoHeadingPunctuation from 'remark-lint-no-heading-punctuation' instead of require(...).
error Unexpected character `:` at end of heading, remove it
cause Heading ends with a punctuation mark that is disallowed by the rule's default configuration.
fix
Remove the trailing punctuation from the heading, or configure the rule to allow specific characters.
error TypeError: remarkLintNoHeadingPunctuation is not a function
cause The default export is imported incorrectly (e.g., using named import instead of default).
fix
Use import remarkLintNoHeadingPunctuation from 'remark-lint-no-heading-punctuation' (default import).
breaking Since version 4, the package is ESM-only and no longer supports CommonJS require().
fix Use `import` syntax instead of `require()`. Ensure your project is ESM or use dynamic import().
deprecated Options provided as a plain string are deprecated in favor of explicit RegExp or source object.
fix Pass a RegExp or an object with `source` property: `{ source: '[,:;]' }`.
gotcha When using a string option, it is wrapped in `new RegExp('[' + x + ']', 'u')` so characters like '.' need escaping.
fix Use RegExp directly or escape regex special characters in the string.
gotcha The rule must be used after the `remark-lint` plugin; otherwise it will not work.
fix Ensure `.use(remarkLint)` is called before `.use(remarkLintNoHeadingPunctuation)`.
gotcha In Node.js, the environment must support ESM (Node 16+).
fix Use Node 16 or later, or use dynamic imports in older Node with `--experimental-modules`.
npm install remark-lint-no-heading-punctuation
yarn add remark-lint-no-heading-punctuation
pnpm add remark-lint-no-heading-punctuation

Demonstrates usage of the remark-lint-no-heading-punctuation rule in a unified pipeline, processing a markdown file and reporting lint messages.

import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import remarkLint from 'remark-lint'
import remarkLintNoHeadingPunctuation from 'remark-lint-no-heading-punctuation'
import { reporter } from 'vfile-reporter'

const file = await unified()
  .use(remarkParse)
  .use(remarkLint)
  .use(remarkLintNoHeadingPunctuation)
  .use(remarkStringify)
  .process('# Mercury:')

console.error(reporter(file))
// Output: 1:1-1:10: Unexpected character `:` at end of heading, remove it