Repository navigation
chore: enforce @svelte-vitals/core runtime-purity with eslint no-restricted-imports - #119
Conversation
…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.
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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. 📝 WalkthroughWalkthroughThis change adds a new ESLint configuration block targeting ChangesESLint core restrictions
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
…nModules (CodeRabbit review)
|
Addressed in c38a60b: the hand-written bare-builtin list is replaced by a list generated from |
Summary
@svelte-vitals/core's most important contract — "runtime-agnostic: nonode:imports, no I/O, no runtime-specific globals" (stated atpackages/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 topackages/core/src/**/*.ts:no-restricted-imports: bansnode:*plus common bare builtins (fs,path,os,child_process, …) with a message pointing to theRuntimeinterface (src/runtime.ts) as the injection pointno-restricted-globals: bansprocess,__dirname,__filename,Bufferpackages/core/test/is deliberately not covered — tests run under Node and legitimately usenode:imports; purity applies tosrc/only.Verification
packages/core/src/(grep fornode:imports and runtime globals — 0 hits), so the rule lands greenimport 'node:fs'fails eslint with theruntime-agnosticmessage; same forprocess.envviano-restricted-globals(probe removed, not committed)pnpm lint/pnpm typecheck/pnpm test(723 tests) — all clean; no other package's lint outcome changed🤖 Generated with Claude Code
Summary by CodeRabbit