remark-lint-correct-media-syntax
raw JSON → 1.0.1 verified Fri May 01 auth: no javascript
A remark-lint rule that warns when image or link syntax has brackets and parentheses accidentally swapped (e.g., `(text)[url]` instead of `[text](url)`). Current stable version is 1.0.1, ESM-only, requires Node.js 16+. It is a focused, zero-config lint rule with no parameters, part of the unified/remark ecosystem. Unlike broader lint presets, this rule targets a single common mistake with a clear, actionable message.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module ↓
cause Using CommonJS require() to load the ESM-only package.
fix
Change to import statement or use dynamic import().
error Unexpected `)[`, expected `[` and `]` around the text (label) and `(` and `)` around the URL ↓
cause Using `(text)[url]` instead of `[text](url)`.
fix
Swap the brackets and parentheses to
[text](url). error Cannot find module 'remark-lint-correct-media-syntax' ↓
cause The package is not installed or the import path is incorrect.
fix
Run
npm install remark-lint-correct-media-syntax and verify the import path. Warnings
breaking Package is ESM-only and does not support CommonJS require(). ↓
fix Use import syntax instead of require(). Switch to ESM or use dynamic import() if needed.
gotcha The rule has no configuration options; it always checks for the specific pattern. ↓
fix No workaround; if you need to customize behavior, consider other lint rules or use remark-message-control.
gotcha The rule does not check for other media syntax issues like missing alt text or broken URLs. ↓
fix Use additional remark-lint plugins (e.g., remark-lint-no-literal-urls) for broader coverage.
deprecated Node.js 16 is the minimum required version; Node 14 is not supported. ↓
fix Upgrade Node.js to version 16 or later.
Install
npm install remark-lint-correct-media-syntax yarn add remark-lint-correct-media-syntax pnpm add remark-lint-correct-media-syntax Imports
- remarkLintCorrectMediaSyntax wrong
const remarkLintCorrectMediaSyntax = require('remark-lint-correct-media-syntax')correctimport remarkLintCorrectMediaSyntax from 'remark-lint-correct-media-syntax' - default export wrong
import { remarkLintCorrectMediaSyntax } from 'remark-lint-correct-media-syntax'correctimport remarkLintCorrectMediaSyntax from 'remark-lint-correct-media-syntax' - TypeScript types
import type { Transformer } from 'unified'
Quickstart
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import remarkLint from 'remark-lint';
import remarkLintCorrectMediaSyntax from 'remark-lint-correct-media-syntax';
import { reporter } from 'vfile-reporter';
const file = await unified()
.use(remarkParse)
.use(remarkLint)
.use(remarkLintCorrectMediaSyntax)
.use(remarkStringify)
.process('(wrong)[https://example.com] and [correct](https://example.com)');
console.error(reporter(file));