Skip to content

Commit 4a1edf6

Browse files
ci: apply automated fixes
1 parent 2130037 commit 4a1edf6

File tree

3 files changed

+56
-40
lines changed

3 files changed

+56
-40
lines changed

docs/router/framework/react/how-to/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,24 @@ This directory contains focused, step-by-step instructions for common TanStack R
3737
### Search Parameters & URL State (Progressive Series)
3838

3939
**Foundation Level (Start Here):**
40+
4041
- [x] [Set Up Basic Search Parameters](./setup-basic-search-params.md) - Create type-safe search validation and reading
4142
- [ ] Navigate with Search Parameters - Update and manage search params with Links and navigation
4243

4344
**Intermediate Level (Common Patterns):**
45+
4446
- [ ] Validate Search Parameters with Schemas - Use schema validation libraries for robust validation and type safety
4547
- [ ] Handle Complex Search Parameter Types - Work with arrays, objects, dates, and nested data
4648
- [ ] Share Search Parameters Across Routes - Inherit and manage search params across route hierarchies
4749

4850
**Advanced Level (Power User Patterns):**
51+
4952
- [ ] Build Advanced Search Parameter Middleware - Create custom middleware for search param processing
5053
- [ ] Optimize Search Parameter Performance - Minimize re-renders and improve performance with selectors
5154
- [ ] Customize Search Parameter Serialization - Implement custom serialization for compression and compatibility
5255

5356
**Specialized Use Cases:**
57+
5458
- [ ] Build Search-Based Filtering Systems - Create complex filtering UIs with URL state
5559
- [ ] Handle Search Parameters in Forms - Synchronize form state with URL search parameters
5660
- [ ] Debug Search Parameter Issues - Troubleshoot common search param problems and performance issues

docs/router/framework/react/how-to/setup-basic-search-params.md

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const Route = createFileRoute('/products')({
2828

2929
function ProductsPage() {
3030
const { page, category, showSale } = Route.useSearch()
31-
31+
3232
return (
3333
<div>
3434
<h1>Products</h1>
@@ -43,6 +43,7 @@ function ProductsPage() {
4343
## Why Use Schema Validation for Search Parameters?
4444

4545
**Production Benefits:**
46+
4647
- **Type Safety**: Automatic TypeScript inference
4748
- **Runtime Validation**: Catches invalid URL parameters gracefully
4849
- **Default Values**: Fallback handling for missing parameters
@@ -152,16 +153,16 @@ const shopSearchSchema = z.object({
152153
// Pagination
153154
page: fallback(z.number(), 1).default(1),
154155
limit: fallback(z.number(), 20).default(20),
155-
156+
156157
// Filtering
157158
category: fallback(z.string(), 'all').default('all'),
158159
minPrice: fallback(z.number(), 0).default(0),
159160
maxPrice: fallback(z.number(), 1000).default(1000),
160-
161+
161162
// Settings
162163
sort: fallback(z.enum(['name', 'price', 'date']), 'name').default('name'),
163164
ascending: fallback(z.boolean(), true).default(true),
164-
165+
165166
// Optional parameters
166167
searchTerm: z.string().optional(),
167168
showOnlyInStock: fallback(z.boolean(), false).default(false),
@@ -190,15 +191,25 @@ Use the route's `useSearch()` hook to access validated and typed search paramete
190191
```tsx
191192
function ShopPage() {
192193
const searchParams = Route.useSearch()
193-
194+
194195
// All properties are fully type-safe and validated
195-
const { page, limit, category, sort, ascending, searchTerm, showOnlyInStock } = searchParams
196-
196+
const {
197+
page,
198+
limit,
199+
category,
200+
sort,
201+
ascending,
202+
searchTerm,
203+
showOnlyInStock,
204+
} = searchParams
205+
197206
return (
198207
<div>
199208
<h1>Shop - Page {page}</h1>
200209
<div>Category: {category}</div>
201-
<div>Sort: {sort} ({ascending ? 'ascending' : 'descending'})</div>
210+
<div>
211+
Sort: {sort} ({ascending ? 'ascending' : 'descending'})
212+
</div>
202213
<div>Items per page: {limit}</div>
203214
<div>In stock only: {showOnlyInStock ? 'Yes' : 'No'}</div>
204215
{searchTerm && <div>Search: "{searchTerm}"</div>}
@@ -224,10 +235,10 @@ export const Route = createFileRoute('/posts')({
224235

225236
function PostsPage() {
226237
const { page, limit } = Route.useSearch()
227-
238+
228239
// Calculate offset for API calls
229240
const offset = (page - 1) * limit
230-
241+
231242
return (
232243
<div>
233244
<h1>Posts (Page {page})</h1>
@@ -243,13 +254,10 @@ function PostsPage() {
243254

244255
```tsx
245256
const catalogSchema = z.object({
246-
sort: fallback(
247-
z.enum(['name', 'date', 'price']),
248-
'name'
249-
).default('name'),
257+
sort: fallback(z.enum(['name', 'date', 'price']), 'name').default('name'),
250258
category: fallback(
251-
z.enum(['electronics', 'clothing', 'books', 'all']),
252-
'all'
259+
z.enum(['electronics', 'clothing', 'books', 'all']),
260+
'all',
253261
).default('all'),
254262
ascending: fallback(z.boolean(), true).default(true),
255263
})
@@ -266,23 +274,25 @@ export const Route = createFileRoute('/catalog')({
266274
const dashboardSchema = z.object({
267275
// Numbers with validation
268276
userId: fallback(z.number().positive(), 1).default(1),
269-
refreshInterval: fallback(z.number().min(1000).max(60000), 5000).default(5000),
270-
277+
refreshInterval: fallback(z.number().min(1000).max(60000), 5000).default(
278+
5000,
279+
),
280+
271281
// Strings with validation
272282
theme: fallback(z.enum(['light', 'dark']), 'light').default('light'),
273283
timezone: z.string().optional(),
274-
284+
275285
// Arrays with validation
276286
selectedIds: fallback(z.number().array(), []).default([]),
277287
tags: fallback(z.string().array(), []).default([]),
278-
288+
279289
// Objects with validation
280290
filters: fallback(
281291
z.object({
282292
status: z.enum(['active', 'inactive']).optional(),
283293
type: z.string().optional(),
284-
}),
285-
{}
294+
}),
295+
{},
286296
).default({}),
287297
})
288298
```
@@ -312,7 +322,7 @@ const routeApi = getRouteApi('/products')
312322

313323
export function ProductFilters() {
314324
const { category, sort, showSale } = routeApi.useSearch()
315-
325+
316326
return (
317327
<div>
318328
<select value={category}>
@@ -333,12 +343,8 @@ import { useSearch } from '@tanstack/react-router'
333343

334344
function GenericSearchDisplay() {
335345
const search = useSearch({ from: '/products' })
336-
337-
return (
338-
<div>
339-
Current filters: {JSON.stringify(search, null, 2)}
340-
</div>
341-
)
346+
347+
return <div>Current filters: {JSON.stringify(search, null, 2)}</div>
342348
}
343349
```
344350

@@ -352,15 +358,15 @@ export const Route = createFileRoute('/example')({
352358
validateSearch: (search: Record<string, unknown>) => ({
353359
// Numbers need coercion from URL strings
354360
page: Number(search.page) || 1,
355-
361+
356362
// Strings can be cast with defaults
357363
category: (search.category as string) || 'all',
358-
364+
359365
// Booleans: TanStack Router auto-converts "true"/"false" to booleans
360366
showSale: Boolean(search.showSale),
361-
367+
362368
// Arrays need JSON parsing validation
363-
selectedIds: Array.isArray(search.selectedIds)
369+
selectedIds: Array.isArray(search.selectedIds)
364370
? search.selectedIds.map(Number).filter(Boolean)
365371
: [],
366372
}),
@@ -432,7 +438,7 @@ const schema = z.object({
432438
const schema = z.object({
433439
// Required with default (navigation can omit, but always present in component)
434440
page: fallback(z.number(), 1).default(1),
435-
441+
436442
// Truly optional (can be undefined in component)
437443
searchTerm: z.string().optional(),
438444
})
@@ -450,12 +456,14 @@ const schema = z.object({
450456
z.object({
451457
status: z.enum(['active', 'inactive']).optional(),
452458
tags: z.string().array().optional(),
453-
dateRange: z.object({
454-
start: z.string().pipe(z.coerce.date()),
455-
end: z.string().pipe(z.coerce.date()),
456-
}).optional(),
459+
dateRange: z
460+
.object({
461+
start: z.string().pipe(z.coerce.date()),
462+
end: z.string().pipe(z.coerce.date()),
463+
})
464+
.optional(),
457465
}),
458-
{}
466+
{},
459467
).default({}),
460468
})
461469
```
@@ -477,4 +485,4 @@ const schema = z.object({
477485
- [TanStack Zod Adapter](https://tanstack.com/router/latest/docs/framework/react/api/router/zodValidator) - Official Zod adapter
478486
- [TanStack Valibot Adapter](https://tanstack.com/router/latest/docs/framework/react/api/router/valibotValidator) - Official Valibot adapter
479487
- [Search Parameters Guide](../guide/search-params.md) - Comprehensive search parameters documentation
480-
- [Type Safety Guide](../guide/type-safety.md) - Understanding TanStack Router's type safety
488+
- [Type Safety Guide](../guide/type-safety.md) - Understanding TanStack Router's type safety

how-to-guides-implementation-plan.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,24 @@ This document outlines the multi-PR process for implementing the remaining how-t
2121
**Status:** Ready for implementation with test verification
2222

2323
**Foundation Level (Start Here):**
24+
2425
-**Search #1: Setup Basic Search Parameters** (`setup-basic-search-params.md`) - COMPLETED with comprehensive validation library support
2526
-**Search #2: Navigate with Search Parameters** (`navigate-with-search-params.md`) - Test Gap: Functional updates, Link patterns
2627

2728
**Intermediate Level (Common Patterns):**
29+
2830
-**Search #3: Validate Search Parameters with Schemas** (`validate-search-params.md`) - Test Coverage: Good (existing Zod tests)
2931
-**Search #4: Handle Complex Search Parameter Types** (`complex-search-param-types.md`) - Test Gap: Arrays, objects, dates
3032
-**Search #5: Share Search Parameters Across Routes** (`share-search-params-across-routes.md`) - Test Coverage: Partial (middleware tests exist)
3133

3234
**Advanced Level (Power User Patterns):**
35+
3336
-**Search #6: Build Advanced Search Parameter Middleware** (`advanced-search-param-middleware.md`) - Test Coverage: Good (existing middleware tests)
3437
-**Search #7: Optimize Search Parameter Performance** (`optimize-search-param-performance.md`) - Test Gap: Performance patterns, selectors
3538
-**Search #8: Customize Search Parameter Serialization** (`customize-search-param-serialization.md`) - Test Gap: Custom serializers
3639

3740
**Specialized Use Cases:**
41+
3842
-**Search #9: Build Search-Based Filtering Systems** (`build-search-filtering-systems.md`) - Test Gap: Complex filtering patterns
3943
-**Search #10: Handle Search Parameters in Forms** (`search-params-in-forms.md`) - Test Gap: Form integration patterns
4044
-**Search #11: Debug Search Parameter Issues** (`debug-search-param-issues.md`) - Test Coverage: Partial (debug tests exist)

0 commit comments

Comments
 (0)