Skip to content

feat: support basic usage of remark-lint for link plugin#2618

Merged
SoonIter merged 2 commits intoweb-infra-dev:mainfrom
JounQin:feat/link-lint
Sep 24, 2025
Merged

feat: support basic usage of remark-lint for link plugin#2618
SoonIter merged 2 commits intoweb-infra-dev:mainfrom
JounQin:feat/link-lint

Conversation

@JounQin
Copy link
Copy Markdown
Collaborator

@JounQin JounQin commented Sep 22, 2025

Summary

support basic usage of remark-lint for link plugin

A user defined demo plugin:

import config from './rspress.config.mjs';

const pluginDriver = await PluginDriver.create(
  config,
  path.resolve(import.meta.dirname, 'rspress.config.mjs'),
  false,
);
const routeService = await RouteService.create({
  config,
  scanDir: config.root,
  externalPages: await pluginDriver.addPages(),
});

const checkDeadLinks = lintRule('check-dead-links', async (tree, file) => {
  remarkLink({
    cleanUrls: false,
    routeService,
    remarkLinkOptions: config.markdown.link,
    lint: true,
  })(tree, file);
});
image

Related Issue

close #2547

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings September 22, 2025 09:15
@netlify
Copy link
Copy Markdown

netlify Bot commented Sep 22, 2025

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit 0fa68d1
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/68d3bc8d856b770008f90262
😎 Deploy Preview https://deploy-preview-2618--rspress-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds basic remark-lint support to the link plugin by emitting diagnostics through VFile instead of logging.

  • Switch checkDeadLinks to accept VFile and optionally emit lint messages.
  • Introduce a lint option to remarkLink to toggle linting behavior.
  • Public API surface change: export PluginDriver and change RouteService export from type-only to value export.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
packages/core/src/node/mdx/remarkPlugins/link.ts Adds VFile-based reporting, a lint flag, and adjusts dead link reporting accordingly.
packages/core/src/index.ts Exposes new runtime exports (PluginDriver, RouteService).

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/core/src/node/mdx/remarkPlugins/link.ts Outdated
Comment thread packages/core/src/node/mdx/remarkPlugins/link.ts Outdated
Comment thread packages/core/src/node/mdx/remarkPlugins/link.ts
Comment thread packages/core/src/node/mdx/remarkPlugins/link.ts
Comment thread packages/core/src/index.ts
Comment thread packages/core/src/node/mdx/remarkPlugins/link.ts Outdated
@JounQin JounQin force-pushed the feat/link-lint branch 2 times, most recently from bea81c3 to 2b8dc83 Compare September 22, 2025 09:58
Comment thread packages/core/src/node/mdx/remarkPlugins/link.ts
@SoonIter
Copy link
Copy Markdown
Member

SoonIter commented Sep 23, 2025

could you provide a e2e case, otherwise, any modifications cause breaking cannot be detected

@JounQin
Copy link
Copy Markdown
Collaborator Author

JounQin commented Sep 24, 2025

could you provide a e2e case, otherwise, any modifications cause breaking cannot be detected

@SoonIter Done.

@JounQin JounQin force-pushed the feat/link-lint branch 3 times, most recently from 3c7708e to 95dd5f1 Compare September 24, 2025 09:39
Copy link
Copy Markdown
Member

@SoonIter SoonIter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SoonIter SoonIter enabled auto-merge (squash) September 24, 2025 11:55
@SoonIter SoonIter merged commit b0117f6 into web-infra-dev:main Sep 24, 2025
9 checks passed
@JounQin JounQin deleted the feat/link-lint branch September 24, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: export checkDeadLinks related remark plugin for reusing (routeService can not be accessed now)

3 participants