-
Notifications
You must be signed in to change notification settings - Fork 10
mock converted from js to ts #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
WalkthroughMigrates protocol/generate-mock-data.ts from CommonJS to ES module imports, switches dotenv loading to import-time via dotenv/config, and adjusts db import to a default ESM import. Adds an npm script generate-mock in protocol/package.json to run the script with ts-node/register. No control-flow changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
protocol/package.json (1)
15-16
: Script addition LGTM; consider preloading dotenv via CLI instead of side-effect import.Current setup works. If you prefer keeping code free of side-effect imports, you can preload dotenv in the script and drop
import 'dotenv/config'
from the TS file.Apply this to package.json:
- "generate-mock": "TS_NODE_TRANSPILE_ONLY=1 node -r ts-node/register ./generate-mock-data.ts" + "generate-mock": "TS_NODE_TRANSPILE_ONLY=1 node -r dotenv/config -r ts-node/register ./generate-mock-data.ts"Then remove the side-effect import at the top of
generate-mock-data.ts
:-import 'dotenv/config';
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
protocol/generate-mock-data.ts
(1 hunks)protocol/package.json
(1 hunks)
🔇 Additional comments (2)
protocol/generate-mock-data.ts (2)
2-2
: If keeping side-effect env load, it's fine as-is.Using
import 'dotenv/config'
here is acceptable for a CLI script and loads envs early enough for downstream imports.
2-8
: ESM import migration verified
tsconfig.json enables esModuleInterop & allowSyntheticDefaultImports;protocol/src/lib/db
exports a default and ts-node/register under Node16 resolution will load it correctly.
Summary by CodeRabbit
Refactor
Chores