Skip to content

chore(remark-lint): migrate to @doc-kit/core - #9290

Open
ovflowd wants to merge 1 commit into
mainfrom
chore/remark-lint-doc-kit-2
Open

ovflowd wants to merge 1 commit into
mainfrom
chore/remark-lint-doc-kit-2

Conversation

@ovflowd

@ovflowd ovflowd commented Nov 1, 2026

Copy link
Copy Markdown
Member

Description

This PR moves @node-core/remark-lint from @node-core/doc-kit 1.x to @doc-kit/core, which is where doc-kit 2 keeps the internals our lint rules import. Dependabot's bump to @node-core/doc-kit 2.0.6 in #9286 fails, because two of the helpers invalid-type-reference used are gone.

  • duplicate-stability-nodes and validate-links import the same modules (QUERIES, the slugger) from @doc-kit/core.
  • invalid-type-reference keeps its type pattern locally and checks each | member with doc-kit's resolveTypeReference, so it accepts exactly what the generator can link. The old resolver accepted anything with a . in it, which hid HTML comments and tags being read as <type> references. The html branch now only matches bare <name> nodes.
  • doc-kit 2 keeps _ in slugs, so validate-links now expects #child_process for a child_process heading. That's also what the site's rehype-slug and the Node.js API docs generate.

The lockfile loses ~1,200 lines, since @doc-kit/core doesn't pull in React, Orama and the rest of doc-kit 1's generators. A patch changeset releases it.

Validation

  • pnpm test, Prettier and the package's lint:js pass, and the site's lint:md stays clean with the new validate-links.
  • I ran the old and new invalid-type-reference over the 70 files in nodejs/node's doc/api with its type-map.json. The new rule reports nothing the old one didn't: it drops the HTML comment and tag false positives (7,103 → 283 messages) and now resolves {object}, {QuotaExceededError}, {WorkerGlobalScope} and {DedicatedWorkerGlobalScope}.

Related Issues

Supersedes #9286

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@node-core/doc-kit 2 moved its internals to @doc-kit/core, and removed
the two helpers invalid-type-reference was built on:
`transformTypeToReferenceLink` and `QUERIES.normalizeTypes`.

- duplicate-stability-nodes and validate-links import the same modules
  from @doc-kit/core.
- invalid-type-reference keeps its type pattern locally and resolves
  each `|` member with doc-kit's `resolveTypeReference`, so it accepts
  exactly what the generator can link. Types never reach it with `<>`
  in them, so the old generic handling is gone.
- The old resolver accepted anything containing a `.`, which hid HTML
  comments and tags being read as `<type>` references. The html branch
  now only matches bare `<name>` nodes.
- doc-kit 2 no longer turns `_` into `-` in slugs, matching the site's
  rehype-slug and the Node.js API anchors (`#child_process`).

Over Node.js's doc/api with its type-map.json, the rule reports nothing
new: it drops the HTML false positives (7103 -> 283 messages) and now
resolves {object}, {QuotaExceededError}, {WorkerGlobalScope} and
{DedicatedWorkerGlobalScope}. The site's markdown lint stays clean.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 1, 2026 21:14
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nodejs-org Ready Ready Preview Nov 1, 2026 9:15pm UTC

Request Review

@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.03%. Comparing base (6920b1d) to head (a5fcc2d).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9290      +/-   ##
==========================================
+ Coverage   86.91%   87.03%   +0.12%     
==========================================
  Files          88       88              
  Lines        6356     6377      +21     
  Branches      387      387              
==========================================
+ Hits         5524     5550      +26     
+ Misses        828      823       -5     
  Partials        4        4              

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The rule incorrectly flags valid expressions such as {vm.Module[][]} and {typeof vm.Module} because it uses identifier-only resolution instead of the full annotation resolver.

1 open issue
1 file not reviewed
  • pnpm-lock.yaml: Generated file
What changed in this PR

Migrates @node-core/remark-lint to doc-kit’s extracted core package, replacing the incompatible dependency bump in #9286 and reducing generator-related dependencies.

Changes:

  • Switches shared helper imports and dependencies to @doc-kit/core.
  • Updates type-reference validation and underscore-preserving heading anchors.
  • Adds regression tests and a patch changeset.
File Description
pnpm-lock.yaml Locks the core dependency and removes unused transitive dependencies.
packages/​remark-lint/​src/​rules/​validate-links.mjs Imports core’s heading slugger.
packages/​remark-lint/​src/​rules/​invalid-type-reference.mjs Adds local type matching and identifier resolution.
packages/​remark-lint/​src/​rules/​duplicate-stability-nodes.mjs Imports query helpers from core.
packages/​remark-lint/​src/​rules/​__tests__/​validate-links.test.mjs Expects underscores in heading anchors.
packages/​remark-lint/​src/​rules/​__tests__/​invalid-type-reference.test.mjs Covers HTML exclusions, arrays, qualified names, and unions.
packages/​remark-lint/​package.json Replaces the doc-kit dependency with core.
.changeset/​quiet-rules-migrate.md Records the patch release and behavior changes.

Review effort: Balanced

Comment on lines +37 to +39
const name = piece.trim().replace(/\[\]$/, '');

return name.length > 0 && resolveTypeReference(name, typeMap) !== '';
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

📦 Build Size Comparison

Summary

Metric Value
Old Total First Load JS 7.19 MB
New Total First Load JS 7.19 MB
Delta 0 B (0.00%)

Comment on lines +5 to +7
const TYPE_RE = /(\{|<)(?! )[^<({})>]+(?! )(\}|>)/g;
// Excludes HTML comments, closing tags and tags with attributes
const HTML_TYPE_RE = /^<[^\s!/=]+>$/;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we import this from somewhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Like?

This branch was successfully deployed

1 active deployment
Preview — a5fcc2db Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fast-track Fast Tracking PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants