Skip to content

Commit acdea9f

Browse files
NicolappsConvex, Inc.
authored andcommitted
private-demos/tanstack-start: Migrate ESLint to v9 (#42398)
GitOrigin-RevId: f2620c2ff8b65df63759a4ad89e93f2c9127f364
1 parent c8ac4f1 commit acdea9f

File tree

11 files changed

+743
-598
lines changed

11 files changed

+743
-598
lines changed

npm-packages/common/config/rush/pnpm-lock.yaml

Lines changed: 671 additions & 459 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm-packages/private-demos/tanstack-start/.eslintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

npm-packages/private-demos/tanstack-start/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
pnpm-lock.yaml
55
routeTree.gen.ts
66
convex/_generated/*
7+
dist/*

npm-packages/private-demos/tanstack-start/convex/README.md

Lines changed: 0 additions & 90 deletions
This file was deleted.
Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,44 @@
1-
import { action, mutation } from './_generated/server'
2-
import { query } from './_generated/server'
3-
import { api } from './_generated/api.js'
41
import { v } from 'convex/values'
2+
import { action, mutation, query } from './_generated/server'
3+
import { api } from './_generated/api.js'
54

6-
export const list = query(async (ctx, { cacheBust }) => {
7-
const _unused = cacheBust
8-
return await ctx.db.query('messages').collect()
5+
export const list = query({
6+
args: {},
7+
handler: async (ctx) => {
8+
return await ctx.db.query('messages').collect()
9+
},
910
})
1011

11-
export const count = query(async (ctx, { cacheBust }) => {
12-
const _unused = cacheBust
13-
return (await ctx.db.query('messages').collect()).length
12+
export const count = query({
13+
args: {
14+
cacheBust: v.optional(v.any()),
15+
},
16+
handler: async (ctx) => {
17+
return (await ctx.db.query('messages').collect()).length
18+
},
1419
})
1520

16-
export const listUsers = query(async (ctx, { cacheBust }) => {
17-
const _unused = cacheBust
18-
return await ctx.db.query('users').collect()
21+
export const listUsers = query({
22+
args: {},
23+
handler: async (ctx) => {
24+
return await ctx.db.query('users').collect()
25+
},
1926
})
2027

21-
export const countUsers = query(async (ctx, { cacheBust }) => {
22-
const _unused = cacheBust
23-
return (await ctx.db.query('users').collect()).length
28+
export const countUsers = query({
29+
args: {
30+
cacheBust: v.optional(v.any()),
31+
},
32+
handler: async (ctx) => {
33+
return (await ctx.db.query('users').collect()).length
34+
},
2435
})
2536

26-
function choose(choices: string[]): string {
37+
function choose(choices: Array<string>): string {
2738
return choices[Math.floor(Math.random() * choices.length)]
2839
}
2940

30-
function madlib(strings: TemplateStringsArray, ...choices: any[]): string {
41+
function madlib(strings: TemplateStringsArray, ...choices: Array<any>): string {
3142
return strings.reduce((result, str, i) => {
3243
return result + str + (choices[i] ? choose(choices[i]) : '')
3344
}, '')
@@ -44,12 +55,15 @@ const text = [
4455
"Could you let the customer know we've fixed their issue?",
4556
]
4657

47-
export const sendGeneratedMessage = mutation(async (ctx) => {
48-
const body = madlib`${greetings} ${names}${punc} ${text}`
49-
const user = await ctx.db.insert('users', {
50-
name: 'user' + Math.floor(Math.random() * 1000),
51-
})
52-
await ctx.db.insert('messages', { body, user: user })
58+
export const sendGeneratedMessage = mutation({
59+
args: {},
60+
handler: async (ctx) => {
61+
const body = madlib`${greetings} ${names}${punc} ${text}`
62+
const user = await ctx.db.insert('users', {
63+
name: 'user' + Math.floor(Math.random() * 1000),
64+
})
65+
await ctx.db.insert('messages', { body, user: user })
66+
},
5367
})
5468

5569
// TODO concurrency here
@@ -63,16 +77,19 @@ export const sendGeneratedMessages = action({
6377
},
6478
})
6579

66-
export const clear = mutation(async (ctx) => {
67-
await Promise.all([
68-
...(await ctx.db.query('messages').collect()).map((message) => {
69-
ctx.db.delete(message._id)
70-
}),
71-
...(await ctx.db.query('users').collect()).map((user) => {
72-
ctx.db.delete(user._id)
73-
}),
74-
])
75-
for (const user of await ctx.db.query('users').collect()) {
76-
await ctx.db.delete(user._id)
77-
}
80+
export const clear = mutation({
81+
args: {},
82+
handler: async (ctx) => {
83+
await Promise.all([
84+
...(await ctx.db.query('messages').collect()).map((message) => {
85+
ctx.db.delete(message._id)
86+
}),
87+
...(await ctx.db.query('users').collect()).map((user) => {
88+
ctx.db.delete(user._id)
89+
}),
90+
])
91+
for (const user of await ctx.db.query('users').collect()) {
92+
await ctx.db.delete(user._id)
93+
}
94+
},
7895
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config'
2+
import { tanstackConfig } from '@tanstack/eslint-config'
3+
import convexPlugin from '@convex-dev/eslint-plugin'
4+
5+
export default defineConfig([
6+
...tanstackConfig,
7+
...convexPlugin.configs.recommended,
8+
globalIgnores(['convex/_generated', 'dist']),
9+
])

npm-packages/private-demos/tanstack-start/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dev:convex": "npx convex dev",
1111
"build": "vite build && tsc --noEmit",
1212
"start": "node .output/server/index.mjs",
13-
"lint": "prettier --check '**/*' --ignore-unknown && eslint --ext .ts,.tsx ./app",
13+
"lint": "prettier --check '**/*' --ignore-unknown && eslint .",
1414
"format": "prettier --write '**/*' --ignore-unknown"
1515
},
1616
"keywords": [],
@@ -27,13 +27,14 @@
2727
"react-dom": "^18.3.1"
2828
},
2929
"devDependencies": {
30+
"@convex-dev/eslint-plugin": "workspace:*",
31+
"@tanstack/eslint-config": "^0.3.0",
3032
"@types/react": "^18.2.65",
3133
"@types/react-dom": "^18.2.21",
3234
"@typescript-eslint/parser": "^6.7.4",
3335
"@vitejs/plugin-react": "^4.2.1",
3436
"concurrently": "~8.2.2",
35-
"eslint": "^8.29.0",
36-
"eslint-config-react-app": "~7.0.1",
37+
"eslint": "^9.37.0",
3738
"prettier": "3.6.2",
3839
"typescript": "^5.9.2",
3940
"vite-tsconfig-paths": "^5.1.3",

npm-packages/private-demos/tanstack-start/src/router.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { createRouter } from '@tanstack/react-router'
2-
import { routeTree } from './routeTree.gen'
32
import { ConvexQueryClient } from '@convex-dev/react-query'
43
import { QueryClient } from '@tanstack/react-query'
54
import { routerWithQueryClient } from '@tanstack/react-router-with-query'
65
import { ConvexProvider, ConvexReactClient } from 'convex/react'
6+
import { routeTree } from './routeTree.gen'
77
import { DefaultCatchBoundary } from './components/DefaultCatchBoundary'
88
import { NotFound } from './components/NotFound'
99

npm-packages/private-demos/tanstack-start/src/routes/__root.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { QueryClient } from '@tanstack/react-query'
21
import {
3-
createRootRouteWithContext,
42
HeadContent,
5-
Scripts,
63
Outlet,
4+
Scripts,
5+
createRootRouteWithContext,
76
} from '@tanstack/react-router'
87
import * as React from 'react'
8+
import type { QueryClient } from '@tanstack/react-query'
99

1010
export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()(
1111
{

npm-packages/private-demos/tanstack-start/src/routes/simple-sibling-queries.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createFileRoute } from '@tanstack/react-router'
22
import { useMutation, useSuspenseQuery } from '@tanstack/react-query'
3-
import { api } from '../../convex/_generated/api'
43
import { convexQuery, useConvexAction } from '@convex-dev/react-query'
4+
import { api } from '../../convex/_generated/api'
55

66
export const Route = createFileRoute('/simple-sibling-queries')({
77
component: SimpleSiblingQueries,

0 commit comments

Comments
 (0)