/src/CLAUDE.md
CLAUDE.md at /src/CLAUDE.md
Path: src/CLAUDE.md
src/ — TypeScript Wrapper for Rust Engine
Architecture
The formatting engine is written in Rust (crates/mdx-formatter-core). The TypeScript code in src/ is a thin wrapper that loads the Rust napi module and provides the npm package API.
Key Files
index.ts— Public API (format(),formatFile(),checkFile(),detectMdx())cli.ts— CLI entry point (commander-based)rust-formatter.ts— Loads the Rust napi module (platform package or local build)settings.ts— DefaultFormatterSettingswith all rules and their defaultstypes.ts— Settings interfaces andFormatOptionsload-config.ts— Loads.mdx-formatter.jsonconfig and merges with defaultsutils.ts— Utility functions (deep clone, deep merge with prototype pollution guard)detect-mdx.ts— MDX content detection heuristicbrowser.ts— Browser-safe export (re-exports from index.ts; for true browser use, see WASM)
Settings
All formatter rules are defined in settings.ts as the formatterSettings object. Each rule has an enabled flag and rule-specific options. Some rules (e.g., indentJsxContent, addEmptyLinesInBlockJsx) accept component name arrays that ship empty by default — users configure them per-project via .mdx-formatter.json.
Types
Settings interfaces live in types.ts. Key types:
FormatterSettings/FormatOptions— ConfigurationDeepPartial<T>— Used for partial settings overrides