Skip to content

feat(cli): enable safe MDX autofix - #210

Merged
luojiyin1987 merged 3 commits into
masterfrom
feat/enable-safe-mdx-fix
Oct 26, 2026
Merged

luojiyin1987 merged 3 commits into
masterfrom
feat/enable-safe-mdx-fix

Conversation

@luojiyin1987

@luojiyin1987 luojiyin1987 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Route .mdx fix requests to Core fixMdx(). Keep fixMarkdown() for regular Markdown.
  • Remove the batch-wide MDX --fix rejection from fix(cli): prevent unsafe --fix on MDX files #208. Mixed batches now run normally.
  • Keep the existing changed check. The CLI writes only files whose fixed content differs.
  • Document that --stdin always parses Markdown. --stdin --fix is not safe for MDX content.
  • Narrow the MDX fix safety claim. Third-party rules control their own fix ranges.
  • Extend the package smoke test to fix MDX from the installed tarball.
  • Add @mdx-js/mdx as a dev dependency to compile fixed MDX in tests.

Behavior

  • Fixes apply to Markdown body text.
  • Built-in rules preserve ESM, JSX attributes, and JavaScript expressions in supported cases.
  • stdin has no file extension. It keeps the existing Markdown behavior.
  • MDX autofix currently supports file-path mode only.

Tests

  • Mixed Markdown and MDX batch.
  • .mdx and .MDX routing.
  • ESM, JSX attribute, and expression preservation.
  • Fix idempotence.
  • Exit code 0 after a complete fix. Exit code 1 when an error remains.
  • Unchanged MDX files keep their old mtime.
  • stdin without an extension matches fixMarkdown() output.
  • Fixed MDX compiles with @mdx-js/mdx.
  • Installed package fixes MDX, preserves ESM and JSX attributes, and exits 0.

Checks

  • npm run lint
  • npm test (259 tests passed)
  • npm run test:package

Route .mdx fix requests to Core fixMdx().

Keep fixMarkdown() for regular Markdown.

Remove the batch-wide MDX fix rejection from #208.

Add tests for mixed batches and source preservation.

Cover idempotence, exit codes, unchanged files, and stdin.

Compile fixed MDX with @mdx-js/mdx.
State that --stdin always parses Markdown.

Warn against --stdin --fix for MDX content.

Narrow the MDX fix safety claim for third-party rules.
Fix .mdx from an installed tarball.

Assert that ESM and JSX attributes stay unchanged.

Assert that Markdown body text changes.
@luojiyin1987
luojiyin1987 merged commit a9bbf67 into master Oct 26, 2026
7 checks passed
@luojiyin1987
luojiyin1987 deleted the feat/enable-safe-mdx-fix branch October 26, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant