Registry / testing / remark-lint-no-empty-image-alt-text

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

JSON →
library1.0.3jsnpmunverified

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.

npm install remark-lint-no-empty-image-alt-text
INSTALL
IMPORT
SIG · REMARK-LINT-NO-EMP
R
remark-lint-no-empty-image-alt-text
testingjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import imageAltText from 'remark-lint-no-empty-image-alt-text'
const imageAltText = require('remark-lint-no-empty-image-alt-text')
ESM default import; CJS require also works but TypeScript may need esModuleInterop.
remarkLint
import remarkLint from 'remark-lint'
const remarkLint = require('remark-lint')
remark-lint is a required peer dependency and should be imported similarly.
remark
import { remark } from 'remark'
import remark from 'remark'
remark package exports a named export 'remark' (function). Default export does not exist in ESM.

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));
Debug
Known issues
gotchaThe 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.
affects: >=1.0.0
gotchaWhen 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.
affects: >=1.0.0
deprecatedThe 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`.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'remark-lint-no-empty-image-alt-text'
Missing installation of the package.
fix
npm install remark-lint-no-empty-image-alt-text
TypeError: remark().use is not a function
Importing remark incorrectly; using default import instead of named export.
fix
Use `import { remark } from 'remark'` instead of `import remark from 'remark'`.
Warning: Missing alt text for image! no-empty-image-alt-text remark-lint
Valid lint warning – no fix needed, but alt text should be added.
fix
Add alt text inside the brackets: `![description](url)`
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
remark-lintrequiredrequired as plugin framework for lint rules
remarkrequiredneed remark parser to process Markdown
Agent activity
4 hits · last 30 days
node
4
Resources
remark-lint-no-empty-image-alt-text — npm install remark-lint-no-empty-image-alt-text · libregistry