Skip to content

Commit 0a2f822

Browse files
KyleAMathewsclaudeautofix-ci[bot]
authored
chore: fix all eslint errors and warnings (#1349)
* Fix all eslint errors and warnings across the repo - Remove unnecessary optional chains on non-nullish values (113 instances) - Remove unnecessary type assertions (2 instances) - Fix async functions with no await expression - Fix variable shadowing (rename or eslint-disable where renaming breaks API) - Fix empty destructuring patterns in vitest fixtures - Suppress unused vars in vitest fixture dependencies needed for ordering - Remove stale eslint-disable directive - Add vite.config.ts to eslint ignores (not in tsconfig) - Change query-once-api changeset from minor to patch (pre-1.0) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci: apply automated fixes * chore: change query-once-api changeset from minor to patch Pre-1.0 package — patch is appropriate for new features. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: wrap onDelete/onInsert returns in Promise.resolve() Removing async changed the return type from Promise<{refetch}> to {refetch}, which doesn't match the mutation handler types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 495abc2 commit 0a2f822

37 files changed

+154
-141
lines changed

.changeset/query-once-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
'@tanstack/db': minor
2+
'@tanstack/db': patch
33
---
44

55
Add `queryOnce` helper for one-shot query execution, including `findOne()` support and optional QueryBuilder configs.

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default [
99
`**/.nitro/**`,
1010
`**/traildepot/**`,
1111
`examples/angular/**`,
12+
`packages/db-collection-e2e/vite.config.ts`,
1213
],
1314
},
1415
{

packages/db-collection-e2e/support/global-setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { Client } from 'pg'
2+
import type { ClientConfig } from 'pg'
13
import type { GlobalSetupContext } from 'vitest/node'
2-
import { Client, type ClientConfig } from 'pg'
34

45
const ELECTRIC_URL = process.env.ELECTRIC_URL ?? 'http://localhost:3000'
56
const POSTGRES_HOST = process.env.POSTGRES_HOST ?? 'localhost'

packages/db-collection-e2e/support/test-context.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { test, inject } from 'vitest'
2-
import { Client } from 'pg'
1+
import { inject, test } from 'vitest'
2+
import { generateSeedData } from '../src/fixtures/seed-data'
33
import { makePgClient } from './global-setup'
4+
import type { Client } from 'pg'
45
import type { SeedDataResult } from '../src/types'
5-
import { generateSeedData } from '../src/fixtures/seed-data'
66

77
/**
88
* Base fixture with database client and abort controller
@@ -14,6 +14,7 @@ export const testWithDb = test.extend<{
1414
testSchema: string
1515
tableName: (base: string) => string
1616
}>({
17+
// eslint-disable-next-line no-empty-pattern
1718
dbClient: async ({}, use) => {
1819
const schema = inject('testSchema')
1920
const client = makePgClient({
@@ -28,16 +29,19 @@ export const testWithDb = test.extend<{
2829
await client.end()
2930
},
3031

32+
// eslint-disable-next-line no-empty-pattern
3133
aborter: async ({}, use) => {
3234
const controller = new AbortController()
3335
await use(controller)
3436
controller.abort('Test complete')
3537
},
3638

39+
// eslint-disable-next-line no-empty-pattern
3740
baseUrl: async ({}, use) => {
3841
await use(inject('baseUrl'))
3942
},
4043

44+
// eslint-disable-next-line no-empty-pattern
4145
testSchema: async ({}, use) => {
4246
await use(inject('testSchema'))
4347
},
@@ -63,7 +67,7 @@ export const testWithTables = testWithDb.extend<{
6367
}>({
6468
usersTable: async ({ dbClient, tableName, task }, use) => {
6569
const name = tableName('users')
66-
const taskFile = task.file?.name.replace(/'/g, '`') ?? 'unknown'
70+
const taskFile = task.file.name.replace(/'/g, '`')
6771
const taskName = task.name.replace(/'/g, '`')
6872

6973
await dbClient.query(`
@@ -90,9 +94,10 @@ export const testWithTables = testWithDb.extend<{
9094
}
9195
},
9296

97+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
9398
postsTable: async ({ dbClient, tableName, usersTable, task }, use) => {
9499
const name = tableName('posts')
95-
const taskFile = task.file?.name.replace(/'/g, '`') ?? 'unknown'
100+
const taskFile = task.file.name.replace(/'/g, '`')
96101
const taskName = task.name.replace(/'/g, '`')
97102

98103
await dbClient.query(`
@@ -119,11 +124,12 @@ export const testWithTables = testWithDb.extend<{
119124
},
120125

121126
commentsTable: async (
127+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
122128
{ dbClient, tableName, postsTable, usersTable, task },
123129
use,
124130
) => {
125131
const name = tableName('comments')
126-
const taskFile = task.file?.name.replace(/'/g, '`') ?? 'unknown'
132+
const taskFile = task.file.name.replace(/'/g, '`')
127133
const taskName = task.name.replace(/'/g, '`')
128134

129135
await dbClient.query(`
@@ -171,6 +177,7 @@ export const testWithSeedData = testWithTables.extend<{
171177
seedData: SeedDataResult
172178
insertSeedData: () => Promise<void>
173179
}>({
180+
// eslint-disable-next-line no-empty-pattern
174181
seedData: async ({}, use) => {
175182
const seed = generateSeedData()
176183
await use(seed)

packages/db/tests/collection-subscriber-duplicate-inserts.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ describe(`CollectionSubscriber duplicate insert prevention`, () => {
403403
eq(u.id, o.userId),
404404
)
405405
.select(({ users: u2, orders: o2 }) => ({
406-
orderId: o2!.id,
406+
orderId: o2.id,
407407
userName: u2.name,
408-
amount: o2!.amount,
408+
amount: o2.amount,
409409
})),
410410
)
411411

packages/db/tests/query/builder/buildQuery.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe(`buildQuery function`, () => {
6767
)
6868
.select(({ employees, departments }) => ({
6969
employee_name: employees.name,
70-
department_name: departments?.name,
70+
department_name: departments.name,
7171
})),
7272
)
7373

packages/db/tests/query/builder/functional-variants.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ describe(`QueryBuilder functional variants (fn)`, () => {
221221
({ employees, departments }) =>
222222
eq(employees.department_id, departments.id),
223223
)
224-
.groupBy(({ departments }) => departments?.name)
224+
.groupBy(({ departments }) => departments.name)
225225
.fn.having(
226226
(row) =>
227227
row.employees.salary > 60000 &&
@@ -245,7 +245,7 @@ describe(`QueryBuilder functional variants (fn)`, () => {
245245
)
246246
.fn.where((row) => row.employees.active)
247247
.fn.where((row) => row.employees.salary > 40000)
248-
.groupBy(({ departments }) => departments?.name)
248+
.groupBy(({ departments }) => departments.name)
249249
.fn.having((row) => row.employees.salary > 70000)
250250
.fn.select((row) => ({
251251
departmentName: row.departments?.name || `Unknown`,

packages/db/tests/query/builder/join.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe(`QueryBuilder.join`, () => {
7575
eq(employees.department_id, departments.id),
7676
)
7777
.join({ projects: projectsCollection }, ({ departments, projects }) =>
78-
eq(departments?.id, projects.department_id),
78+
eq(departments.id, projects.department_id),
7979
)
8080

8181
const builtQuery = getQueryIR(query)
@@ -101,8 +101,8 @@ describe(`QueryBuilder.join`, () => {
101101
.select(({ employees, departments }) => ({
102102
id: employees.id,
103103
name: employees.name,
104-
department_name: departments?.name,
105-
department_budget: departments?.budget,
104+
department_name: departments.name,
105+
department_budget: departments.budget,
106106
}))
107107

108108
const builtQuery = getQueryIR(query)
@@ -122,7 +122,7 @@ describe(`QueryBuilder.join`, () => {
122122
({ employees, departments }) =>
123123
eq(employees.department_id, departments.id),
124124
)
125-
.where(({ departments }) => gt(departments?.budget, 1000000))
125+
.where(({ departments }) => gt(departments.budget, 1000000))
126126

127127
const builtQuery = getQueryIR(query)
128128
expect(builtQuery.where).toBeDefined()
@@ -160,13 +160,13 @@ describe(`QueryBuilder.join`, () => {
160160
eq(employees.department_id, departments.id),
161161
)
162162
.where(({ employees, departments }) =>
163-
and(gt(employees.salary, 50000), gt(departments?.budget, 1000000)),
163+
and(gt(employees.salary, 50000), gt(departments.budget, 1000000)),
164164
)
165165
.select(({ employees, departments }) => ({
166166
id: employees.id,
167167
name: employees.name,
168-
department_name: departments?.name,
169-
dept_location: departments?.location,
168+
department_name: departments.name,
169+
dept_location: departments.location,
170170
}))
171171

172172
const builtQuery = getQueryIR(query)
@@ -360,7 +360,7 @@ describe(`QueryBuilder.join`, () => {
360360
.innerJoin(
361361
{ projects: projectsCollection },
362362
({ departments, projects }) =>
363-
eq(departments?.id, projects.department_id),
363+
eq(departments.id, projects.department_id),
364364
)
365365

366366
const builtQuery = getQueryIR(query)

packages/db/tests/query/builder/subqueries.test-d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe(`Subquery Types`, () => {
119119
.select(({ issue, activeUser }) => ({
120120
issueId: issue.id,
121121
issueTitle: issue.title,
122-
userName: activeUser?.name,
122+
userName: activeUser.name,
123123
}))
124124

125125
// Verify the result type
@@ -148,7 +148,7 @@ describe(`Subquery Types`, () => {
148148
)
149149
.select(({ issue, activeUser }) => ({
150150
issueId: issue.id,
151-
userName: activeUser?.name,
151+
userName: activeUser.name,
152152
}))
153153

154154
// Verify the result type
@@ -250,7 +250,7 @@ describe(`Subquery Types`, () => {
250250
)
251251
.select(({ issue, activeUser }) => ({
252252
issueId: issue.id,
253-
userName: activeUser?.name,
253+
userName: activeUser.name,
254254
}))
255255

256256
// Verify the result type
@@ -274,7 +274,7 @@ describe(`Subquery Types`, () => {
274274
)
275275
.select(({ issue, user }) => ({
276276
issueId: issue.id,
277-
userName: user?.name,
277+
userName: user.name,
278278
}))
279279

280280
// Verify the result type

packages/db/tests/query/compiler/subqueries.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ describe(`Query2 Subqueries`, () => {
232232
.select(({ issue, activeUser }) => ({
233233
issueId: issue.id,
234234
issueTitle: issue.title,
235-
userName: activeUser?.name,
235+
userName: activeUser.name,
236236
}))
237237

238238
const builtQuery = getQueryIR(query)
@@ -267,7 +267,7 @@ describe(`Query2 Subqueries`, () => {
267267
.select(({ issue, activeUser }) => ({
268268
issueId: issue.id,
269269
issueTitle: issue.title,
270-
userName: activeUser?.name,
270+
userName: activeUser.name,
271271
}))
272272

273273
const builtQuery = getQueryIR(query)
@@ -363,7 +363,7 @@ describe(`Query2 Subqueries`, () => {
363363
.select(({ issue, userInfo }) => ({
364364
issueId: issue.id,
365365
issueTitle: issue.title,
366-
userName: userInfo?.name,
366+
userName: userInfo.name,
367367
}))
368368

369369
const builtQuery = getQueryIR(outerQuery)

0 commit comments

Comments
 (0)