remark-lint-no-shortcut-reference-image

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

remark-lint rule to warn when shortcut reference images are used in Markdown. Shortcut references like ![text] look similar to plain text and can cause ambiguity; this rule enforces the use of collapsed or full reference images ([text][] or [text][reference]) to improve clarity. Current version is 4.0.1, part of the remark-lint monorepo. Releases follow semver; breaking changes may occur with major version bumps. This package is ESM-only, ships TypeScript types, and is recommended for consistent reference image syntax.

error ERR_REQUIRE_ESM: require() of ES Module
cause Using require() with an ESM-only package in a CommonJS context.
fix
Use import or dynamic import: const remarkLintNoShortcutReferenceImage = (await import('remark-lint-no-shortcut-reference-image')).default;
error TypeError: remarkLintNoShortcutReferenceImage is not a function
cause Attempting to use the package as an object or calling it directly without the unified pipeline.
fix
Use the package as a unified plugin: .use(remarkLintNoShortcutReferenceImage).
error Cannot find module 'remark-lint-no-shortcut-reference-image'
cause Package not installed or missing in package.json.
fix
Run npm install remark-lint-no-shortcut-reference-image.
breaking The package is ESM-only since version 4.0.0. You cannot use require() in CommonJS without dynamic import.
fix Switch to ESM (import/export) or use dynamic import: const module = await import('remark-lint-no-shortcut-reference-image');
breaking Export changed from named export to default export in version 4.0.0. Importing { remarkLintNoShortcutReferenceImage } will break.
fix Use default import: import remarkLintNoShortcutReferenceImage from 'remark-lint-no-shortcut-reference-image';
gotcha The rule has no configuration options. Providing an options object will be silently ignored but may cause confusion.
fix Do not pass options; simply use .use(remarkLintNoShortcutReferenceImage).
deprecated Shortcut reference images are discouraged for accessibility reasons. This rule may be merged into a more general rule in the future.
fix Follow recommendations to use collapsed or full references.
npm install remark-lint-no-shortcut-reference-image
yarn add remark-lint-no-shortcut-reference-image
pnpm add remark-lint-no-shortcut-reference-image

Lint a Markdown string for shortcut reference images using the unified ecosystem. The rule warns, does not modify.

import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import remarkLint from 'remark-lint';
import remarkLintNoShortcutReferenceImage from 'remark-lint-no-shortcut-reference-image';
import { reporter } from 'vfile-reporter';

const file = await unified()
  .use(remarkParse)
  .use(remarkLint)
  .use(remarkLintNoShortcutReferenceImage)
  .use(remarkStringify)
  .process('![bad reference]\n\n[bad reference]: https://example.com/image.png');

console.log(reporter(file));
// Output: 1:1-1:16: Unexpected shortcut reference image (`![text]`), expected collapsed reference (`![text][]`)