Skip to content

[codex] Enforce canonical Node namespace imports#3238

Merged
juliusmarminge merged 1 commit into
mainfrom
codex/enforce-node-namespace-imports
Jun 20, 2026
Merged

[codex] Enforce canonical Node namespace imports#3238
juliusmarminge merged 1 commit into
mainfrom
codex/enforce-node-namespace-imports

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • add a tested Oxlint rule requiring namespace imports for every node:* module and canonical NodeXyz aliases
  • migrate existing TypeScript and JavaScript Node built-in imports repo-wide
  • keep Electron out of the static rule and remove stale Macroscope guidance that required named Electron imports
  • adapt the one Node module spy to a hoisted module mock because ESM namespace objects are immutable

The installed Effect language-service namespaceImportPackages option was evaluated first. Its wildcard resolver supports node:*, but the import diagnostic only handles namespace re-exports from barrel modules, so it does not diagnose direct Node built-in imports. The Oxlint rule is therefore the enforcement source of truth.

Validation

  • vp check
  • vp run typecheck
  • vp run lint:mobile
  • vp test oxlint-plugin-t3code/rules apps/server/src/workspace/WorkspaceEntries.test.ts
  • focused existing tests for Node fs/path/process/crypto/http call sites
  • node --check for every changed .mjs file

Note

Low Risk
Mechanical import renames across many files with no intended runtime behavior change; risk is mainly merge noise or a missed call-site typo, not security or data handling.

Overview
This PR standardizes how the repo imports Node built-ins: node:* modules must use namespace imports with canonical aliases like NodeFS, NodePath, NodeChildProcess, and NodeProcess, instead of named or default imports (readFile, path, fs, etc.). Call sites are updated repo-wide in desktop scripts, server runtime/tests, mobile sync scripts, and related tooling.

Macroscope guidance is aligned so electron is no longer called out as requiring named imports alongside @t3tools/contracts; only non-Node packages keep named imports where appropriate.

Behavior should be unchanged—this is import style and lint enforcement, with existing // @effect-diagnostics nodeBuiltinImport:off escapes preserved where scripts intentionally touch Node at the boundary.

Reviewed by Cursor Bugbot for commit b44c58d. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Enforce canonical Node namespace imports across the codebase with a new t3code/namespace-node-imports lint rule

  • Introduces a new Oxlint rule namespace-node-imports in the t3code plugin that requires all node: built-in imports to use namespace-style imports with canonical aliases (e.g. NodeFS, NodePath, NodeCrypto).
  • Applies the rule as an error in vite.config.ts and migrates all existing node: imports across apps/, packages/, scripts/, and desktop scripts to the canonical namespace style.
  • The rule computes the expected alias from module and segment alias maps with PascalCase conversion, and reports any declaration that uses a named, default, or non-canonical namespace import.
  • Behavioral Change: t3code/namespace-node-imports is now enforced as a lint error, so any future non-canonical Node built-in import will fail CI.

Macroscope summarized b44c58d.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f0c64165-285f-4e08-b4a7-e5ebe280f7a4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/enforce-node-namespace-imports

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

@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Jun 20, 2026
@juliusmarminge juliusmarminge merged commit 2fa37ec into main Jun 20, 2026
16 checks passed
@juliusmarminge juliusmarminge deleted the codex/enforce-node-namespace-imports branch June 20, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant