textlint-plugin-mdx
raw JSON → 1.1.0 verified Fri May 01 auth: no javascript
textlint plugin to lint MDX files. Latest version 1.1.0 (released 2025-05-23). Supports MDX 3+ with ESM-only, requires TypeScript 5+ as peer dependency. Key differentiator: native MDX parsing with remark-directive and GFM support, unlike using generic markdown plugin which can break MDX syntax. No browser usage.
Common errors
error Cannot find module 'textlint-plugin-mdx' ↓
cause Package not installed or not resolved in ESM context
fix
Install package: npm install textlint-plugin-mdx
error require() of ES Module textlint-plugin-mdx not supported ↓
cause CommonJS require on ESM-only package
fix
Use import syntax or set type: 'module' in package.json
error TypeError: textlintPluginMdx is not a constructor ↓
cause Default export is an object, not a class; using new on it
fix
Use plugin object directly: engine.addPlugin(textlintPluginMdx)
Warnings
breaking ESM-only package; require() will throw error ↓
fix Use import syntax or dynamic import()
deprecated Using @textlint/textlint-plugin-markdown with .mdx extension breaks MDX parsing ↓
fix Remove .mdx from @textlint/textlint-plugin-markdown extensions and use textlint-plugin-mdx
gotcha Requires TypeScript 5+ as peer dependency even if not using TypeScript, but it's optional ↓
fix Install TypeScript: npm install --save-dev typescript@^5.0.0
gotcha Default export is plugin object, not a class; new operator will fail ↓
fix Use plugin directly as object, not with new
Install
npm install textlint-plugin-mdx yarn add textlint-plugin-mdx pnpm add textlint-plugin-mdx Imports
- default wrong
const textlintPluginMdx = require('textlint-plugin-mdx')correctimport textlintPluginMdx from 'textlint-plugin-mdx' - plugin wrong
import plugin from 'textlint-plugin-mdx'correctimport { plugin } from 'textlint-plugin-mdx' - TextlintPluginOptions wrong
import { TextlintPluginOptions } from 'textlint-plugin-mdx'correctimport type { TextlintPluginOptions } from 'textlint-plugin-mdx'
Quickstart
// .textlintrc.json
{
"plugins": {
"mdx": true
}
}
// Or programmatic usage:
import { TextLintEngine } from 'textlint';
const engine = new TextLintEngine({
plugins: [
['textlint-plugin-mdx', {
extensions: ['.mdx']
}]
],
rules: {
'no-todo': true
}
});
const results = await engine.executeOnFiles(['example.mdx']);
console.log(results);