remark-lint-no-empty-image-alt-text

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

A remark-lint rule that warns when image alt text is missing or empty, promoting accessibility. Current version 1.0.3, stable maintenance mode. Lightweight, focused solely on detecting empty alt text in Markdown images, unlike broader lint rules that may cover other accessibility concerns.

error Error: Cannot find module 'remark-lint-no-empty-image-alt-text'
cause Missing installation of the package.
fix
npm install remark-lint-no-empty-image-alt-text
error TypeError: remark().use is not a function
cause Importing remark incorrectly; using default import instead of named export.
fix
Use import { remark } from 'remark' instead of import remark from 'remark'.
error Warning: Missing alt text for image! no-empty-image-alt-text remark-lint
cause Valid lint warning – no fix needed, but alt text should be added.
fix
Add alt text inside the brackets: ![description](url)
gotcha The rule only checks for empty alt text (e.g., `![](url)`) but does not check for missing alt attribute in HTML `<img>` tags within Markdown.
fix Use additional lint rules to cover HTML img tags if needed.
gotcha When using CommonJS require, TypeScript may require esModuleInterop enabled to import default export.
fix Set esModuleInterop: true in tsconfig.json, or use import syntax with .default.
deprecated The package is in maintenance mode with no recent updates. Consider that future remark versions may break compatibility.
fix Monitor for newer versions or switch to a more active lint rule like `remark-lint-no-empty-alt-text`.
npm install remark-lint-no-empty-image-alt-text
yarn add remark-lint-no-empty-image-alt-text
pnpm add remark-lint-no-empty-image-alt-text

Shows how to use the rule with remark to lint an image lacking alt text.

import { remark } from 'remark';
import remarkLint from 'remark-lint';
import imageAltText from 'remark-lint-no-empty-image-alt-text';

const file = await remark()
  .use(remarkLint)
  .use(imageAltText)
  .process('![](./media/example.png)');

console.log(String(file));