Repository navigation
feat(DEP0210,DEP0211): add node:sqlite class renames codemod - #571
FrustratedBoy420 wants to merge 4 commits into
Conversation
Rename `DatabaseSync` to `Database` and `StatementSync` to `Statement` for bindings that resolve to `node:sqlite`. Support ESM named, namespace, and default imports, CommonJS destructuring and property access, aliases, `await import()`, re-exports, and TypeScript type references. Keep the old local name as an alias when the new name is already used or the old name is declared again, and keep public export names. Leave third-party `sqlite` packages and unrelated identifiers unchanged. Closes nodejs#560 Assisted-by: Claude Code (claude-opus-5-5)
AugustinMauroy
left a comment
There was a problem hiding this comment.
could you read and apply rule of https://ai-coding-assistants-policy.openjsf.org/
Find `node:sqlite` bindings with `getModuleDependencies` and `resolveBindingPath` from `@nodejs/codemod-utils` instead of custom import, require, and dynamic import queries. Type-only imports are not resolved by `resolveBindingPath`, so they are now left unchanged and documented as a limitation. Assisted-by: Claude Code (claude-opus-5-5)
|
Thanks for the review, @AugustinMauroy. I've read the OpenJS AI Coding Assistants Policy and added an AI assistance section to the PR description. The new commit uses an |
534035b to
84ec1f8
Compare
|
Update: I've rewritten the commit trailers to |
Replace `node.kind() === '...'` comparisons with `node.is('...')`, as
suggested by @AugustinMauroy in review.
Assisted-by: Claude Code (claude-opus-5-5)
|
Thanks for the suggestions, @AugustinMauroy! I've applied all five in 95edc81 and switched the one remaining |
|
@AugustinMauroy all review threads are addressed and resolved (the suggestions landed in 95edc81, and the trailers now follow the OpenJS AI policy). Could you take another look when you have time? Thanks! |
|
@brunocroh @JakobJingleheimer could one of you also take a look at this one? Thanks! |
Closes #560
What
Adds a new recipe,
@nodejs/sqlite-class-renames, for DEP0210 and DEP0211. It renamesDatabaseSynctoDatabaseandStatementSynctoStatementfor bindings that resolve tonode:sqlite.Supported forms
import { type StatementSync }), namespace imports, and default importsconst { DatabaseSync } = require(...)) and property access (sqlite.DatabaseSync,require('node:sqlite').StatementSync)await import('node:sqlite')with destructuring or a namespace bindingsqlite.StatementSyncas a qualified typeHow it stays safe
Following the guidance in the issue:
node:sqliteis resolved. The shared helpers match^(node:)?sqlite$, butsqlitewithout the prefix is a third-party package, so this recipe matches thenode:sqlitespecifier only.DatabaseSync as DBbecomesDatabase as DB, and references toDBdo not change.import { Database as DatabaseSync } from 'node:sqlite', and no other code changes.export { DatabaseSync } from 'node:sqlite'becomesexport { Database as DatabaseSync } from 'node:sqlite'.export { DatabaseSync }of a renamed local becomesexport { Database as DatabaseSync }, and the shorthand{ DatabaseSync }becomes{ DatabaseSync: Database }.new Statement()is introduced. Only existing references are renamed.sqlite) is declared again in the file, its member accesses are left unchanged and a warning is printed.Not covered (documented in the README): computed access such as
sqlite['DatabaseSync'], andimport('node:sqlite').then(...)callbacks.Tests
12 fixtures: ESM named, ESM aliases, ESM namespace and default imports, CJS destructuring with aliases, CJS property access, dynamic import, binding collisions, shadowed identifiers, re-exports and local exports, TypeScript, unrelated modules (
sqlite, local files, plain properties), and already-migrated code.npm testin the recipe: 12 passedexpectedfile produces no changes (12 passed)biome lint: cleannpm run type-check: cleanAI assistance
This PR was written with help from Claude Code (
claude-opus-5-5), following the OpenJS AI Coding Assistants Policy. All commits carry anAssisted-by: Claude Code (claude-opus-5-5)trailer. I take responsibility for this submission.