Skip to content

[codex] fix MDX global component no-undef lint#343

Merged
youyongsong merged 1 commit into
mainfrom
codex/fix-mdx-global-no-undef
Jun 24, 2026
Merged

[codex] fix MDX global component no-undef lint#343
youyongsong merged 1 commit into
mainfrom
codex/fix-mdx-global-no-undef

Conversation

@youyongsong

@youyongsong youyongsong commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • declare Doom runtime MDX global components as readonly globals in the built-in ESLint config
  • share the global component discovery logic with the Rspress global plugin so lint/build stay in sync
  • add regression coverage that permits known Doom MDX globals while still reporting unknown components

Root Cause

After the ESLint 10 upgrade, JSX component identifiers in MDX are included in the scope analysis used by no-undef. Doom injects components such as Overview, Steps, K8sCrd, and ExternalSiteLink through Rspress markdown.globalComponents, so document authors do not import them locally. Without declaring those names as globals, doom lint reports valid MDX component usage as undefined.

Validation

  • yarn test packages/doom/test/eslint.spec.ts
  • yarn build
  • yarn eslint packages/doom/src/eslint.ts packages/doom/src/plugins/global/index.ts packages/doom/src/plugins/global/components.ts packages/doom/test/eslint.spec.ts
  • yarn doom lint fixture-docs --no-cspell -g 'en/test/managedtap.mdx'
  • validated against real vendor docs using clean worktrees from current remote main/master snapshots; the MDX global component no-undef errors are gone

Notes

Clean vendor validation also shows independent failures from doom-lint-no-legacy-os-names on current aml-docs and acp-docs master content. That rule was introduced separately in @alauda/doom@2.5.3 and is not part of the ESLint 10 global component regression fixed here.

Summary by CodeRabbit

  • New Features

    • MDX global components are now recognized in the built-in lint configuration, so common component tags can be used without triggering undefined identifier errors.
    • Global component detection is now handled more reliably when generating lint settings.
  • Bug Fixes

    • Improved lint behavior for MDX files so valid components are no longer reported as undefined.
    • Preserved warnings for truly unknown component names.

@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9516556

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@alauda/doom Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ff6128f-3d52-41a4-853f-600ec6437266

📥 Commits

Reviewing files that changed from the base of the PR and between 5923e7b and 9516556.

📒 Files selected for processing (5)
  • .changeset/fix-mdx-global-component-lint.md
  • packages/doom/src/eslint.ts
  • packages/doom/src/plugins/global/components.ts
  • packages/doom/src/plugins/global/index.ts
  • packages/doom/test/eslint.spec.ts

Walkthrough

Adds a shared helper (components.ts) that enumerates global component files and names from the runtime/components directory. Refactors the global plugin to use it, and updates the ESLint config to inject those names as MDX globals with optional remarkConfigPath resolution. A new test suite verifies that known globals pass and unknown ones still fail no-undef.

Changes

MDX global components declared in ESLint config

Layer / File(s) Summary
Global component enumeration helpers
packages/doom/src/plugins/global/components.ts
New file exports getGlobalComponentFiles and getGlobalComponentNames, which synchronously read and filter the runtime/components directory, excluding underscore-prefixed, .d declaration, and index files.
Global plugin refactor + ESLint globals wiring
packages/doom/src/plugins/global/index.ts, packages/doom/src/eslint.ts
global/index.ts replaces its inline readdirSync pipeline with getGlobalComponentFiles(). eslint.ts adds fs/path imports, introduces a multi-step optional remarkConfigPath resolution (ESM → CJS → built lib), conditionally injects it into parserOptions, and sets MDX languageOptions.globals from getGlobalComponentNames().
ESLint config tests and changeset
packages/doom/test/eslint.spec.ts, .changeset/fix-mdx-global-component-lint.md
New test suite runs ESLint with the doom config against in-memory MDX, asserting known globals produce no no-undef messages and unknown components do. Changeset records the patch release.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop! A new helper hops into place,
Gathering components with tidy grace.
No more "undefined" for Steps or Term—
The lint config now gives each one a firm
global spot, confirmed by tests that run.
✨ The rabbit cheers: clean linting, done!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-mdx-global-no-undef

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

yarn add https://pkg.pr.new/@alauda/doom@343.tgz
yarn add https://pkg.pr.new/@alauda/doom-export@343.tgz

commit: 9516556

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.14286% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.27%. Comparing base (5923e7b) to head (9516556).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/doom/src/eslint.ts 66.66% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #343      +/-   ##
==========================================
+ Coverage   53.88%   54.27%   +0.39%     
==========================================
  Files          61       63       +2     
  Lines        1520     1555      +35     
  Branches      472      482      +10     
==========================================
+ Hits          819      844      +25     
- Misses        542      550       +8     
- Partials      159      161       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@youyongsong youyongsong marked this pull request as ready for review June 24, 2026 09:59
@youyongsong youyongsong merged commit 935b096 into main Jun 24, 2026
16 of 17 checks passed
@youyongsong youyongsong deleted the codex/fix-mdx-global-no-undef branch June 24, 2026 10:02
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