Skip to content

chore: enforce @svelte-vitals/core runtime-purity with eslint no-restricted-imports - #119

Merged
oekazuma merged 2 commits into
mainfrom
advisor/009-enforce-core-purity-lint
Jul 5, 2026
Merged

oekazuma merged 2 commits into
mainfrom
advisor/009-enforce-core-purity-lint

Conversation

@oekazuma

@oekazuma oekazuma commented Jul 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

@svelte-vitals/core's most important contract — "runtime-agnostic: no node: imports, no I/O, no runtime-specific globals" (stated at packages/core/src/index.ts:1-2) — was previously upheld only by documentation and review. This PR turns it into a CI gate, following the principle that prohibitions should be enforced mechanically rather than documented (see Anthropic's Claude Code steering guide).

Changes

One scoped block in eslint.config.js, applying only to packages/core/src/**/*.ts:

  • no-restricted-imports: bans node:* plus common bare builtins (fs, path, os, child_process, …) with a message pointing to the Runtime interface (src/runtime.ts) as the injection point
  • no-restricted-globals: bans process, __dirname, __filename, Buffer

packages/core/test/ is deliberately not covered — tests run under Node and legitimately use node: imports; purity applies to src/ only.

Verification

  • Pre-check: zero existing violations in packages/core/src/ (grep for node: imports and runtime globals — 0 hits), so the rule lands green
  • Positive probe: a temp file with import 'node:fs' fails eslint with the runtime-agnostic message; same for process.env via no-restricted-globals (probe removed, not committed)
  • pnpm lint / pnpm typecheck / pnpm test (723 tests) — all clean; no other package's lint outcome changed
  • No changeset (internal tooling only; no published package behavior change)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Strengthened code checks in the core package to prevent use of environment-specific APIs, helping keep behavior consistent across runtimes.
    • Added clearer guidance when restricted APIs are used, encouraging safer input/output handling.

…ricted-imports

Scope no-restricted-imports/no-restricted-globals to packages/core/src/**
so a node: import or runtime global (process, Buffer, __dirname, __filename)
fails `pnpm lint` / CI instead of relying on review, per the runtime-agnostic
contract documented in packages/core/src/index.ts.
@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@oekazuma, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d61d3372-c81e-4e80-9a61-554705e7fc87

📥 Commits

Reviewing files that changed from the base of the PR and between 4c39a57 and c38a60b.

📒 Files selected for processing (1)
  • eslint.config.js
📝 Walkthrough

Walkthrough

This change adds a new ESLint configuration block targeting packages/core/src/**/*.ts, introducing no-restricted-imports to block Node built-in modules and no-restricted-globals to block runtime-specific globals, both with messages directing I/O to be injected via a Runtime interface.

Changes

ESLint core restrictions

Layer / File(s) Summary
Restrict Node imports and globals in core package
eslint.config.js
New config block for packages/core/src/**/*.ts disallows Node built-in module imports and runtime globals (process, __dirname, __filename, Buffer) with design§8 error messages instructing I/O injection via the Runtime interface.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main change: enforcing runtime-purity in @svelte-vitals/core via ESLint rules.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch advisor/009-enforce-core-purity-lint

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@eslint.config.js`:
- Around line 38-54: The import restriction in the eslint config still leaves
some Node builtin modules and subpaths unblocked, so update the allowlist in the
import pattern group to cover the missing builtins such as net, dns,
worker_threads, and path subpaths like path/posix and path/win32, or replace
this allowlist with a broader builtin-ban rule. Make the change in the config’s
patterns group so the rule consistently catches all Node builtin imports.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a7612f35-9180-46e7-9748-4e3aeb1de45d

📥 Commits

Reviewing files that changed from the base of the PR and between 2f0bb14 and 4c39a57.

📒 Files selected for processing (1)
  • eslint.config.js

Comment thread eslint.config.js Outdated
@oekazuma

oekazuma commented Jul 5, 2026

Copy link
Copy Markdown
Owner Author

Addressed in c38a60b: the hand-written bare-builtin list is replaced by a list generated from node:module's builtinModules (plus /* subpath variants), so net, dns, worker_threads, path/posix, path/win32, etc. are all covered and the list can never go stale. Verified with positive probes on path/posix, net, node:net, and path/win32 — all fail lint as intended.

@oekazuma
oekazuma merged commit 1a2b0f6 into main Jul 5, 2026
5 checks passed
@oekazuma
oekazuma deleted the advisor/009-enforce-core-purity-lint branch July 5, 2026 17:27
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