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.

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)
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
npm install textlint-plugin-mdx
yarn add textlint-plugin-mdx
pnpm add textlint-plugin-mdx

Shows how to configure textlint-plugin-mdx in .textlintrc.json and use it programmatically with ESLint-like results.

// .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);