drizzle-team / drizzle-team/drizzle-orm

[BUG]: eslint-plugin-drizzle where-clause rules skip `#private` receivers

Open Beginner friendly
#6,287 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

### What version of `drizzle-orm` are you using?

1.0.0-rc.4

### What version of `drizzle-kit` are you using?

1.0.0-rc.4

### Other packages

eslint-plugin-drizzle@0.2.3

### Describe the Bug

`enforce-delete-with-where` and `enforce-update-with-where` report nothing when the Drizzle instance is a native private class field.

```ts
class UserRepo {
#db: Database;
constructor(db: Database) { this.#db = db; }

clear() {
return this.#db.delete(users); // no report
}
}
```

The rules do report the same code when the field is `private db` or a plain `db` variable.

`isDrizzleObj` in `src/utils/options.ts` only accepts `node.object.property.type === 'Identifier'`. `#db` is a `PrivateIdentifier`, so the check returns false. `resolveMemberExpressionPath` in `src/utils/ast.ts` skips `PrivateIdentifier` too, so after fixing the first check the message would suggest `this.delete(...).where(...)` instead of `this.#db.delete(...).where(...)`.

Both rules should treat `this.#db` like `this.db`. Accepting `PrivateIdentifier` as well as `Identifier` in those two helpers fixes it.

Contributor guide

Open the contributing guide

Research direction

Start in src/utils/options.ts at isDrizzleObj and src/utils/ast.ts at resolveMemberExpressionPath. Trace how enforce-delete-with-where and enforce-update-with-where use these helpers, then verify that native private receivers are recognized like regular members. Done means both rules report the missing where clause and preserve this.#db in the suggested message.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.