Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion .github/workflows/docs-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
12 changes: 6 additions & 6 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
@@ -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}`)
}

Expand Down
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

20 changes: 10 additions & 10 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
// ...
}
```
Expand All @@ -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() {
Expand Down Expand Up @@ -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)) {
// ...
}
Expand All @@ -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)) {
// ...
}
Expand All @@ -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
}
Expand All @@ -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)
Expand Down Expand Up @@ -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
})
Expand Down Expand Up @@ -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)}`
Expand Down
26 changes: 8 additions & 18 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,39 +12,32 @@ 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`,
format: [`PascalCase`],
leadingUnderscore: `allow`,
},
],
"import/no-cycle": `error`,
'import/no-cycle': `error`,
},
},
]
8 changes: 4 additions & 4 deletions examples/angular/todos/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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: [
provideBrowserGlobalErrorListeners(),
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
],
};
}
4 changes: 2 additions & 2 deletions examples/angular/todos/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Routes } from '@angular/router';
import { Routes } from '@angular/router'

export const routes: Routes = [
// Add your routes here
];
]
36 changes: 18 additions & 18 deletions examples/angular/todos/src/app/app.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -140,44 +140,44 @@ 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(),
text: this.newTodoText.trim(),
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
}
}
14 changes: 7 additions & 7 deletions examples/angular/todos/src/collections/todos-collection.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -42,4 +42,4 @@ export const todosCollection = createCollection(
},
],
}),
);
)
8 changes: 4 additions & 4 deletions examples/angular/todos/src/main.ts
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion examples/angular/todos/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ module.exports = {
extend: {},
},
plugins: [],
};
}
Loading
Loading