Configuration
The formatter looks for configuration in three layers (later layers override earlier ones):
- Built-in defaults (from
settings.mjs) - Config file (
.mdx-formatter.jsonor"mdx-formatter"key inpackage.json) - 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/**"]
}
}