Repository navigation
chore(lint): enforce node: protocol for Node.js builtin imports (AI-assisted) - #12544
Merged
Merged
Conversation
…ssisted) Enable `import/enforce-node-protocol-usage` and autofix all builtin imports to use the `node:` protocol. - Update the `no-restricted-syntax` default-import guard to target `node:path` (it silently stopped matching otherwise) and convert the few named `node:path` imports that had bypassed it. - Remove the obsolete `stream` pathGroup from `import/order`. - Manually prefix imports in files ESLint doesn't reach (`openBrowser.ts` is eslint-disabled, `commands/build/` matches the global `**/build/**` ignore). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Size Change: 0 B Total Size: 12.4 MB ℹ️ View Unchanged
|
⚡️ Lighthouse report for the deploy preview of this PR
|
|
Size Change: -7.21 kB (-0.06%) Total Size: 12.5 MB 📦 View Changed
ℹ️ View Unchanged
|
…f-24b150 # Conflicts: # packages/docusaurus-utils/src/emitUtils.ts # packages/docusaurus-utils/src/hashUtils.ts # packages/docusaurus/src/commands/swizzle/__tests__/components.test.ts # test/snapshotPathNormalizer.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-flight checklist
Motivation
Builtin imports were inconsistent: some used
'path', others'node:path'. This enablesimport/enforce-node-protocol-usage('always'), shipped with oureslint-plugin-import@2.32, and autofixes ~170 import specifiers.Other changes (AI-assisted):
no-restricted-syntaxdefault-import guard: it matchedLiteral[value=path], so it would have silently stopped working after the migration. It now targets"node:path". That surfaced 7 named imports fromnode:paththat had already bypassed the guard, which I converted toimport path from 'node:path'.import/order: removed the dead{pattern: 'stream'}pathGroup. The onlystreamimport already usednode:stream.commands/utils/openBrowser/openBrowser.tshas a file-leveleslint-disable(vendored CRA code).commands/build/buildLocale.tsis skipped because the global**/build/**ignore also matchessrc/commands/build/. That gap predates this PR and is left for a follow-up.Notes for review:
packages/*/src/client,packages/*/src/themeor browser-sidewebsite/src. The only builtins undersrc/clientarenode:streamandnode:stream/consumersinrenderToHtml.tsx. That file is SSR-only (imported byserverEntry.tsx) and was already prefixed. Thewebsite/src/plugins/*files that changed are Node-side plugins.vi.mock()on a builtin (tests only usevi.spyOnonfs-extra), so there was nothing to update. Snapshots are unchanged.docusaurus-types/src/routing.d.tsnow importsParsedUrlQueryInputfrom'node:querystring'.@types/nodehas declared both specifiers since v16, so resolution for users doesn't change.create-docusaurus/templatesis linted (exceptfacebook) but has no builtin imports. The rule now covers it.vi.mock(),require.resolve(),.cjsfiles and TSdeclare module/import()types. A grep found no unprefixed builtins there..md/.mdxdocs and blog posts still use'path'. A follow-up could update the current docs.Test Plan
pnpm lint:js: 0 errors. Warnings are identical tomain(494, no per-file/per-rule difference).pnpm build:packages: OK. The compiled CJS emitsrequire("node:path").pnpm --filter website typecheck: OKpnpm lint:knip: OKpnpm test: 192 files / 3151 tests pass, no snapshot changespnpm build:website:fast: OKTest links
No UI change.
Deploy preview: https://deploy-preview-12544--docusaurus-2.netlify.app/
Related issues/PRs
🤖 Generated with Claude Code