diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8fbf8f760..b39f31408 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,9 +1,9 @@ --- name: šŸ› Bug Report about: Create a report to help us improve -title: "" -labels: "" -assignees: "" +title: '' +labels: '' +assignees: '' --- - [ ] I've validated the bug against the latest version of DB packages diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index d783ef32d..554769b60 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -24,10 +24,8 @@ jobs: - name: Setup Tools uses: tanstack/config/.github/setup@main - name: Fix formatting - run: pnpm prettier --ignore-unknown . --check - - name: Run ESLint - run: pnpm run lint + run: pnpm format - name: Apply fixes uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 with: - commit-message: "ci: apply automated fixes" + commit-message: 'ci: apply automated fixes' diff --git a/.github/workflows/docs-sync.yml b/.github/workflows/docs-sync.yml index fdbcb9ba2..a53823435 100644 --- a/.github/workflows/docs-sync.yml +++ b/.github/workflows/docs-sync.yml @@ -3,7 +3,7 @@ name: Sync Generated Docs on: schedule: # Run daily at 2 AM UTC - - cron: "0 2 * * *" + - cron: '0 2 * * *' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 2c5ac83b0..781738da4 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -23,8 +23,8 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: "20" - cache: "pnpm" + node-version: '20' + cache: 'pnpm' - name: Install dependencies run: pnpm install --frozen-lockfile diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9d789f762..21fee0463 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -51,17 +51,17 @@ jobs: - name: Compressed Size Action - DB Package uses: preactjs/compressed-size-action@v2 with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - pattern: "./packages/db/dist/**/*.{js,mjs}" - comment-key: "db-package-size" - build-script: "build:minified" + repo-token: '${{ secrets.GITHUB_TOKEN }}' + pattern: './packages/db/dist/**/*.{js,mjs}' + comment-key: 'db-package-size' + build-script: 'build:minified' - name: Compressed Size Action - React DB Package uses: preactjs/compressed-size-action@v2 with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - pattern: "./packages/react-db/dist/**/*.{js,mjs}" - comment-key: "react-db-package-size" - build-script: "build:minified" + repo-token: '${{ secrets.GITHUB_TOKEN }}' + pattern: './packages/react-db/dist/**/*.{js,mjs}' + comment-key: 'react-db-package-size' + build-script: 'build:minified' build-example: name: Build Example Site runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11042f7b0..cad12d577 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,8 +36,8 @@ jobs: with: version: pnpm run changeset:version publish: pnpm run changeset:publish - commit: "ci: Version Packages" - title: "ci: Version Packages" + commit: 'ci: Version Packages' + title: 'ci: Version Packages' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.pnpmfile.cjs b/.pnpmfile.cjs index f154da33d..70392f0a0 100644 --- a/.pnpmfile.cjs +++ b/.pnpmfile.cjs @@ -1,17 +1,17 @@ function readPackage(pkg, context) { // Force all @tanstack/db dependencies to resolve to workspace version - if (pkg.dependencies && pkg.dependencies["@tanstack/db"]) { - pkg.dependencies["@tanstack/db"] = "workspace:*" + if (pkg.dependencies && pkg.dependencies['@tanstack/db']) { + pkg.dependencies['@tanstack/db'] = 'workspace:*' context.log(`Overriding @tanstack/db dependency in ${pkg.name}`) } - if (pkg.devDependencies && pkg.devDependencies["@tanstack/db"]) { - pkg.devDependencies["@tanstack/db"] = "workspace:*" + if (pkg.devDependencies && pkg.devDependencies['@tanstack/db']) { + pkg.devDependencies['@tanstack/db'] = 'workspace:*' context.log(`Overriding @tanstack/db devDependency in ${pkg.name}`) } - if (pkg.peerDependencies && pkg.peerDependencies["@tanstack/db"]) { - pkg.peerDependencies["@tanstack/db"] = "workspace:*" + if (pkg.peerDependencies && pkg.peerDependencies['@tanstack/db']) { + pkg.peerDependencies['@tanstack/db'] = 'workspace:*' context.log(`Overriding @tanstack/db peerDependency in ${pkg.name}`) } diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index eaff0359c..000000000 --- a/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "trailingComma": "es5", - "semi": false, - "tabWidth": 2 -} diff --git a/AGENTS.md b/AGENTS.md index ee8056447..6654f89bf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,7 +36,7 @@ function processData(data: unknown) { if (isDataObject(data)) { return data.value } - throw new Error("Invalid data") + throw new Error('Invalid data') } const result: TQueryData = someOperation() @@ -58,12 +58,12 @@ const result: TQueryData = someOperation() ```typescript // Duplicated logic in multiple places function processA() { - const key = typeof value === "number" ? `__number__${value}` : String(value) + const key = typeof value === 'number' ? `__number__${value}` : String(value) // ... } function processB() { - const key = typeof value === "number" ? `__number__${value}` : String(value) + const key = typeof value === 'number' ? `__number__${value}` : String(value) // ... } ``` @@ -72,7 +72,7 @@ function processB() { ```typescript function serializeKey(value: string | number): string { - return typeof value === "number" ? `__number__${value}` : String(value) + return typeof value === 'number' ? `__number__${value}` : String(value) } function processA() { @@ -161,7 +161,7 @@ readyJobs.forEach(processJob) ```typescript // O(n) lookup for each check -const items = ["foo", "bar", "baz" /* hundreds more */] +const items = ['foo', 'bar', 'baz' /* hundreds more */] if (items.includes(searchValue)) { // ... } @@ -171,7 +171,7 @@ if (items.includes(searchValue)) { ```typescript // O(1) lookup -const items = new Set(["foo", "bar", "baz" /* hundreds more */]) +const items = new Set(['foo', 'bar', 'baz' /* hundreds more */]) if (items.has(searchValue)) { // ... } @@ -194,7 +194,7 @@ if (items.has(searchValue)) { // Intending to check if subset limit is more restrictive than superset function isLimitSubset( subset: number | undefined, - superset: number | undefined + superset: number | undefined, ) { return subset === undefined || superset === undefined || subset <= superset } @@ -207,7 +207,7 @@ function isLimitSubset( ```typescript function isLimitSubset( subset: number | undefined, - superset: number | undefined + superset: number | undefined, ) { // Subset with no limit cannot be a subset of one with a limit return superset === undefined || (subset !== undefined && subset <= superset) @@ -361,7 +361,7 @@ const dependentBuilders = [] // Accurately describes dependents ```typescript // Found a bug with fetchSnapshot resolving after up-to-date message // Should add a test: -test("ignores snapshot that resolves after up-to-date message", async () => { +test('ignores snapshot that resolves after up-to-date message', async () => { // Reproduce the corner case // Verify it's handled correctly }) @@ -520,7 +520,7 @@ const filtered = items.filter((item) => item.value > 0) ```typescript // āŒ Bad: numeric 1 and string "__number__1" collide - const key = typeof val === "number" ? `__number__${val}` : String(val) + const key = typeof val === 'number' ? `__number__${val}` : String(val) // āœ… Good: proper encoding with type prefix const key = `${typeof val}_${String(val)}` diff --git a/eslint.config.js b/eslint.config.js index 1f40676a4..02e6c5438 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,4 @@ -import prettierPlugin from "eslint-plugin-prettier" -import prettierConfig from "eslint-config-prettier" -import stylisticPlugin from "@stylistic/eslint-plugin" -import { tanstackConfig } from "@tanstack/config/eslint" +import { tanstackConfig } from '@tanstack/config/eslint' export default [ ...tanstackConfig, @@ -15,31 +12,24 @@ export default [ ], }, { - plugins: { - stylistic: stylisticPlugin, - prettier: prettierPlugin, - }, settings: { // import-x/* settings required for import/no-cycle. - "import-x/resolver": { typescript: true }, - "import-x/extensions": [".ts", ".tsx", ".js", ".jsx", ".cjs", ".mjs"], + 'import-x/resolver': { typescript: true }, + 'import-x/extensions': ['.ts', '.tsx', '.js', '.jsx', '.cjs', '.mjs'], }, rules: { - "prettier/prettier": `error`, - "stylistic/quotes": [`error`, `backtick`], - "pnpm/enforce-catalog": `off`, - "pnpm/json-enforce-catalog": `off`, - ...prettierConfig.rules, + 'pnpm/enforce-catalog': `off`, + 'pnpm/json-enforce-catalog': `off`, }, }, { files: [`**/*.ts`, `**/*.tsx`], rules: { - "@typescript-eslint/no-unused-vars": [ + '@typescript-eslint/no-unused-vars': [ `error`, { argsIgnorePattern: `^_`, varsIgnorePattern: `^_` }, ], - "@typescript-eslint/naming-convention": [ + '@typescript-eslint/naming-convention': [ `error`, { selector: `typeParameter`, @@ -47,7 +37,7 @@ export default [ leadingUnderscore: `allow`, }, ], - "import/no-cycle": `error`, + 'import/no-cycle': `error`, }, }, ] diff --git a/examples/angular/todos/src/app/app.config.ts b/examples/angular/todos/src/app/app.config.ts index 414eeaeb8..a690ebc33 100644 --- a/examples/angular/todos/src/app/app.config.ts +++ b/examples/angular/todos/src/app/app.config.ts @@ -2,10 +2,10 @@ import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection, -} from '@angular/core'; -import { provideRouter } from '@angular/router'; +} from '@angular/core' +import { provideRouter } from '@angular/router' -import { routes } from './app.routes'; +import { routes } from './app.routes' export const appConfig: ApplicationConfig = { providers: [ @@ -13,4 +13,4 @@ export const appConfig: ApplicationConfig = { provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), ], -}; +} diff --git a/examples/angular/todos/src/app/app.routes.ts b/examples/angular/todos/src/app/app.routes.ts index c4dcbaef3..5281a3272 100644 --- a/examples/angular/todos/src/app/app.routes.ts +++ b/examples/angular/todos/src/app/app.routes.ts @@ -1,5 +1,5 @@ -import { Routes } from '@angular/router'; +import { Routes } from '@angular/router' export const routes: Routes = [ // Add your routes here -]; +] diff --git a/examples/angular/todos/src/app/app.ts b/examples/angular/todos/src/app/app.ts index 55c59b7f2..46b1609d0 100644 --- a/examples/angular/todos/src/app/app.ts +++ b/examples/angular/todos/src/app/app.ts @@ -1,9 +1,9 @@ -import { Component, signal } from '@angular/core'; -import { injectLiveQuery } from '@tanstack/angular-db'; -import { eq } from '@tanstack/db'; -import { todosCollection } from '../collections/todos-collection'; -import { FormsModule } from '@angular/forms'; -import { CommonModule } from '@angular/common'; +import { Component, signal } from '@angular/core' +import { injectLiveQuery } from '@tanstack/angular-db' +import { eq } from '@tanstack/db' +import { todosCollection } from '../collections/todos-collection' +import { FormsModule } from '@angular/forms' +import { CommonModule } from '@angular/common' @Component({ selector: 'app-root', @@ -140,20 +140,20 @@ export class App { projects = [ { id: 1, name: 'Work' }, { id: 2, name: 'Home' }, - ]; + ] - selectedProjectId = signal(2); + selectedProjectId = signal(2) todoQuery = injectLiveQuery({ params: () => ({ projectID: this.selectedProjectId() }), query: ({ params, q }) => q.from({ todo: todosCollection }).where(({ todo }) => eq(todo.projectID, params.projectID)), - }); + }) - newTodoText = ''; + newTodoText = '' addTodo() { - if (!this.newTodoText.trim()) return; + if (!this.newTodoText.trim()) return const newTodo = { id: Date.now(), @@ -161,23 +161,23 @@ export class App { projectID: this.selectedProjectId(), completed: false, created_at: new Date(), - }; + } - todosCollection.insert(newTodo); - this.newTodoText = ''; + todosCollection.insert(newTodo) + this.newTodoText = '' } toggleTodo(id: number) { todosCollection.update(id, (draft: any) => { - draft.completed = !draft.completed; - }); + draft.completed = !draft.completed + }) } deleteTodo(id: number) { - todosCollection.delete(id); + todosCollection.delete(id) } getCompletedCount(): number { - return this.todoQuery.data().filter((todo) => todo.completed).length; + return this.todoQuery.data().filter((todo) => todo.completed).length } } diff --git a/examples/angular/todos/src/collections/todos-collection.ts b/examples/angular/todos/src/collections/todos-collection.ts index 1aa97d796..70e2fbb89 100644 --- a/examples/angular/todos/src/collections/todos-collection.ts +++ b/examples/angular/todos/src/collections/todos-collection.ts @@ -1,11 +1,11 @@ -import { createCollection, localOnlyCollectionOptions } from '@tanstack/db'; +import { createCollection, localOnlyCollectionOptions } from '@tanstack/db' interface Todo { - id: number; - text: string; - projectID: number; - completed: boolean; - created_at: Date; + id: number + text: string + projectID: number + completed: boolean + created_at: Date } export const todosCollection = createCollection( @@ -42,4 +42,4 @@ export const todosCollection = createCollection( }, ], }), -); +) diff --git a/examples/angular/todos/src/main.ts b/examples/angular/todos/src/main.ts index 190f3418d..8192dca69 100644 --- a/examples/angular/todos/src/main.ts +++ b/examples/angular/todos/src/main.ts @@ -1,5 +1,5 @@ -import { bootstrapApplication } from '@angular/platform-browser'; -import { appConfig } from './app/app.config'; -import { App } from './app/app'; +import { bootstrapApplication } from '@angular/platform-browser' +import { appConfig } from './app/app.config' +import { App } from './app/app' -bootstrapApplication(App, appConfig).catch((err) => console.error(err)); +bootstrapApplication(App, appConfig).catch((err) => console.error(err)) diff --git a/examples/angular/todos/tailwind.config.js b/examples/angular/todos/tailwind.config.js index 0cc494f78..cf64e228a 100644 --- a/examples/angular/todos/tailwind.config.js +++ b/examples/angular/todos/tailwind.config.js @@ -5,4 +5,4 @@ module.exports = { extend: {}, }, plugins: [], -}; +} diff --git a/examples/react/offline-transactions/src/components/DefaultCatchBoundary.tsx b/examples/react/offline-transactions/src/components/DefaultCatchBoundary.tsx index 63e20524f..ae1b64f67 100644 --- a/examples/react/offline-transactions/src/components/DefaultCatchBoundary.tsx +++ b/examples/react/offline-transactions/src/components/DefaultCatchBoundary.tsx @@ -4,8 +4,8 @@ import { rootRouteId, useMatch, useRouter, -} from "@tanstack/react-router" -import type { ErrorComponentProps } from "@tanstack/react-router" +} from '@tanstack/react-router' +import type { ErrorComponentProps } from '@tanstack/react-router' export function DefaultCatchBoundary({ error }: ErrorComponentProps) { const router = useRouter() diff --git a/examples/react/offline-transactions/src/components/NotFound.tsx b/examples/react/offline-transactions/src/components/NotFound.tsx index b29bf8dc7..7b54fa568 100644 --- a/examples/react/offline-transactions/src/components/NotFound.tsx +++ b/examples/react/offline-transactions/src/components/NotFound.tsx @@ -1,4 +1,4 @@ -import { Link } from "@tanstack/react-router" +import { Link } from '@tanstack/react-router' export function NotFound({ children }: { children?: any }) { return ( diff --git a/examples/react/offline-transactions/src/components/TodoDemo.tsx b/examples/react/offline-transactions/src/components/TodoDemo.tsx index 4a4bd3259..fcdf088da 100644 --- a/examples/react/offline-transactions/src/components/TodoDemo.tsx +++ b/examples/react/offline-transactions/src/components/TodoDemo.tsx @@ -1,6 +1,6 @@ -import React, { useEffect, useMemo, useState } from "react" -import { useLiveQuery } from "@tanstack/react-db" -import { createTodoActions, todoCollection } from "~/db/todos" +import React, { useEffect, useMemo, useState } from 'react' +import { useLiveQuery } from '@tanstack/react-db' +import { createTodoActions, todoCollection } from '~/db/todos' interface TodoDemoProps { title: string @@ -28,7 +28,7 @@ export function TodoDemo({ const { data: todoList = [], isLoading } = useLiveQuery((q) => q .from({ todo: todoCollection }) - .orderBy(({ todo }) => todo.createdAt, `desc`) + .orderBy(({ todo }) => todo.createdAt, `desc`), ) // Monitor online status diff --git a/examples/react/offline-transactions/src/db/todos.ts b/examples/react/offline-transactions/src/db/todos.ts index bc50377f4..1d8be0340 100644 --- a/examples/react/offline-transactions/src/db/todos.ts +++ b/examples/react/offline-transactions/src/db/todos.ts @@ -1,14 +1,14 @@ -import { createCollection } from "@tanstack/react-db" -import { queryCollectionOptions } from "@tanstack/query-db-collection" +import { createCollection } from '@tanstack/react-db' +import { queryCollectionOptions } from '@tanstack/query-db-collection' import { IndexedDBAdapter, LocalStorageAdapter, startOfflineExecutor, -} from "@tanstack/offline-transactions" -import { z } from "zod" -import type { PendingMutation } from "@tanstack/db" -import type { Todo } from "~/utils/todos" -import { queryClient } from "~/utils/queryClient" +} from '@tanstack/offline-transactions' +import { z } from 'zod' +import type { PendingMutation } from '@tanstack/db' +import type { Todo } from '~/utils/todos' +import { queryClient } from '~/utils/queryClient' /** * A utility function to fetch data from a URL with built-in retry logic for non-200 responses. @@ -29,7 +29,7 @@ import { queryClient } from "~/utils/queryClient" export async function fetchWithRetry( url: string, options: RequestInit = {}, - retryConfig: { retries?: number; delay?: number; backoff?: number } = {} + retryConfig: { retries?: number; delay?: number; backoff?: number } = {}, ): Promise { const { retries = 6, delay = 1000, backoff = 2 } = retryConfig @@ -45,7 +45,7 @@ export async function fetchWithRetry( // If it's a non-200 response, log the status and prepare to retry console.warn( - `Fetch attempt ${i + 1} failed with status: ${response.status}. Retrying...` + `Fetch attempt ${i + 1} failed with status: ${response.status}. Retrying...`, ) // Wait before the next attempt, with exponential backoff @@ -57,7 +57,7 @@ export async function fetchWithRetry( // Catch network errors and log a message console.error( `Fetch attempt ${i + 1} failed due to a network error:`, - error + error, ) // Wait before the next attempt, with exponential backoff @@ -104,7 +104,7 @@ export const todoCollection = createCollection( }, getKey: (item) => item.id, schema: todoSchema, - }) + }), ) // API client functions @@ -127,8 +127,8 @@ export const todoAPI = { const response = await fetchWithRetry(`/api/todos`, { method: `POST`, headers: { - "Content-Type": `application/json`, - "Idempotency-Key": idempotencyKey, + 'Content-Type': `application/json`, + 'Idempotency-Key': idempotencyKey, }, body: JSON.stringify({ text: todoData.text, @@ -149,14 +149,14 @@ export const todoAPI = { { method: `PUT`, headers: { - "Content-Type": `application/json`, - "Idempotency-Key": idempotencyKey, + 'Content-Type': `application/json`, + 'Idempotency-Key': idempotencyKey, }, body: JSON.stringify({ text: todoData.text, completed: todoData.completed, }), - } + }, ) if (!response.ok) { @@ -171,9 +171,9 @@ export const todoAPI = { { method: `DELETE`, headers: { - "Idempotency-Key": idempotencyKey, + 'Idempotency-Key': idempotencyKey, }, - } + }, ) if (!response.ok) { @@ -265,7 +265,7 @@ export async function createIndexedDBOfflineExecutor() { code: diagnostic.code, message: diagnostic.message, error: diagnostic.error, - } + }, ) }, }) @@ -297,7 +297,7 @@ export async function createLocalStorageOfflineExecutor() { code: diagnostic.code, message: diagnostic.message, error: diagnostic.error, - } + }, ) }, }) diff --git a/examples/react/offline-transactions/src/router.tsx b/examples/react/offline-transactions/src/router.tsx index e15333a99..d5579a802 100644 --- a/examples/react/offline-transactions/src/router.tsx +++ b/examples/react/offline-transactions/src/router.tsx @@ -1,7 +1,7 @@ -import { createRouter as createTanStackRouter } from "@tanstack/react-router" -import { routeTree } from "./routeTree.gen" -import { DefaultCatchBoundary } from "./components/DefaultCatchBoundary" -import { NotFound } from "./components/NotFound" +import { createRouter as createTanStackRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +import { DefaultCatchBoundary } from './components/DefaultCatchBoundary' +import { NotFound } from './components/NotFound' export function createRouter() { const router = createTanStackRouter({ @@ -15,7 +15,7 @@ export function createRouter() { return router } -declare module "@tanstack/react-router" { +declare module '@tanstack/react-router' { interface Register { router: ReturnType } diff --git a/examples/react/offline-transactions/src/routes/__root.tsx b/examples/react/offline-transactions/src/routes/__root.tsx index ae2487fb4..89588bacb 100644 --- a/examples/react/offline-transactions/src/routes/__root.tsx +++ b/examples/react/offline-transactions/src/routes/__root.tsx @@ -4,15 +4,15 @@ import { Link, Scripts, createRootRoute, -} from "@tanstack/react-router" -import { TanStackRouterDevtools } from "@tanstack/react-router-devtools" -import { QueryClientProvider } from "@tanstack/react-query" -import * as React from "react" -import { DefaultCatchBoundary } from "~/components/DefaultCatchBoundary" -import { NotFound } from "~/components/NotFound" -import appCss from "~/styles/app.css?url" -import { seo } from "~/utils/seo" -import { queryClient } from "~/utils/queryClient" +} from '@tanstack/react-router' +import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' +import { QueryClientProvider } from '@tanstack/react-query' +import * as React from 'react' +import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary' +import { NotFound } from '~/components/NotFound' +import appCss from '~/styles/app.css?url' +import { seo } from '~/utils/seo' +import { queryClient } from '~/utils/queryClient' export const Route = createRootRoute({ head: () => ({ diff --git a/examples/react/offline-transactions/src/routes/api/todos.$todoId.ts b/examples/react/offline-transactions/src/routes/api/todos.$todoId.ts index e55263518..21b293645 100644 --- a/examples/react/offline-transactions/src/routes/api/todos.$todoId.ts +++ b/examples/react/offline-transactions/src/routes/api/todos.$todoId.ts @@ -1,7 +1,7 @@ -import { createServerFileRoute } from "@tanstack/react-start/server" -import { json } from "@tanstack/react-start" -import type { TodoUpdate } from "~/utils/todos" -import { todoService } from "~/utils/todos" +import { createServerFileRoute } from '@tanstack/react-start/server' +import { json } from '@tanstack/react-start' +import type { TodoUpdate } from '~/utils/todos' +import { todoService } from '~/utils/todos' export const ServerRoute = createServerFileRoute(`/api/todos/$todoId`).methods({ GET: async ({ params, request }) => { @@ -45,7 +45,7 @@ export const ServerRoute = createServerFileRoute(`/api/todos/$todoId`).methods({ if (error instanceof Error && error.message.includes(`Simulated`)) { return json( { error: `Network error - please try again` }, - { status: 503 } + { status: 503 }, ) } return json({ error: `Failed to update todo` }, { status: 500 }) @@ -71,7 +71,7 @@ export const ServerRoute = createServerFileRoute(`/api/todos/$todoId`).methods({ if (error instanceof Error && error.message.includes(`Simulated`)) { return json( { error: `Network error - please try again` }, - { status: 503 } + { status: 503 }, ) } return json({ error: `Failed to delete todo` }, { status: 500 }) diff --git a/examples/react/offline-transactions/src/routes/api/todos.ts b/examples/react/offline-transactions/src/routes/api/todos.ts index 76623dd3c..8b6d1f8d7 100644 --- a/examples/react/offline-transactions/src/routes/api/todos.ts +++ b/examples/react/offline-transactions/src/routes/api/todos.ts @@ -1,7 +1,7 @@ -import { createServerFileRoute } from "@tanstack/react-start/server" -import { json } from "@tanstack/react-start" -import type { TodoInput } from "~/utils/todos" -import { todoService } from "~/utils/todos" +import { createServerFileRoute } from '@tanstack/react-start/server' +import { json } from '@tanstack/react-start' +import type { TodoInput } from '~/utils/todos' +import { todoService } from '~/utils/todos' export const ServerRoute = createServerFileRoute(`/api/todos`).methods({ GET: async ({ request }) => { @@ -43,7 +43,7 @@ export const ServerRoute = createServerFileRoute(`/api/todos`).methods({ if (error instanceof Error && error.message.includes(`Simulated`)) { return json( { error: `Network error - please try again` }, - { status: 503 } + { status: 503 }, ) } return json({ error: `Failed to create todo` }, { status: 500 }) diff --git a/examples/react/offline-transactions/src/routes/api/users.$userId.ts b/examples/react/offline-transactions/src/routes/api/users.$userId.ts index 8f966de20..19426fbbf 100644 --- a/examples/react/offline-transactions/src/routes/api/users.$userId.ts +++ b/examples/react/offline-transactions/src/routes/api/users.$userId.ts @@ -1,13 +1,13 @@ -import { createServerFileRoute } from "@tanstack/react-start/server" -import { json } from "@tanstack/react-start" -import type { User } from "~/utils/users" +import { createServerFileRoute } from '@tanstack/react-start/server' +import { json } from '@tanstack/react-start' +import type { User } from '~/utils/users' export const ServerRoute = createServerFileRoute(`/api/users/$userId`).methods({ GET: async ({ params, request }) => { console.info(`Fetching users by id=${params.userId}... @`, request.url) try { const res = await fetch( - `https://jsonplaceholder.typicode.com/users/` + params.userId + `https://jsonplaceholder.typicode.com/users/` + params.userId, ) if (!res.ok) { throw new Error(`Failed to fetch user`) diff --git a/examples/react/offline-transactions/src/routes/api/users.ts b/examples/react/offline-transactions/src/routes/api/users.ts index d92e39318..b627c2f1f 100644 --- a/examples/react/offline-transactions/src/routes/api/users.ts +++ b/examples/react/offline-transactions/src/routes/api/users.ts @@ -1,9 +1,9 @@ import { createServerFileRoute, getRequestHeaders, -} from "@tanstack/react-start/server" -import { createMiddleware, json } from "@tanstack/react-start" -import type { User } from "~/utils/users" +} from '@tanstack/react-start/server' +import { createMiddleware, json } from '@tanstack/react-start' +import type { User } from '~/utils/users' const userLoggerMiddleware = createMiddleware({ type: `request` }).server( async ({ next, _request }) => { @@ -13,7 +13,7 @@ const userLoggerMiddleware = createMiddleware({ type: `request` }).server( result.response.headers.set(`x-users`, `true`) console.info(`Out: /users`) return result - } + }, ) const testParentMiddleware = createMiddleware({ type: `request` }).server( @@ -23,7 +23,7 @@ const testParentMiddleware = createMiddleware({ type: `request` }).server( result.response.headers.set(`x-test-parent`, `true`) console.info(`Out: testParentMiddleware`) return result - } + }, ) const testMiddleware = createMiddleware({ type: `request` }) diff --git a/examples/react/offline-transactions/src/routes/index.tsx b/examples/react/offline-transactions/src/routes/index.tsx index bb1db6612..6e9141e5d 100644 --- a/examples/react/offline-transactions/src/routes/index.tsx +++ b/examples/react/offline-transactions/src/routes/index.tsx @@ -1,4 +1,4 @@ -import { Link, createFileRoute } from "@tanstack/react-router" +import { Link, createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute(`/`)({ component: Home, diff --git a/examples/react/offline-transactions/src/routes/indexeddb.tsx b/examples/react/offline-transactions/src/routes/indexeddb.tsx index 5ab1db0d3..de3b88db9 100644 --- a/examples/react/offline-transactions/src/routes/indexeddb.tsx +++ b/examples/react/offline-transactions/src/routes/indexeddb.tsx @@ -1,7 +1,7 @@ -import { createFileRoute } from "@tanstack/react-router" -import { useEffect, useState } from "react" -import { TodoDemo } from "~/components/TodoDemo" -import { createIndexedDBOfflineExecutor } from "~/db/todos" +import { createFileRoute } from '@tanstack/react-router' +import { useEffect, useState } from 'react' +import { TodoDemo } from '~/components/TodoDemo' +import { createIndexedDBOfflineExecutor } from '~/db/todos' export const Route = createFileRoute(`/indexeddb`)({ component: IndexedDBDemo, diff --git a/examples/react/offline-transactions/src/routes/localstorage.tsx b/examples/react/offline-transactions/src/routes/localstorage.tsx index a9db81c5c..91ee02bff 100644 --- a/examples/react/offline-transactions/src/routes/localstorage.tsx +++ b/examples/react/offline-transactions/src/routes/localstorage.tsx @@ -1,7 +1,7 @@ -import { createFileRoute } from "@tanstack/react-router" -import { useEffect, useState } from "react" -import { TodoDemo } from "~/components/TodoDemo" -import { createLocalStorageOfflineExecutor } from "~/db/todos" +import { createFileRoute } from '@tanstack/react-router' +import { useEffect, useState } from 'react' +import { TodoDemo } from '~/components/TodoDemo' +import { createLocalStorageOfflineExecutor } from '~/db/todos' export const Route = createFileRoute(`/localstorage`)({ component: LocalStorageDemo, diff --git a/examples/react/offline-transactions/src/utils/loggingMiddleware.tsx b/examples/react/offline-transactions/src/utils/loggingMiddleware.tsx index 2c516283b..336587007 100644 --- a/examples/react/offline-transactions/src/utils/loggingMiddleware.tsx +++ b/examples/react/offline-transactions/src/utils/loggingMiddleware.tsx @@ -1,4 +1,4 @@ -import { createMiddleware } from "@tanstack/react-start" +import { createMiddleware } from '@tanstack/react-start' const preLogMiddleware = createMiddleware({ type: `function` }) .client(async (ctx) => { diff --git a/examples/react/offline-transactions/src/utils/queryClient.ts b/examples/react/offline-transactions/src/utils/queryClient.ts index 3706eed12..5ca414ef7 100644 --- a/examples/react/offline-transactions/src/utils/queryClient.ts +++ b/examples/react/offline-transactions/src/utils/queryClient.ts @@ -1,4 +1,4 @@ -import { QueryClient } from "@tanstack/react-query" +import { QueryClient } from '@tanstack/react-query' export const queryClient = new QueryClient({ defaultOptions: { diff --git a/examples/react/offline-transactions/src/utils/todos.ts b/examples/react/offline-transactions/src/utils/todos.ts index 935a7f565..419683556 100644 --- a/examples/react/offline-transactions/src/utils/todos.ts +++ b/examples/react/offline-transactions/src/utils/todos.ts @@ -28,7 +28,7 @@ export const todoService = { getAll(): Array { return Array.from(todosStore.values()).sort( (a, b) => - new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() + new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), ) }, diff --git a/examples/react/offline-transactions/tailwind.config.mjs b/examples/react/offline-transactions/tailwind.config.mjs index 6765f75b2..e49f4eb77 100644 --- a/examples/react/offline-transactions/tailwind.config.mjs +++ b/examples/react/offline-transactions/tailwind.config.mjs @@ -1,4 +1,4 @@ /** @type {import('tailwindcss').Config} */ export default { - content: ["./src/**/*.{js,jsx,ts,tsx}"], + content: ['./src/**/*.{js,jsx,ts,tsx}'], } diff --git a/examples/react/offline-transactions/vite.config.ts b/examples/react/offline-transactions/vite.config.ts index f730c1bf5..7c7d0e77c 100644 --- a/examples/react/offline-transactions/vite.config.ts +++ b/examples/react/offline-transactions/vite.config.ts @@ -1,9 +1,9 @@ -import path from "node:path" -import { tanstackStart } from "@tanstack/react-start/plugin/vite" -import { defineConfig } from "vite" -import tsConfigPaths from "vite-tsconfig-paths" -import viteReact from "@vitejs/plugin-react" -import chokidar from "chokidar" +import path from 'node:path' +import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import viteReact from '@vitejs/plugin-react' +import chokidar from 'chokidar' function watchWorkspacePackages() { return { @@ -27,7 +27,7 @@ function watchWorkspacePackages() { watcher.on(`ready`, () => { console.log( - `[watch-workspace] Initial scan complete. Watching for changes...` + `[watch-workspace] Initial scan complete. Watching for changes...`, ) const watchedPaths = watcher.getWatched() console.log(`[watch-workspace] Currently watching:`, watchedPaths) diff --git a/examples/react/paced-mutations-demo/src/App.tsx b/examples/react/paced-mutations-demo/src/App.tsx index 57f1ad33c..26781446c 100644 --- a/examples/react/paced-mutations-demo/src/App.tsx +++ b/examples/react/paced-mutations-demo/src/App.tsx @@ -1,13 +1,13 @@ -import { useEffect, useMemo, useState } from "react" -import mitt from "mitt" +import { useEffect, useMemo, useState } from 'react' +import mitt from 'mitt' import { createCollection, debounceStrategy, queueStrategy, throttleStrategy, usePacedMutations, -} from "@tanstack/react-db" -import type { PendingMutation, Transaction } from "@tanstack/react-db" +} from '@tanstack/react-db' +import type { PendingMutation, Transaction } from '@tanstack/react-db' interface Item { id: number @@ -86,7 +86,7 @@ export function App() { const [trailing, setTrailing] = useState(true) const [transactions, setTransactions] = useState>( - [] + [], ) const [optimisticState, setOptimisticState] = useState(null) const [syncedState, setSyncedState] = useState(fakeServer.get(1)!) @@ -130,7 +130,7 @@ export function App() { return { ...t, state: `executing` as const, executingAt } } return t - }) + }), ) // Simulate network delay to fake server (random 100-600ms) @@ -200,7 +200,7 @@ export function App() { } } return t - }) + }), ) // Update optimistic state after completion setOptimisticState(itemCollection.get(1)) @@ -213,7 +213,7 @@ export function App() { return { ...t, state: `failed` as const, completedAt: Date.now() } } return t - }) + }), ) // Update optimistic state after failure setOptimisticState(itemCollection.get(1)) diff --git a/examples/react/paced-mutations-demo/src/index.css b/examples/react/paced-mutations-demo/src/index.css index d863dbaf4..e315d3e3d 100644 --- a/examples/react/paced-mutations-demo/src/index.css +++ b/examples/react/paced-mutations-demo/src/index.css @@ -6,8 +6,8 @@ body { font-family: - -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", - "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; + -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', + 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; background: #f5f5f5; @@ -16,7 +16,7 @@ body { code { font-family: - source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace; + source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; background: #f0f0f0; padding: 2px 6px; border-radius: 3px; @@ -74,7 +74,7 @@ h1 { } .control-group select, -.control-group input[type="number"] { +.control-group input[type='number'] { width: 100%; padding: 8px; border: 1px solid #ddd; @@ -89,7 +89,7 @@ h1 { margin-bottom: 8px; } -.checkbox-group input[type="checkbox"] { +.checkbox-group input[type='checkbox'] { width: 16px; height: 16px; } diff --git a/examples/react/paced-mutations-demo/src/main.tsx b/examples/react/paced-mutations-demo/src/main.tsx index 8def6fa63..950701bda 100644 --- a/examples/react/paced-mutations-demo/src/main.tsx +++ b/examples/react/paced-mutations-demo/src/main.tsx @@ -1,10 +1,10 @@ -import React from "react" -import ReactDOM from "react-dom/client" -import { App } from "./App" -import "./index.css" +import React from 'react' +import ReactDOM from 'react-dom/client' +import { App } from './App' +import './index.css' ReactDOM.createRoot(document.getElementById(`root`)!).render( - + , ) diff --git a/examples/react/paced-mutations-demo/vite.config.ts b/examples/react/paced-mutations-demo/vite.config.ts index ea1889ae7..9ffcc6757 100644 --- a/examples/react/paced-mutations-demo/vite.config.ts +++ b/examples/react/paced-mutations-demo/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from "vite" -import react from "@vitejs/plugin-react" +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], diff --git a/examples/react/projects/README.md b/examples/react/projects/README.md index 3bfe71853..7a122431d 100644 --- a/examples/react/projects/README.md +++ b/examples/react/projects/README.md @@ -78,7 +78,7 @@ Now that you have two routes you can use a `Link` component to navigate between To use SPA (Single Page Application) navigation you will need to import the `Link` component from `@tanstack/react-router`. ```tsx -import { Link } from "@tanstack/react-router" +import { Link } from '@tanstack/react-router' ``` Then anywhere in your JSX you can use it like so: @@ -98,10 +98,10 @@ In the File Based Routing setup the layout is located in `src/routes/__root.tsx` Here is an example layout that includes a header: ```tsx -import { Outlet, createRootRoute } from "@tanstack/react-router" -import { TanStackRouterDevtools } from "@tanstack/react-router-devtools" +import { Outlet, createRootRoute } from '@tanstack/react-router' +import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' -import { Link } from "@tanstack/react-router" +import { Link } from '@tanstack/react-router' export const Route = createRootRoute({ component: () => ( @@ -132,9 +132,9 @@ For example: ```tsx const peopleRoute = createRoute({ getParentRoute: () => rootRoute, - path: "/people", + path: '/people', loader: async () => { - const response = await fetch("https://swapi.dev/api/people") + const response = await fetch('https://swapi.dev/api/people') return response.json() as Promise<{ results: { name: string @@ -180,16 +180,16 @@ Built on a TypeScript implementation of differential dataflow, TanStack DB provi This example uses Query Collections for server-state synchronization with tRPC: ```tsx -import { createCollection } from "@tanstack/react-db" -import { queryCollectionOptions } from "@tanstack/query-db-collection" -import { QueryClient } from "@tanstack/query-core" +import { createCollection } from '@tanstack/react-db' +import { queryCollectionOptions } from '@tanstack/query-db-collection' +import { QueryClient } from '@tanstack/query-core' const queryClient = new QueryClient() export const todoCollection = createCollection( queryCollectionOptions({ - id: "todos", - queryKey: ["todos"], + id: 'todos', + queryKey: ['todos'], queryFn: async () => { const todos = await trpc.todos.getAll.query() return todos.map((todo) => ({ @@ -224,7 +224,7 @@ const AddTodo = () => { onClick={() => todoCollection.insert({ id: crypto.randomUUID(), - text: "šŸ”„ Make app faster", + text: 'šŸ”„ Make app faster', completed: false, }) } @@ -238,7 +238,7 @@ const AddTodo = () => { Use live queries to read data reactively across collections: ```tsx -import { useLiveQuery } from "@tanstack/react-db" +import { useLiveQuery } from '@tanstack/react-db' const Todos = () => { // Read data using live queries with cross-collection joins @@ -246,12 +246,12 @@ const Todos = () => { query .from({ t: todoCollection }) .join({ - type: "inner", + type: 'inner', from: { l: listCollection }, on: [`@l.id`, `=`, `@t.list_id`], }) - .where("@l.active", "=", true) - .select("@t.id", "@t.text", "@t.status", "@l.name") + .where('@l.active', '=', true) + .select('@t.id', '@t.text', '@t.status', '@l.name') ) return ( diff --git a/examples/react/projects/docker-compose.yaml b/examples/react/projects/docker-compose.yaml index 6da89ad48..42a8aca0d 100644 --- a/examples/react/projects/docker-compose.yaml +++ b/examples/react/projects/docker-compose.yaml @@ -1,5 +1,5 @@ -version: "3.3" -name: "tanstack-start-db-projects" +version: '3.3' +name: 'tanstack-start-db-projects' services: postgres: diff --git a/examples/react/projects/drizzle.config.ts b/examples/react/projects/drizzle.config.ts index 6a6f388fd..30ae9a282 100644 --- a/examples/react/projects/drizzle.config.ts +++ b/examples/react/projects/drizzle.config.ts @@ -1,5 +1,5 @@ -import "dotenv/config" -import { defineConfig } from "drizzle-kit" +import 'dotenv/config' +import { defineConfig } from 'drizzle-kit' export default defineConfig({ out: `./src/db/out`, diff --git a/examples/react/projects/eslint.config.mjs b/examples/react/projects/eslint.config.mjs index e3c217b91..29a94ce29 100644 --- a/examples/react/projects/eslint.config.mjs +++ b/examples/react/projects/eslint.config.mjs @@ -1,19 +1,19 @@ -import js from "@eslint/js" -import tsParser from "@typescript-eslint/parser" -import tsPlugin from "@typescript-eslint/eslint-plugin" -import reactPlugin from "eslint-plugin-react" -import prettierPlugin from "eslint-plugin-prettier" -import prettierConfig from "eslint-config-prettier" -import globals from "globals" -import { includeIgnoreFile } from "@eslint/compat" -import { fileURLToPath } from "url" +import js from '@eslint/js' +import tsParser from '@typescript-eslint/parser' +import tsPlugin from '@typescript-eslint/eslint-plugin' +import reactPlugin from 'eslint-plugin-react' +import prettierPlugin from 'eslint-plugin-prettier' +import prettierConfig from 'eslint-config-prettier' +import globals from 'globals' +import { includeIgnoreFile } from '@eslint/compat' +import { fileURLToPath } from 'url' -const gitignorePath = fileURLToPath(new URL(".gitignore", import.meta.url)) +const gitignorePath = fileURLToPath(new URL('.gitignore', import.meta.url)) export default [ - includeIgnoreFile(gitignorePath, "Imported .gitignore patterns"), + includeIgnoreFile(gitignorePath, 'Imported .gitignore patterns'), { - files: ["src/**/*.{js,jsx,ts,tsx,mjs}"], + files: ['src/**/*.{js,jsx,ts,tsx,mjs}'], languageOptions: { ecmaVersion: 2022, sourceType: `module`, @@ -35,7 +35,7 @@ export default [ }, }, plugins: { - "@typescript-eslint": tsPlugin, + '@typescript-eslint': tsPlugin, react: reactPlugin, prettier: prettierPlugin, }, @@ -44,12 +44,12 @@ export default [ ...tsPlugin.configs.recommended.rules, ...reactPlugin.configs.recommended.rules, ...prettierConfig.rules, - "prettier/prettier": `error`, - "react/react-in-jsx-scope": `off`, - "react/jsx-uses-react": `off`, - "no-undef": `off`, - "@typescript-eslint/no-undef": "off", - "@typescript-eslint/no-unused-vars": [ + 'prettier/prettier': `error`, + 'react/react-in-jsx-scope': `off`, + 'react/jsx-uses-react': `off`, + 'no-undef': `off`, + '@typescript-eslint/no-undef': 'off', + '@typescript-eslint/no-unused-vars': [ `error`, { argsIgnorePattern: `^_`, diff --git a/examples/react/projects/src/db/auth-schema.ts b/examples/react/projects/src/db/auth-schema.ts index c0ff607e2..ac78b4658 100644 --- a/examples/react/projects/src/db/auth-schema.ts +++ b/examples/react/projects/src/db/auth-schema.ts @@ -1,61 +1,61 @@ -import { pgTable, text, timestamp, boolean } from "drizzle-orm/pg-core" +import { pgTable, text, timestamp, boolean } from 'drizzle-orm/pg-core' -export const users = pgTable("users", { - id: text("id").primaryKey(), - name: text("name").notNull(), - email: text("email").notNull().unique(), - emailVerified: boolean("email_verified") +export const users = pgTable('users', { + id: text('id').primaryKey(), + name: text('name').notNull(), + email: text('email').notNull().unique(), + emailVerified: boolean('email_verified') .$defaultFn(() => false) .notNull(), - image: text("image"), - createdAt: timestamp("created_at") + image: text('image'), + createdAt: timestamp('created_at') .$defaultFn(() => /* @__PURE__ */ new Date()) .notNull(), - updatedAt: timestamp("updated_at") + updatedAt: timestamp('updated_at') .$defaultFn(() => /* @__PURE__ */ new Date()) .notNull(), }) -export const sessions = pgTable("sessions", { - id: text("id").primaryKey(), - expiresAt: timestamp("expires_at").notNull(), - token: text("token").notNull().unique(), - createdAt: timestamp("created_at").notNull(), - updatedAt: timestamp("updated_at").notNull(), - ipAddress: text("ip_address"), - userAgent: text("user_agent"), - userId: text("user_id") +export const sessions = pgTable('sessions', { + id: text('id').primaryKey(), + expiresAt: timestamp('expires_at').notNull(), + token: text('token').notNull().unique(), + createdAt: timestamp('created_at').notNull(), + updatedAt: timestamp('updated_at').notNull(), + ipAddress: text('ip_address'), + userAgent: text('user_agent'), + userId: text('user_id') .notNull() - .references(() => users.id, { onDelete: "cascade" }), + .references(() => users.id, { onDelete: 'cascade' }), }) -export const accounts = pgTable("accounts", { - id: text("id").primaryKey(), - accountId: text("account_id").notNull(), - providerId: text("provider_id").notNull(), - userId: text("user_id") +export const accounts = pgTable('accounts', { + id: text('id').primaryKey(), + accountId: text('account_id').notNull(), + providerId: text('provider_id').notNull(), + userId: text('user_id') .notNull() - .references(() => users.id, { onDelete: "cascade" }), - accessToken: text("access_token"), - refreshToken: text("refresh_token"), - idToken: text("id_token"), - accessTokenExpiresAt: timestamp("access_token_expires_at"), - refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), - scope: text("scope"), - password: text("password"), - createdAt: timestamp("created_at").notNull(), - updatedAt: timestamp("updated_at").notNull(), + .references(() => users.id, { onDelete: 'cascade' }), + accessToken: text('access_token'), + refreshToken: text('refresh_token'), + idToken: text('id_token'), + accessTokenExpiresAt: timestamp('access_token_expires_at'), + refreshTokenExpiresAt: timestamp('refresh_token_expires_at'), + scope: text('scope'), + password: text('password'), + createdAt: timestamp('created_at').notNull(), + updatedAt: timestamp('updated_at').notNull(), }) -export const verifications = pgTable("verifications", { - id: text("id").primaryKey(), - identifier: text("identifier").notNull(), - value: text("value").notNull(), - expiresAt: timestamp("expires_at").notNull(), - createdAt: timestamp("created_at").$defaultFn( +export const verifications = pgTable('verifications', { + id: text('id').primaryKey(), + identifier: text('identifier').notNull(), + value: text('value').notNull(), + expiresAt: timestamp('expires_at').notNull(), + createdAt: timestamp('created_at').$defaultFn( () => /* @__PURE__ */ new Date() ), - updatedAt: timestamp("updated_at").$defaultFn( + updatedAt: timestamp('updated_at').$defaultFn( () => /* @__PURE__ */ new Date() ), }) diff --git a/examples/react/projects/src/db/connection.ts b/examples/react/projects/src/db/connection.ts index 5a8ea8beb..2712baa58 100644 --- a/examples/react/projects/src/db/connection.ts +++ b/examples/react/projects/src/db/connection.ts @@ -1,4 +1,4 @@ -import "dotenv/config" -import { drizzle } from "drizzle-orm/node-postgres" +import 'dotenv/config' +import { drizzle } from 'drizzle-orm/node-postgres' export const db = drizzle(process.env.DATABASE_URL!, { casing: `snake_case` }) diff --git a/examples/react/projects/src/db/schema.ts b/examples/react/projects/src/db/schema.ts index 34df19e6a..cdd205c0a 100644 --- a/examples/react/projects/src/db/schema.ts +++ b/examples/react/projects/src/db/schema.ts @@ -5,11 +5,11 @@ import { timestamp, varchar, text, -} from "drizzle-orm/pg-core" -import { createSchemaFactory } from "drizzle-zod" -import { z } from "zod" -export * from "./auth-schema" -import { users } from "./auth-schema" +} from 'drizzle-orm/pg-core' +import { createSchemaFactory } from 'drizzle-zod' +import { z } from 'zod' +export * from './auth-schema' +import { users } from './auth-schema' const { createInsertSchema, createSelectSchema, createUpdateSchema } = createSchemaFactory({ zodInstance: z }) @@ -18,11 +18,11 @@ export const projectsTable = pgTable(`projects`, { id: integer().primaryKey().generatedAlwaysAsIdentity(), name: varchar({ length: 255 }).notNull(), description: text(), - shared_user_ids: text("shared_user_ids").array().notNull().default([]), + shared_user_ids: text('shared_user_ids').array().notNull().default([]), created_at: timestamp({ withTimezone: true }).notNull().defaultNow(), - owner_id: text("owner_id") + owner_id: text('owner_id') .notNull() - .references(() => users.id, { onDelete: "cascade" }), + .references(() => users.id, { onDelete: 'cascade' }), }) export const todosTable = pgTable(`todos`, { @@ -30,13 +30,13 @@ export const todosTable = pgTable(`todos`, { text: varchar({ length: 500 }).notNull(), completed: boolean().notNull().default(false), created_at: timestamp({ withTimezone: true }).notNull().defaultNow(), - user_id: text("user_id") + user_id: text('user_id') .notNull() - .references(() => users.id, { onDelete: "cascade" }), - project_id: integer("project_id") + .references(() => users.id, { onDelete: 'cascade' }), + project_id: integer('project_id') .notNull() - .references(() => projectsTable.id, { onDelete: "cascade" }), - user_ids: text("user_ids").array().notNull().default([]), + .references(() => projectsTable.id, { onDelete: 'cascade' }), + user_ids: text('user_ids').array().notNull().default([]), }) export const selectProjectSchema = createSelectSchema(projectsTable) diff --git a/examples/react/projects/src/lib/auth-client.ts b/examples/react/projects/src/lib/auth-client.ts index 8665c3b11..939114361 100644 --- a/examples/react/projects/src/lib/auth-client.ts +++ b/examples/react/projects/src/lib/auth-client.ts @@ -1,2 +1,2 @@ -import { createAuthClient } from "better-auth/react" +import { createAuthClient } from 'better-auth/react' export const authClient = createAuthClient() diff --git a/examples/react/projects/src/lib/auth.ts b/examples/react/projects/src/lib/auth.ts index f423c5fdc..22426df53 100644 --- a/examples/react/projects/src/lib/auth.ts +++ b/examples/react/projects/src/lib/auth.ts @@ -1,11 +1,11 @@ -import { betterAuth } from "better-auth" -import { drizzleAdapter } from "better-auth/adapters/drizzle" -import { db } from "@/db/connection" // your drizzle instance -import * as schema from "@/db/auth-schema" +import { betterAuth } from 'better-auth' +import { drizzleAdapter } from 'better-auth/adapters/drizzle' +import { db } from '@/db/connection' // your drizzle instance +import * as schema from '@/db/auth-schema' export const auth = betterAuth({ database: drizzleAdapter(db, { - provider: "pg", + provider: 'pg', usePlural: true, schema, // debugLogs: true, @@ -13,10 +13,10 @@ export const auth = betterAuth({ emailAndPassword: { enabled: true, // Disable signup in production, allow in dev - disableSignUp: process.env.NODE_ENV === "production", - minPasswordLength: process.env.NODE_ENV === "production" ? 8 : 1, + disableSignUp: process.env.NODE_ENV === 'production', + minPasswordLength: process.env.NODE_ENV === 'production' ? 8 : 1, }, trustedOrigins: [ - "http://localhost:5173", // Vite dev server + 'http://localhost:5173', // Vite dev server ], }) diff --git a/examples/react/projects/src/lib/collections.ts b/examples/react/projects/src/lib/collections.ts index 336466dbe..235969dd2 100644 --- a/examples/react/projects/src/lib/collections.ts +++ b/examples/react/projects/src/lib/collections.ts @@ -1,20 +1,20 @@ -import { createCollection } from "@tanstack/react-db" -import { queryCollectionOptions } from "@tanstack/query-db-collection" -import { QueryClient } from "@tanstack/query-core" +import { createCollection } from '@tanstack/react-db' +import { queryCollectionOptions } from '@tanstack/query-db-collection' +import { QueryClient } from '@tanstack/query-core' import { selectTodoSchema, selectProjectSchema, selectUsersSchema, -} from "@/db/schema" -import { trpc } from "@/lib/trpc-client" +} from '@/db/schema' +import { trpc } from '@/lib/trpc-client' // Create a query client for query collections const queryClient = new QueryClient() export const usersCollection = createCollection( queryCollectionOptions({ - id: "users", - queryKey: ["users"], + id: 'users', + queryKey: ['users'], // Poll for updates every 5 seconds refetchInterval: 5000, queryFn: async () => { @@ -32,8 +32,8 @@ export const usersCollection = createCollection( ) export const projectCollection = createCollection( queryCollectionOptions({ - id: "projects", - queryKey: ["projects"], + id: 'projects', + queryKey: ['projects'], // Poll for updates every 5 seconds refetchInterval: 5000, queryFn: async () => { @@ -78,8 +78,8 @@ export const projectCollection = createCollection( export const todoCollection = createCollection( queryCollectionOptions({ - id: "todos", - queryKey: ["todos"], + id: 'todos', + queryKey: ['todos'], // Poll for updates every 5 seconds refetchInterval: 5000, queryFn: async () => { diff --git a/examples/react/projects/src/lib/trpc-client.ts b/examples/react/projects/src/lib/trpc-client.ts index d03bf6922..11b29a321 100644 --- a/examples/react/projects/src/lib/trpc-client.ts +++ b/examples/react/projects/src/lib/trpc-client.ts @@ -1,13 +1,13 @@ -import { createTRPCProxyClient, httpBatchLink } from "@trpc/client" -import type { AppRouter } from "@/routes/api/trpc/$" +import { createTRPCProxyClient, httpBatchLink } from '@trpc/client' +import type { AppRouter } from '@/routes/api/trpc/$' export const trpc = createTRPCProxyClient({ links: [ httpBatchLink({ - url: "/api/trpc", + url: '/api/trpc', async headers() { return { - cookie: typeof document !== "undefined" ? document.cookie : "", + cookie: typeof document !== 'undefined' ? document.cookie : '', } }, }), diff --git a/examples/react/projects/src/lib/trpc.ts b/examples/react/projects/src/lib/trpc.ts index 8843140d1..98e498464 100644 --- a/examples/react/projects/src/lib/trpc.ts +++ b/examples/react/projects/src/lib/trpc.ts @@ -1,6 +1,6 @@ -import { initTRPC, TRPCError } from "@trpc/server" -import { auth } from "@/lib/auth" -import { db } from "@/db/connection" +import { initTRPC, TRPCError } from '@trpc/server' +import { auth } from '@/lib/auth' +import { db } from '@/db/connection' export type Context = { session: Awaited> @@ -15,7 +15,7 @@ export const middleware = t.middleware export const isAuthed = middleware(async ({ ctx, next }) => { if (!ctx.session?.user) { - throw new TRPCError({ code: "UNAUTHORIZED" }) + throw new TRPCError({ code: 'UNAUTHORIZED' }) } return next({ ctx: { diff --git a/examples/react/projects/src/lib/trpc/projects.ts b/examples/react/projects/src/lib/trpc/projects.ts index fd9de7132..dcf6e7a45 100644 --- a/examples/react/projects/src/lib/trpc/projects.ts +++ b/examples/react/projects/src/lib/trpc/projects.ts @@ -1,12 +1,12 @@ -import { router, authedProcedure } from "@/lib/trpc" -import { z } from "zod" -import { TRPCError } from "@trpc/server" -import { eq, and, sql } from "drizzle-orm" +import { router, authedProcedure } from '@/lib/trpc' +import { z } from 'zod' +import { TRPCError } from '@trpc/server' +import { eq, and, sql } from 'drizzle-orm' import { projectsTable, createProjectSchema, updateProjectSchema, -} from "@/db/schema" +} from '@/db/schema' export const projectsRouter = router({ getAll: authedProcedure.query(async ({ ctx }) => { @@ -24,8 +24,8 @@ export const projectsRouter = router({ .mutation(async ({ ctx, input }) => { if (input.owner_id !== ctx.session.user.id) { throw new TRPCError({ - code: "FORBIDDEN", - message: "You can only create projects you own", + code: 'FORBIDDEN', + message: 'You can only create projects you own', }) } @@ -58,9 +58,9 @@ export const projectsRouter = router({ if (!updatedItem) { throw new TRPCError({ - code: "NOT_FOUND", + code: 'NOT_FOUND', message: - "Project not found or you do not have permission to update it", + 'Project not found or you do not have permission to update it', }) } @@ -82,9 +82,9 @@ export const projectsRouter = router({ if (!deletedItem) { throw new TRPCError({ - code: "NOT_FOUND", + code: 'NOT_FOUND', message: - "Project not found or you do not have permission to delete it", + 'Project not found or you do not have permission to delete it', }) } diff --git a/examples/react/projects/src/lib/trpc/todos.ts b/examples/react/projects/src/lib/trpc/todos.ts index 127d36cca..d6825804e 100644 --- a/examples/react/projects/src/lib/trpc/todos.ts +++ b/examples/react/projects/src/lib/trpc/todos.ts @@ -1,8 +1,8 @@ -import { router, authedProcedure } from "@/lib/trpc" -import { z } from "zod" -import { TRPCError } from "@trpc/server" -import { eq, and, arrayContains } from "drizzle-orm" -import { todosTable, createTodoSchema, updateTodoSchema } from "@/db/schema" +import { router, authedProcedure } from '@/lib/trpc' +import { z } from 'zod' +import { TRPCError } from '@trpc/server' +import { eq, and, arrayContains } from 'drizzle-orm' +import { todosTable, createTodoSchema, updateTodoSchema } from '@/db/schema' export const todosRouter = router({ getAll: authedProcedure.query(async ({ ctx }) => { @@ -44,8 +44,8 @@ export const todosRouter = router({ if (!updatedItem) { throw new TRPCError({ - code: "NOT_FOUND", - message: "Todo not found or you do not have permission to update it", + code: 'NOT_FOUND', + message: 'Todo not found or you do not have permission to update it', }) } @@ -67,8 +67,8 @@ export const todosRouter = router({ if (!deletedItem) { throw new TRPCError({ - code: "NOT_FOUND", - message: "Todo not found or you do not have permission to delete it", + code: 'NOT_FOUND', + message: 'Todo not found or you do not have permission to delete it', }) } diff --git a/examples/react/projects/src/lib/trpc/users.ts b/examples/react/projects/src/lib/trpc/users.ts index 86f887753..13c730bdd 100644 --- a/examples/react/projects/src/lib/trpc/users.ts +++ b/examples/react/projects/src/lib/trpc/users.ts @@ -1,7 +1,7 @@ -import { router, authedProcedure } from "@/lib/trpc" -import { z } from "zod" -import { TRPCError } from "@trpc/server" -import { users } from "@/db/schema" +import { router, authedProcedure } from '@/lib/trpc' +import { z } from 'zod' +import { TRPCError } from '@trpc/server' +import { users } from '@/db/schema' export const usersRouter = router({ getAll: authedProcedure.query(async ({ ctx }) => { @@ -11,7 +11,7 @@ export const usersRouter = router({ create: authedProcedure.input(z.any()).mutation(async () => { throw new TRPCError({ - code: "FORBIDDEN", + code: 'FORBIDDEN', message: "Can't create new users through API", }) }), @@ -20,7 +20,7 @@ export const usersRouter = router({ .input(z.object({ id: z.string(), data: z.any() })) .mutation(async () => { throw new TRPCError({ - code: "FORBIDDEN", + code: 'FORBIDDEN', message: "Can't edit users through API", }) }), @@ -29,7 +29,7 @@ export const usersRouter = router({ .input(z.object({ id: z.string() })) .mutation(async () => { throw new TRPCError({ - code: "FORBIDDEN", + code: 'FORBIDDEN', message: "Can't delete users through API", }) }), diff --git a/examples/react/projects/src/router.tsx b/examples/react/projects/src/router.tsx index e025c0f7f..50504c678 100644 --- a/examples/react/projects/src/router.tsx +++ b/examples/react/projects/src/router.tsx @@ -1,9 +1,9 @@ -import { createRouter as createTanstackRouter } from "@tanstack/react-router" +import { createRouter as createTanstackRouter } from '@tanstack/react-router' // Import the generated route tree -import { routeTree } from "./routeTree.gen" +import { routeTree } from './routeTree.gen' -import "./styles.css" +import './styles.css' // Create a new router instance export function getRouter() { diff --git a/examples/react/projects/src/routes/__root.tsx b/examples/react/projects/src/routes/__root.tsx index bb4aa1c89..477a34019 100644 --- a/examples/react/projects/src/routes/__root.tsx +++ b/examples/react/projects/src/routes/__root.tsx @@ -1,13 +1,13 @@ -import * as React from "react" +import * as React from 'react' import { HeadContent, Outlet, Scripts, createRootRoute, -} from "@tanstack/react-router" -import { TanStackRouterDevtools } from "@tanstack/react-router-devtools" +} from '@tanstack/react-router' +import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' -import appCss from "../styles.css?url" +import appCss from '../styles.css?url' export const Route = createRootRoute({ head: () => ({ diff --git a/examples/react/projects/src/routes/_authenticated.tsx b/examples/react/projects/src/routes/_authenticated.tsx index 749668ea4..c119ed40c 100644 --- a/examples/react/projects/src/routes/_authenticated.tsx +++ b/examples/react/projects/src/routes/_authenticated.tsx @@ -1,13 +1,13 @@ -import { useEffect, useState } from "react" +import { useEffect, useState } from 'react' import { Link, Outlet, createFileRoute, useNavigate, -} from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" -import { authClient } from "@/lib/auth-client" -import { projectCollection } from "@/lib/collections" +} from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' +import { authClient } from '@/lib/auth-client' +import { projectCollection } from '@/lib/collections' export const Route = createFileRoute(`/_authenticated`)({ component: AuthenticatedLayout, diff --git a/examples/react/projects/src/routes/_authenticated/index.tsx b/examples/react/projects/src/routes/_authenticated/index.tsx index bc3990cd2..a8f8cb9ab 100644 --- a/examples/react/projects/src/routes/_authenticated/index.tsx +++ b/examples/react/projects/src/routes/_authenticated/index.tsx @@ -1,8 +1,8 @@ -import { useEffect } from "react" -import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" -import { projectCollection, todoCollection } from "@/lib/collections" -import { authClient } from "@/lib/auth-client" +import { useEffect } from 'react' +import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' +import { projectCollection, todoCollection } from '@/lib/collections' +import { authClient } from '@/lib/auth-client' export const Route = createFileRoute(`/_authenticated/`)({ component: IndexRedirect, diff --git a/examples/react/projects/src/routes/_authenticated/project/$projectId.tsx b/examples/react/projects/src/routes/_authenticated/project/$projectId.tsx index 3a648964f..7c3084f23 100644 --- a/examples/react/projects/src/routes/_authenticated/project/$projectId.tsx +++ b/examples/react/projects/src/routes/_authenticated/project/$projectId.tsx @@ -1,13 +1,13 @@ -import { createFileRoute } from "@tanstack/react-router" -import { eq, useLiveQuery } from "@tanstack/react-db" -import { useState } from "react" -import type { Todo } from "@/db/schema" -import { authClient } from "@/lib/auth-client" +import { createFileRoute } from '@tanstack/react-router' +import { eq, useLiveQuery } from '@tanstack/react-db' +import { useState } from 'react' +import type { Todo } from '@/db/schema' +import { authClient } from '@/lib/auth-client' import { projectCollection, todoCollection, usersCollection, -} from "@/lib/collections" +} from '@/lib/collections' export const Route = createFileRoute(`/_authenticated/project/$projectId`)({ component: ProjectPage, diff --git a/examples/react/projects/src/routes/api/auth.ts b/examples/react/projects/src/routes/api/auth.ts index c8d288f8b..4b3b9bfbf 100644 --- a/examples/react/projects/src/routes/api/auth.ts +++ b/examples/react/projects/src/routes/api/auth.ts @@ -1,5 +1,5 @@ -import { createFileRoute } from "@tanstack/react-router" -import { auth } from "@/lib/auth" +import { createFileRoute } from '@tanstack/react-router' +import { auth } from '@/lib/auth' const serve = ({ request }: { request: Request }) => { return auth.handler(request) diff --git a/examples/react/projects/src/routes/api/trpc/$.ts b/examples/react/projects/src/routes/api/trpc/$.ts index e7438e56b..eb6071a4a 100644 --- a/examples/react/projects/src/routes/api/trpc/$.ts +++ b/examples/react/projects/src/routes/api/trpc/$.ts @@ -1,11 +1,11 @@ -import { createFileRoute } from "@tanstack/react-router" -import { fetchRequestHandler } from "@trpc/server/adapters/fetch" -import { router } from "@/lib/trpc" -import { projectsRouter } from "@/lib/trpc/projects" -import { todosRouter } from "@/lib/trpc/todos" -import { usersRouter } from "@/lib/trpc/users" -import { db } from "@/db/connection" -import { auth } from "@/lib/auth" +import { createFileRoute } from '@tanstack/react-router' +import { fetchRequestHandler } from '@trpc/server/adapters/fetch' +import { router } from '@/lib/trpc' +import { projectsRouter } from '@/lib/trpc/projects' +import { todosRouter } from '@/lib/trpc/todos' +import { usersRouter } from '@/lib/trpc/users' +import { db } from '@/db/connection' +import { auth } from '@/lib/auth' export const appRouter = router({ projects: projectsRouter, diff --git a/examples/react/projects/src/routes/login.tsx b/examples/react/projects/src/routes/login.tsx index 09512463c..1f2a039c1 100644 --- a/examples/react/projects/src/routes/login.tsx +++ b/examples/react/projects/src/routes/login.tsx @@ -1,7 +1,7 @@ -import { useState } from "react" -import { createFileRoute } from "@tanstack/react-router" -import type { FormEvent } from "react" -import { authClient } from "@/lib/auth-client" +import { useState } from 'react' +import { createFileRoute } from '@tanstack/react-router' +import type { FormEvent } from 'react' +import { authClient } from '@/lib/auth-client' export const Route = createFileRoute(`/login`)({ component: Layout, diff --git a/examples/react/projects/src/start.tsx b/examples/react/projects/src/start.tsx index de7b170ed..9e8694bab 100644 --- a/examples/react/projects/src/start.tsx +++ b/examples/react/projects/src/start.tsx @@ -1,4 +1,4 @@ -import { createStart } from "@tanstack/react-start" +import { createStart } from '@tanstack/react-start' export const startInstance = createStart(() => { return { diff --git a/examples/react/projects/src/styles.css b/examples/react/projects/src/styles.css index 80cb92ada..06f1bca4b 100644 --- a/examples/react/projects/src/styles.css +++ b/examples/react/projects/src/styles.css @@ -1,15 +1,15 @@ -@import "tailwindcss"; +@import 'tailwindcss'; body { @apply m-0; font-family: - -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", - "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; + -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', + 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } code { font-family: - source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace; + source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } diff --git a/examples/react/projects/vite.config.ts b/examples/react/projects/vite.config.ts index 6708900ed..7307fb0e8 100644 --- a/examples/react/projects/vite.config.ts +++ b/examples/react/projects/vite.config.ts @@ -1,8 +1,8 @@ -import { defineConfig } from "vite" -import { tanstackStart } from "@tanstack/react-start/plugin/vite" -import viteTsConfigPaths from "vite-tsconfig-paths" -import tailwindcss from "@tailwindcss/vite" -import react from "@vitejs/plugin-react" +import { defineConfig } from 'vite' +import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteTsConfigPaths from 'vite-tsconfig-paths' +import tailwindcss from '@tailwindcss/vite' +import react from '@vitejs/plugin-react' const config = defineConfig({ plugins: [ diff --git a/examples/react/todo/docker-compose.yml b/examples/react/todo/docker-compose.yml index 9b6ddcffe..cb03bb1b3 100644 --- a/examples/react/todo/docker-compose.yml +++ b/examples/react/todo/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: '3.8' services: postgres: image: postgres:17-alpine @@ -7,7 +7,7 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - - "54322:5432" + - '54322:5432' volumes: - ./postgres.conf:/etc/postgresql/postgresql.conf:ro tmpfs: @@ -18,7 +18,7 @@ services: - -c - config_file=/etc/postgresql/postgresql.conf healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres"] + test: ['CMD-SHELL', 'pg_isready -U postgres'] interval: 5s timeout: 5s retries: 5 @@ -37,11 +37,11 @@ services: trailbase: image: trailbase/trailbase:latest ports: - - "${PORT:-4000}:4000" + - '${PORT:-4000}:4000' restart: unless-stopped volumes: - ./traildepot:/app/traildepot - command: "/app/trail --data-dir /app/traildepot run --address 0.0.0.0:4000 --dev" + command: '/app/trail --data-dir /app/traildepot run --address 0.0.0.0:4000 --dev' volumes: postgres_data: diff --git a/examples/react/todo/drizzle.config.ts b/examples/react/todo/drizzle.config.ts index 550633431..486be88c9 100644 --- a/examples/react/todo/drizzle.config.ts +++ b/examples/react/todo/drizzle.config.ts @@ -1,4 +1,4 @@ -import type { Config } from "drizzle-kit" +import type { Config } from 'drizzle-kit' export default { schema: `./src/db/schema.ts`, diff --git a/examples/react/todo/scripts/migrate.ts b/examples/react/todo/scripts/migrate.ts index ee0089f38..d58ebc44e 100644 --- a/examples/react/todo/scripts/migrate.ts +++ b/examples/react/todo/scripts/migrate.ts @@ -1,7 +1,7 @@ -import { drizzle } from "drizzle-orm/node-postgres" -import { migrate } from "drizzle-orm/node-postgres/migrator" -import pkg from "pg" -import * as dotenv from "dotenv" +import { drizzle } from 'drizzle-orm/node-postgres' +import { migrate } from 'drizzle-orm/node-postgres/migrator' +import pkg from 'pg' +import * as dotenv from 'dotenv' dotenv.config() diff --git a/examples/react/todo/src/api/server.ts b/examples/react/todo/src/api/server.ts index 4aa55431d..948d2442e 100644 --- a/examples/react/todo/src/api/server.ts +++ b/examples/react/todo/src/api/server.ts @@ -1,14 +1,14 @@ -import express from "express" -import cors from "cors" -import { sql } from "../db/postgres" +import express from 'express' +import cors from 'cors' +import { sql } from '../db/postgres' import { validateInsertConfig, validateInsertTodo, validateUpdateConfig, validateUpdateTodo, -} from "../db/validation" -import type { Express } from "express" -import type { Txid } from "@tanstack/electric-db-collection" +} from '../db/validation' +import type { Express } from 'express' +import type { Txid } from '@tanstack/electric-db-collection' // Create Express app const app: Express = express() diff --git a/examples/react/todo/src/components/NotFound.tsx b/examples/react/todo/src/components/NotFound.tsx index 2e892fafd..60caed4d7 100644 --- a/examples/react/todo/src/components/NotFound.tsx +++ b/examples/react/todo/src/components/NotFound.tsx @@ -1,4 +1,4 @@ -import { Link } from "@tanstack/react-router" +import { Link } from '@tanstack/react-router' export function NotFound() { return ( diff --git a/examples/react/todo/src/components/TodoApp.tsx b/examples/react/todo/src/components/TodoApp.tsx index 0fbcb65ed..9a0225436 100644 --- a/examples/react/todo/src/components/TodoApp.tsx +++ b/examples/react/todo/src/components/TodoApp.tsx @@ -1,11 +1,11 @@ -import React, { useState } from "react" -import { Link } from "@tanstack/react-router" -import { debounceStrategy, usePacedMutations } from "@tanstack/react-db" -import type { FormEvent } from "react" -import type { Collection, Transaction } from "@tanstack/react-db" +import React, { useState } from 'react' +import { Link } from '@tanstack/react-router' +import { debounceStrategy, usePacedMutations } from '@tanstack/react-db' +import type { FormEvent } from 'react' +import type { Collection, Transaction } from '@tanstack/react-db' -import type { SelectConfig, SelectTodo } from "@/db/validation" -import { getComplementaryColor } from "@/lib/color" +import type { SelectConfig, SelectTodo } from '@/db/validation' +import { getComplementaryColor } from '@/lib/color' interface TodoAppProps { todos: Array @@ -165,8 +165,8 @@ export function TodoApp({ todosToToggle.map((todo) => todo.id), (drafts) => drafts.forEach( - (draft) => (draft.completed = !draft.completed) - ) + (draft) => (draft.completed = !draft.completed), + ), ) }} > diff --git a/examples/react/todo/src/db/index.ts b/examples/react/todo/src/db/index.ts index 5a856e693..fbd0af99d 100644 --- a/examples/react/todo/src/db/index.ts +++ b/examples/react/todo/src/db/index.ts @@ -1,6 +1,6 @@ -import { drizzle } from "drizzle-orm/node-postgres" -import { Pool } from "pg" -import * as schema from "./schema" +import { drizzle } from 'drizzle-orm/node-postgres' +import { Pool } from 'pg' +import * as schema from './schema' // Create a PostgreSQL pool const pool = new Pool({ diff --git a/examples/react/todo/src/db/postgres.ts b/examples/react/todo/src/db/postgres.ts index 674348433..9a0c0437c 100644 --- a/examples/react/todo/src/db/postgres.ts +++ b/examples/react/todo/src/db/postgres.ts @@ -1,4 +1,4 @@ -import postgres from "postgres" +import postgres from 'postgres' // Create a postgres instance export const sql = postgres({ diff --git a/examples/react/todo/src/db/schema.ts b/examples/react/todo/src/db/schema.ts index 4bf9e0d0a..bed8f98a8 100644 --- a/examples/react/todo/src/db/schema.ts +++ b/examples/react/todo/src/db/schema.ts @@ -1,4 +1,4 @@ -import { boolean, pgTable, serial, text, timestamp } from "drizzle-orm/pg-core" +import { boolean, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core' export const todos = pgTable(`todos`, { id: serial(`id`).primaryKey(), diff --git a/examples/react/todo/src/db/validation.ts b/examples/react/todo/src/db/validation.ts index 404afd0d4..2fa8408af 100644 --- a/examples/react/todo/src/db/validation.ts +++ b/examples/react/todo/src/db/validation.ts @@ -1,6 +1,6 @@ -import { createInsertSchema, createSelectSchema } from "drizzle-zod" -import { config, todos } from "./schema" -import type { z } from "zod" +import { createInsertSchema, createSelectSchema } from 'drizzle-zod' +import { config, todos } from './schema' +import type { z } from 'zod' // Auto-generated schemas from Drizzle schema (omit auto-generated fields) export const insertTodoSchema = createInsertSchema(todos).omit({ diff --git a/examples/react/todo/src/index.css b/examples/react/todo/src/index.css index 5211a0414..6dafed23c 100644 --- a/examples/react/todo/src/index.css +++ b/examples/react/todo/src/index.css @@ -1,4 +1,4 @@ -@import "tailwindcss"; +@import 'tailwindcss'; html, body { @@ -21,7 +21,7 @@ button { body { font: - 14px "Helvetica Neue", + 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; diff --git a/examples/react/todo/src/lib/api.ts b/examples/react/todo/src/lib/api.ts index c6e070b31..e066cdbe6 100644 --- a/examples/react/todo/src/lib/api.ts +++ b/examples/react/todo/src/lib/api.ts @@ -1,4 +1,4 @@ -import type { SelectConfig, SelectTodo } from "../db/validation" +import type { SelectConfig, SelectTodo } from '../db/validation' // API helper for todos and config const API_BASE_URL = `/api` @@ -19,11 +19,11 @@ export const api = { return response.json() }, create: async ( - todo: Partial + todo: Partial, ): Promise<{ todo: SelectTodo; txid: number }> => { const response = await fetch(`${API_BASE_URL}/todos`, { method: `POST`, - headers: { "Content-Type": `application/json` }, + headers: { 'Content-Type': `application/json` }, body: JSON.stringify(todo), }) if (!response.ok) @@ -32,11 +32,11 @@ export const api = { }, update: async ( id: unknown, - changes: Partial + changes: Partial, ): Promise<{ todo: SelectTodo; txid: number }> => { const response = await fetch(`${API_BASE_URL}/todos/${id}`, { method: `PUT`, - headers: { "Content-Type": `application/json` }, + headers: { 'Content-Type': `application/json` }, body: JSON.stringify(changes), }) if (!response.ok) @@ -44,7 +44,7 @@ export const api = { return response.json() }, delete: async ( - id: unknown + id: unknown, ): Promise<{ success: boolean; txid: number }> => { const response = await fetch(`${API_BASE_URL}/todos/${id}`, { method: `DELETE`, @@ -70,11 +70,11 @@ export const api = { return response.json() }, create: async ( - config: Partial + config: Partial, ): Promise<{ config: SelectConfig; txid: number }> => { const response = await fetch(`${API_BASE_URL}/config`, { method: `POST`, - headers: { "Content-Type": `application/json` }, + headers: { 'Content-Type': `application/json` }, body: JSON.stringify(config), }) if (!response.ok) @@ -83,11 +83,11 @@ export const api = { }, update: async ( id: number, - changes: Partial + changes: Partial, ): Promise<{ config: SelectConfig; txid: number }> => { const response = await fetch(`${API_BASE_URL}/config/${id}`, { method: `PUT`, - headers: { "Content-Type": `application/json` }, + headers: { 'Content-Type': `application/json` }, body: JSON.stringify(changes), }) if (!response.ok) diff --git a/examples/react/todo/src/lib/collections.ts b/examples/react/todo/src/lib/collections.ts index 5e41bac92..689372b80 100644 --- a/examples/react/todo/src/lib/collections.ts +++ b/examples/react/todo/src/lib/collections.ts @@ -1,12 +1,12 @@ -import { createCollection } from "@tanstack/react-db" -import { electricCollectionOptions } from "@tanstack/electric-db-collection" -import { queryCollectionOptions } from "@tanstack/query-db-collection" -import { trailBaseCollectionOptions } from "@tanstack/trailbase-db-collection" -import { QueryClient } from "@tanstack/query-core" -import { initClient } from "trailbase" -import { selectConfigSchema, selectTodoSchema } from "../db/validation" -import { api } from "./api" -import type { SelectConfig, SelectTodo } from "../db/validation" +import { createCollection } from '@tanstack/react-db' +import { electricCollectionOptions } from '@tanstack/electric-db-collection' +import { queryCollectionOptions } from '@tanstack/query-db-collection' +import { trailBaseCollectionOptions } from '@tanstack/trailbase-db-collection' +import { QueryClient } from '@tanstack/query-core' +import { initClient } from 'trailbase' +import { selectConfigSchema, selectTodoSchema } from '../db/validation' +import { api } from './api' +import type { SelectConfig, SelectTodo } from '../db/validation' // Create a query client for query collections const queryClient = new QueryClient() @@ -48,7 +48,7 @@ export const electricTodoCollection = createCollection( } const response = await api.todos.update(original.id, changes) return response.txid - }) + }), ) return { txid: txids } }, @@ -61,11 +61,11 @@ export const electricTodoCollection = createCollection( } const response = await api.todos.delete(original.id) return response.txid - }) + }), ) return { txid: txids } }, - }) + }), ) // Query Todo Collection @@ -102,7 +102,7 @@ export const queryTodoCollection = createCollection( throw new Error(`Original todo not found for update`) } return await api.todos.update(original.id, changes) - }) + }), ) }, onDelete: async ({ transaction }) => { @@ -113,10 +113,10 @@ export const queryTodoCollection = createCollection( throw new Error(`Original todo not found for delete`) } await api.todos.delete(original.id) - }) + }), ) }, - }) + }), ) type Todo = { @@ -143,7 +143,7 @@ export const trailBaseTodoCollection = createCollection( created_at: (date) => Math.floor(date.valueOf() / 1000), updated_at: (date) => Math.floor(date.valueOf() / 1000), }, - }) + }), ) // Electric Config Collection @@ -175,11 +175,11 @@ export const electricConfigCollection = createCollection( } const response = await api.config.update(original.id, changes) return response.txid - }) + }), ) return { txid: txids } }, - }) + }), ) // Query Config Collection @@ -213,11 +213,11 @@ export const queryConfigCollection = createCollection( } const response = await api.config.update(original.id, changes) return response.txid - }) + }), ) return { txid: txids } }, - }) + }), ) type Config = { @@ -244,5 +244,5 @@ export const trailBaseConfigCollection = createCollection( created_at: (date) => Math.floor(date.valueOf() / 1000), updated_at: (date) => Math.floor(date.valueOf() / 1000), }, - }) + }), ) diff --git a/examples/react/todo/src/main.tsx b/examples/react/todo/src/main.tsx index 0218796d3..5368d1602 100644 --- a/examples/react/todo/src/main.tsx +++ b/examples/react/todo/src/main.tsx @@ -1,13 +1,13 @@ -import { StrictMode } from "react" -import { createRoot } from "react-dom/client" -import { RouterProvider } from "@tanstack/react-router" -import { getRouter } from "./router" -import "./index.css" +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import { RouterProvider } from '@tanstack/react-router' +import { getRouter } from './router' +import './index.css' const router = getRouter() createRoot(document.getElementById(`root`)!).render( - + , ) diff --git a/examples/react/todo/src/router.tsx b/examples/react/todo/src/router.tsx index 75e151354..e4dfe3766 100644 --- a/examples/react/todo/src/router.tsx +++ b/examples/react/todo/src/router.tsx @@ -1,10 +1,10 @@ -import { createRouter as createTanstackRouter } from "@tanstack/react-router" +import { createRouter as createTanstackRouter } from '@tanstack/react-router' // Import the generated route tree -import { routeTree } from "./routeTree.gen" -import { NotFound } from "./components/NotFound" +import { routeTree } from './routeTree.gen' +import { NotFound } from './components/NotFound' -import "./styles.css" +import './styles.css' // Create a new router instance export function getRouter() { diff --git a/examples/react/todo/src/routes/__root.tsx b/examples/react/todo/src/routes/__root.tsx index 94dd0b516..e57101152 100644 --- a/examples/react/todo/src/routes/__root.tsx +++ b/examples/react/todo/src/routes/__root.tsx @@ -1,12 +1,12 @@ -import * as React from "react" +import * as React from 'react' import { HeadContent, Outlet, Scripts, createRootRoute, -} from "@tanstack/react-router" +} from '@tanstack/react-router' -import appCss from "../styles.css?url" +import appCss from '../styles.css?url' export const Route = createRootRoute({ head: () => ({ diff --git a/examples/react/todo/src/routes/api/config.$id.ts b/examples/react/todo/src/routes/api/config.$id.ts index 9acfec234..f60ef9a64 100644 --- a/examples/react/todo/src/routes/api/config.$id.ts +++ b/examples/react/todo/src/routes/api/config.$id.ts @@ -1,8 +1,8 @@ -import { createFileRoute } from "@tanstack/react-router" -import { json } from "@tanstack/react-start" -import { sql } from "../../db/postgres" -import { validateUpdateConfig } from "../../db/validation" -import type { Txid } from "@tanstack/electric-db-collection" +import { createFileRoute } from '@tanstack/react-router' +import { json } from '@tanstack/react-start' +import { sql } from '../../db/postgres' +import { validateUpdateConfig } from '../../db/validation' +import type { Txid } from '@tanstack/electric-db-collection' // Generate a transaction ID async function generateTxId(tx: any): Promise { @@ -36,7 +36,7 @@ export const Route = createFileRoute(`/api/config/$id`)({ error: `Failed to fetch config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -76,7 +76,7 @@ export const Route = createFileRoute(`/api/config/$id`)({ error: `Failed to update config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -111,7 +111,7 @@ export const Route = createFileRoute(`/api/config/$id`)({ error: `Failed to delete config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, diff --git a/examples/react/todo/src/routes/api/config.ts b/examples/react/todo/src/routes/api/config.ts index 2224720c2..c4ae48cc1 100644 --- a/examples/react/todo/src/routes/api/config.ts +++ b/examples/react/todo/src/routes/api/config.ts @@ -1,8 +1,8 @@ -import { createFileRoute } from "@tanstack/react-router" -import { json } from "@tanstack/react-start" -import { sql } from "../../db/postgres" -import { validateInsertConfig } from "../../db/validation" -import type { Txid } from "@tanstack/electric-db-collection" +import { createFileRoute } from '@tanstack/react-router' +import { json } from '@tanstack/react-start' +import { sql } from '../../db/postgres' +import { validateInsertConfig } from '../../db/validation' +import type { Txid } from '@tanstack/electric-db-collection' // Generate a transaction ID async function generateTxId(tx: any): Promise { @@ -30,7 +30,7 @@ export const Route = createFileRoute(`/api/config`)({ error: `Failed to fetch config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -59,7 +59,7 @@ export const Route = createFileRoute(`/api/config`)({ error: `Failed to create config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, diff --git a/examples/react/todo/src/routes/api/todos.$id.ts b/examples/react/todo/src/routes/api/todos.$id.ts index 12b4cf9e2..5f57126cd 100644 --- a/examples/react/todo/src/routes/api/todos.$id.ts +++ b/examples/react/todo/src/routes/api/todos.$id.ts @@ -1,8 +1,8 @@ -import { createFileRoute } from "@tanstack/react-router" -import { json } from "@tanstack/react-start" -import { sql } from "../../db/postgres" -import { validateUpdateTodo } from "../../db/validation" -import type { Txid } from "@tanstack/electric-db-collection" +import { createFileRoute } from '@tanstack/react-router' +import { json } from '@tanstack/react-start' +import { sql } from '../../db/postgres' +import { validateUpdateTodo } from '../../db/validation' +import type { Txid } from '@tanstack/electric-db-collection' // Generate a transaction ID async function generateTxId(tx: any): Promise { @@ -36,7 +36,7 @@ export const Route = createFileRoute(`/api/todos/$id`)({ error: `Failed to fetch todo`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -76,7 +76,7 @@ export const Route = createFileRoute(`/api/todos/$id`)({ error: `Failed to update todo`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -111,7 +111,7 @@ export const Route = createFileRoute(`/api/todos/$id`)({ error: `Failed to delete todo`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, diff --git a/examples/react/todo/src/routes/api/todos.ts b/examples/react/todo/src/routes/api/todos.ts index 72b45f3e8..22fe77953 100644 --- a/examples/react/todo/src/routes/api/todos.ts +++ b/examples/react/todo/src/routes/api/todos.ts @@ -1,8 +1,8 @@ -import { createFileRoute } from "@tanstack/react-router" -import { json } from "@tanstack/react-start" -import { sql } from "../../db/postgres" -import { validateInsertTodo } from "../../db/validation" -import type { Txid } from "@tanstack/electric-db-collection" +import { createFileRoute } from '@tanstack/react-router' +import { json } from '@tanstack/react-start' +import { sql } from '../../db/postgres' +import { validateInsertTodo } from '../../db/validation' +import type { Txid } from '@tanstack/electric-db-collection' // Generate a transaction ID async function generateTxId(tx: any): Promise { @@ -34,7 +34,7 @@ export const Route = createFileRoute(`/api/todos`)({ error: `Failed to fetch todos`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -62,7 +62,7 @@ export const Route = createFileRoute(`/api/todos`)({ error: `Failed to create todo`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, diff --git a/examples/react/todo/src/routes/electric.tsx b/examples/react/todo/src/routes/electric.tsx index 461af9ecb..61629b81f 100644 --- a/examples/react/todo/src/routes/electric.tsx +++ b/examples/react/todo/src/routes/electric.tsx @@ -1,13 +1,13 @@ -import * as React from "react" -import { createFileRoute } from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' import { electricConfigCollection, electricTodoCollection, -} from "../lib/collections" -import { TodoApp } from "../components/TodoApp" -import { api } from "../lib/api" -import type { Transaction } from "@tanstack/react-db" +} from '../lib/collections' +import { TodoApp } from '../components/TodoApp' +import { api } from '../lib/api' +import type { Transaction } from '@tanstack/react-db' export const Route = createFileRoute(`/electric`)({ component: ElectricPage, @@ -27,11 +27,11 @@ function ElectricPage() { const { data: todos } = useLiveQuery((q) => q .from({ todo: electricTodoCollection }) - .orderBy(({ todo }) => todo.created_at, `asc`) + .orderBy(({ todo }) => todo.created_at, `asc`), ) const { data: configData } = useLiveQuery((q) => - q.from({ config: electricConfigCollection }) + q.from({ config: electricConfigCollection }), ) // Electric collections use txid to track sync @@ -57,14 +57,14 @@ function ElectricPage() { } const response = await api.config.update( mutation.original.id, - mutation.changes + mutation.changes, ) txids.push(response.txid) } // Wait for all txids to sync back to the collection await Promise.all( - txids.map((txid) => electricConfigCollection.utils.awaitTxid(txid)) + txids.map((txid) => electricConfigCollection.utils.awaitTxid(txid)), ) } diff --git a/examples/react/todo/src/routes/index.tsx b/examples/react/todo/src/routes/index.tsx index 0986beb69..34e259689 100644 --- a/examples/react/todo/src/routes/index.tsx +++ b/examples/react/todo/src/routes/index.tsx @@ -1,5 +1,5 @@ -import * as React from "react" -import { Link, createFileRoute } from "@tanstack/react-router" +import * as React from 'react' +import { Link, createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute(`/`)({ component: HomePage, diff --git a/examples/react/todo/src/routes/query.tsx b/examples/react/todo/src/routes/query.tsx index f6a620296..62c0ad37d 100644 --- a/examples/react/todo/src/routes/query.tsx +++ b/examples/react/todo/src/routes/query.tsx @@ -1,10 +1,10 @@ -import * as React from "react" -import { createFileRoute } from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" -import { queryConfigCollection, queryTodoCollection } from "../lib/collections" -import { TodoApp } from "../components/TodoApp" -import { api } from "../lib/api" -import type { Transaction } from "@tanstack/react-db" +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' +import { queryConfigCollection, queryTodoCollection } from '../lib/collections' +import { TodoApp } from '../components/TodoApp' +import { api } from '../lib/api' +import type { Transaction } from '@tanstack/react-db' export const Route = createFileRoute(`/query`)({ component: QueryPage, @@ -24,11 +24,11 @@ function QueryPage() { const { data: todos } = useLiveQuery((q) => q .from({ todo: queryTodoCollection }) - .orderBy(({ todo }) => todo.created_at, `asc`) + .orderBy(({ todo }) => todo.created_at, `asc`), ) const { data: configData } = useLiveQuery((q) => - q.from({ config: queryConfigCollection }) + q.from({ config: queryConfigCollection }), ) // Query collections automatically refetch after handler completes @@ -42,7 +42,7 @@ function QueryPage() { await Promise.all( inserts.map(async (mutation) => { await api.config.create(mutation.modified) - }) + }), ) // Handle updates @@ -53,7 +53,7 @@ function QueryPage() { throw new Error(`Original config not found for update`) } await api.config.update(mutation.original.id, mutation.changes) - }) + }), ) // Trigger refetch to get confirmed server state diff --git a/examples/react/todo/src/routes/trailbase.tsx b/examples/react/todo/src/routes/trailbase.tsx index 4c4370eba..96e05e11a 100644 --- a/examples/react/todo/src/routes/trailbase.tsx +++ b/examples/react/todo/src/routes/trailbase.tsx @@ -1,11 +1,11 @@ -import * as React from "react" -import { createFileRoute } from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' import { trailBaseConfigCollection, trailBaseTodoCollection, -} from "../lib/collections" -import { TodoApp } from "../components/TodoApp" +} from '../lib/collections' +import { TodoApp } from '../components/TodoApp' export const Route = createFileRoute(`/trailbase`)({ component: TrailBasePage, @@ -25,11 +25,11 @@ function TrailBasePage() { const { data: todos } = useLiveQuery((q) => q .from({ todo: trailBaseTodoCollection }) - .orderBy(({ todo }) => todo.created_at, `asc`) + .orderBy(({ todo }) => todo.created_at, `asc`), ) const { data: configData } = useLiveQuery((q) => - q.from({ config: trailBaseConfigCollection }) + q.from({ config: trailBaseConfigCollection }), ) // Note: TrailBase collections use recordApi internally, which is not exposed diff --git a/examples/react/todo/src/server.ts b/examples/react/todo/src/server.ts index 1f8997f3e..130fbb5a9 100644 --- a/examples/react/todo/src/server.ts +++ b/examples/react/todo/src/server.ts @@ -1,4 +1,4 @@ -import handler from "@tanstack/react-start/server-entry" +import handler from '@tanstack/react-start/server-entry' export default { fetch(request: Request) { diff --git a/examples/react/todo/src/start.tsx b/examples/react/todo/src/start.tsx index de7b170ed..9e8694bab 100644 --- a/examples/react/todo/src/start.tsx +++ b/examples/react/todo/src/start.tsx @@ -1,4 +1,4 @@ -import { createStart } from "@tanstack/react-start" +import { createStart } from '@tanstack/react-start' export const startInstance = createStart(() => { return { diff --git a/examples/react/todo/src/styles.css b/examples/react/todo/src/styles.css index 80cb92ada..06f1bca4b 100644 --- a/examples/react/todo/src/styles.css +++ b/examples/react/todo/src/styles.css @@ -1,15 +1,15 @@ -@import "tailwindcss"; +@import 'tailwindcss'; body { @apply m-0; font-family: - -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", - "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; + -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', + 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } code { font-family: - source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace; + source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } diff --git a/examples/react/todo/vite.config.ts b/examples/react/todo/vite.config.ts index ab0b541fd..3bf6a06e3 100644 --- a/examples/react/todo/vite.config.ts +++ b/examples/react/todo/vite.config.ts @@ -1,8 +1,8 @@ -import { defineConfig } from "vite" -import react from "@vitejs/plugin-react" -import tailwindcss from "@tailwindcss/vite" -import { tanstackStart } from "@tanstack/react-start/plugin/vite" -import viteTsConfigPaths from "vite-tsconfig-paths" +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' +import tailwindcss from '@tailwindcss/vite' +import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteTsConfigPaths from 'vite-tsconfig-paths' // https://vitejs.dev/config/ export default defineConfig({ diff --git a/examples/solid/todo/docker-compose.yml b/examples/solid/todo/docker-compose.yml index 9b6ddcffe..cb03bb1b3 100644 --- a/examples/solid/todo/docker-compose.yml +++ b/examples/solid/todo/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: '3.8' services: postgres: image: postgres:17-alpine @@ -7,7 +7,7 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - - "54322:5432" + - '54322:5432' volumes: - ./postgres.conf:/etc/postgresql/postgresql.conf:ro tmpfs: @@ -18,7 +18,7 @@ services: - -c - config_file=/etc/postgresql/postgresql.conf healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres"] + test: ['CMD-SHELL', 'pg_isready -U postgres'] interval: 5s timeout: 5s retries: 5 @@ -37,11 +37,11 @@ services: trailbase: image: trailbase/trailbase:latest ports: - - "${PORT:-4000}:4000" + - '${PORT:-4000}:4000' restart: unless-stopped volumes: - ./traildepot:/app/traildepot - command: "/app/trail --data-dir /app/traildepot run --address 0.0.0.0:4000 --dev" + command: '/app/trail --data-dir /app/traildepot run --address 0.0.0.0:4000 --dev' volumes: postgres_data: diff --git a/examples/solid/todo/drizzle.config.ts b/examples/solid/todo/drizzle.config.ts index 550633431..486be88c9 100644 --- a/examples/solid/todo/drizzle.config.ts +++ b/examples/solid/todo/drizzle.config.ts @@ -1,4 +1,4 @@ -import type { Config } from "drizzle-kit" +import type { Config } from 'drizzle-kit' export default { schema: `./src/db/schema.ts`, diff --git a/examples/solid/todo/scripts/migrate.ts b/examples/solid/todo/scripts/migrate.ts index ee0089f38..d58ebc44e 100644 --- a/examples/solid/todo/scripts/migrate.ts +++ b/examples/solid/todo/scripts/migrate.ts @@ -1,7 +1,7 @@ -import { drizzle } from "drizzle-orm/node-postgres" -import { migrate } from "drizzle-orm/node-postgres/migrator" -import pkg from "pg" -import * as dotenv from "dotenv" +import { drizzle } from 'drizzle-orm/node-postgres' +import { migrate } from 'drizzle-orm/node-postgres/migrator' +import pkg from 'pg' +import * as dotenv from 'dotenv' dotenv.config() diff --git a/examples/solid/todo/src/api/server.ts b/examples/solid/todo/src/api/server.ts index 4aa55431d..948d2442e 100644 --- a/examples/solid/todo/src/api/server.ts +++ b/examples/solid/todo/src/api/server.ts @@ -1,14 +1,14 @@ -import express from "express" -import cors from "cors" -import { sql } from "../db/postgres" +import express from 'express' +import cors from 'cors' +import { sql } from '../db/postgres' import { validateInsertConfig, validateInsertTodo, validateUpdateConfig, validateUpdateTodo, -} from "../db/validation" -import type { Express } from "express" -import type { Txid } from "@tanstack/electric-db-collection" +} from '../db/validation' +import type { Express } from 'express' +import type { Txid } from '@tanstack/electric-db-collection' // Create Express app const app: Express = express() diff --git a/examples/solid/todo/src/components/NotFound.tsx b/examples/solid/todo/src/components/NotFound.tsx index 04619d4e8..3304c4195 100644 --- a/examples/solid/todo/src/components/NotFound.tsx +++ b/examples/solid/todo/src/components/NotFound.tsx @@ -1,4 +1,4 @@ -import { Link } from "@tanstack/solid-router" +import { Link } from '@tanstack/solid-router' export function NotFound() { return ( diff --git a/examples/solid/todo/src/components/TodoApp.tsx b/examples/solid/todo/src/components/TodoApp.tsx index 1e69d592c..c8cc0df58 100644 --- a/examples/solid/todo/src/components/TodoApp.tsx +++ b/examples/solid/todo/src/components/TodoApp.tsx @@ -1,8 +1,8 @@ -import { Link } from "@tanstack/solid-router" -import { For, Show, createSignal } from "solid-js" -import type { JSX } from "solid-js" -import type { Collection } from "@tanstack/solid-db" -import type { SelectConfig, SelectTodo } from "../db/validation" +import { Link } from '@tanstack/solid-router' +import { For, Show, createSignal } from 'solid-js' +import type { JSX } from 'solid-js' +import type { Collection } from '@tanstack/solid-db' +import type { SelectConfig, SelectTodo } from '../db/validation' interface TodoAppProps { todos: Array @@ -121,7 +121,7 @@ export function TodoApp(props: TodoAppProps) { return (
@@ -193,9 +193,9 @@ export function TodoApp(props: TodoAppProps) { todosToToggle.map((todo) => todo.id), (drafts) => { drafts.forEach( - (draft) => (draft.completed = !allCompleted) + (draft) => (draft.completed = !allCompleted), ) - } + }, ) }} > @@ -262,7 +262,7 @@ export function TodoApp(props: TodoAppProps) {