chore(drizzle): alias _query to query and enforce via lint#3118
Open
chore(drizzle): alias _query to query and enforce via lint#3118
Conversation
Prep for drizzle v1, which renames the RQB namespace from `query` to `_query`. Adds a runtime alias so both names work, rewrites every `.query` drizzle receiver to `._query`, and enforces the new name with an oxlint rule plus a type-aware CI check. - New `@kilocode/drizzle-shims` package patches PgDatabase and BaseSQLiteDatabase prototypes with a `_query` getter; transaction subclasses (`tx._query`) are covered automatically. - Side-effect imports added at every `drizzle(...)` construction site (packages/db client plus 12 DO service files). - `oxlint-plugin-drizzle.js` gains `prefer-underscore-query` (autofix, name-gated: db / ctx.db / this.db / tx / trx). - `scripts/drizzle-query-rename.ts` is a ts-morph codemod/verifier that walks every workspace tsconfig plus dev/ and scripts/ orphans and checks the drizzle `query` property by declaration location. Exposed as `pnpm drizzle:query-rename` and `pnpm drizzle:query-check`; the check runs as part of `pnpm validate`. - 372 call sites across 76 files rewritten.
| */ | ||
|
|
||
| import { Project, Node, SyntaxKind } from 'ts-morph'; | ||
| import { readFileSync } from 'node:fs'; |
Contributor
There was a problem hiding this comment.
WARNING: readFileSync is imported but never used
This new script is wired into pnpm validate, but the unused import will be flagged by the existing no-unused-vars linting and can make validation fail even though the checker itself works. Remove this import so the added CI step does not break lint.
Contributor
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (103 files)
Fix these issues in Kilo Cloud Reviewed by gpt-5.5-2026-04-23 · 723,623 tokens |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prep for drizzle v1, which renames the RQB namespace from
queryto_query. This change adds a runtime alias so both names work today, rewrites every.querydrizzle receiver to._query, and enforces the new name going forward.@kilocode/drizzle-shimspackage patchesPgDatabase.prototypeandBaseSQLiteDatabase.prototypewith a_querygetter that returnsthis.query. Transaction subclasses (PgTransaction,SQLiteTransaction) inherit the alias automatically, sotx._queryworks everywhere too. Includes module augmentations so TypeScript sees_queryon every drizzle db flavour.import '@kilocode/drizzle-shims/query-alias';) at everydrizzle(...)construction site —packages/db/src/client.tsplus 12 DO service files. The new workspace dep was added to each affected service.oxlint-plugin-drizzle.jsgainsprefer-underscore-query(AST-only, autofixable, name-gated on["db", "ctx.db", "this.db", "tx", "trx"]— same posture as the existing two drizzle rules). Enabled as"error"in.oxlintrc.json.scripts/drizzle-query-rename.ts— ts-morph codemod / CI verifier. Because oxlint plugins can't see types, this script is the authoritative check: it walks every workspace tsconfig plusdev/andscripts/orphan files and identifies.queryproperty accesses whosequeryproperty is declared insidedrizzle-orm. Runs aspnpm drizzle:query-rename(--fix) orpnpm drizzle:query-check; the latter is wired intopnpm validate..queryto._query.When drizzle v1 lands, delete
packages/drizzle-shims/, the 13 side-effect imports, the oxlint rule, and the codemod script. The codebase already reads from_query.Verification
pnpm drizzle:query-check— zero drizzle.queryreceivers remain across the whole repo.@kilocode/db,@kilocode/drizzle-shims,@kilocode/worker-utils,web, and the nine DO services) — all clean. Fullpnpm typecheckskipped per AGENTS guidance.pnpm lint— 0 warnings, 0 errors across 5,690 files.pnpm test— 4,930 passed, 2 skipped, 317 suites..query(...)call sites to confirm no false positives; verified the autofix rewrites cleanly onapps/web/src/lib/user.ts.Visual Changes
N/A
Reviewer Notes
packages/drizzle-shims/src/query-alias.tswith clear removal instructions for the drizzle v1 migration.txn/trxrenames, helpers returning a drizzle db, etc.).@kilocode/trpc's.d.tsabout@kilocode/drizzle-shims/query-aliasbeing an external dep. It's benign (the import is type-only from consumers' perspective and resolves via the workspace), but worth flagging.query-alias.ts— only additive, no setter, idempotent, non-enumerable; and (2) the codemod correctness — mitigated by the type-aware check, the full test suite passing, and targeted typechecks. Worth spot-checking a handful of rewrites (e.g.apps/web/src/lib/kilo-pass/usage-triggered-bonus.ts) to confirm semantics are preserved.