mdx-formatter
GitHub repository

Type to search...

to open search from anywhere

You are viewing documentation for an older version.View the latest version

Configuration

Configuration options and config file setup for mdx-formatter

The formatter looks for configuration in three layers (later layers override earlier ones):

  1. Built-in defaults (from settings.ts)

  2. Config file (.mdx-formatter.json or "mdx-formatter" key in package.json)

  3. Programmatic options (passed to format())

Config File

Create .mdx-formatter.json in your project root:

{
  "addEmptyLinesInBlockJsx": {
    "blockComponents": ["Outro", "InfoBox"]
  },
  "indentJsxContent": {
    "containerComponents": ["Outro", "InfoBox", "LayoutDivide"]
  },
  "formatMultiLineJsx": {
    "ignoreComponents": ["CodeBlock"]
  }
}

Or add an "mdx-formatter" key to your package.json:

{
  "mdx-formatter": {
    "addEmptyLinesInBlockJsx": {
      "blockComponents": ["Outro", "InfoBox"]
    }
  }
}

Excluding Files

You can add an exclude array to your config file to skip files matching the given glob patterns. These patterns are merged with the CLI --ignore option.

{
  "exclude": ["doc/docs/claude/**", "generated/**/*.md"],
  "formatMultiLineJsx": {
    "ignoreComponents": ["CodeBlock"]
  }
}

This is useful for excluding auto-generated files that don't need formatting, without adding patterns to every CLI invocation.

The exclude key also works in package.json:

{
  "mdx-formatter": {
    "exclude": ["doc/docs/claude/**"]
  }
}