Skip to content

Commit 9857a67

Browse files
authored
refactor: revisit prettier config to be minimal (#2193)
1 parent a836356 commit 9857a67

36 files changed

+558
-560
lines changed

docs/getting-started/comparison.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ type State = {
326326

327327
type Actions = {
328328
updateCount: (
329-
countCallback: (count: State['count']) => State['count']
329+
countCallback: (count: State['count']) => State['count'],
330330
) => void
331331
}
332332

@@ -362,7 +362,7 @@ type State = {
362362

363363
type Actions = {
364364
updateCount: (
365-
countCallback: (count: State['count']) => State['count']
365+
countCallback: (count: State['count']) => State['count'],
366366
) => void
367367
}
368368

docs/guides/auto-generating-selectors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type WithSelectors<S> = S extends { getState: () => infer T }
2121
: never
2222

2323
const createSelectors = <S extends UseBoundStore<StoreApi<object>>>(
24-
_store: S
24+
_store: S,
2525
) => {
2626
let store = _store as WithSelectors<typeof _store>
2727
store.use = {}

docs/guides/connect-to-state-with-url-hash.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export const useBoundStore = create(
3838
{
3939
name: 'food-storage', // unique name
4040
storage: createJSONStorage(() => hashStorage),
41-
}
42-
)
41+
},
42+
),
4343
)
4444
```
4545

docs/guides/initialize-state-with-props.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ import { useStoreWithEqualityFn } from 'zustand/traditional'
135135

136136
function useBearContext<T>(
137137
selector: (state: BearState) => T,
138-
equalityFn?: (left: T, right: T) => boolean
138+
equalityFn?: (left: T, right: T) => boolean,
139139
): T {
140140
const store = useContext(BearContext)
141141
if (!store) throw new Error('Missing BearContext.Provider in the tree')

docs/guides/slices-pattern.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ export const useBoundStore = create(
108108
...createBearSlice(...a),
109109
...createFishSlice(...a),
110110
}),
111-
{ name: 'bound-store' }
112-
)
111+
{ name: 'bound-store' },
112+
),
113113
)
114114
```
115115

docs/guides/testing.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export default mergeConfig(
249249
environment: 'jsdom',
250250
setupFiles: ['./setup-vitest.ts'],
251251
},
252-
})
252+
}),
253253
)
254254
```
255255

@@ -302,7 +302,7 @@ export const createCounterStore = () => {
302302
}
303303

304304
export const CounterStoreContext = createContext<StoreApi<CounterStore>>(
305-
null as never
305+
null as never,
306306
)
307307

308308
export type CounterStoreProviderProps = PropsWithChildren
@@ -322,13 +322,13 @@ export const CounterStoreProvider = ({
322322
export type UseCounterStoreContextSelector<T> = (store: CounterStore) => T
323323

324324
export const useCounterStoreContext = <T,>(
325-
selector: UseCounterStoreContextSelector<T>
325+
selector: UseCounterStoreContextSelector<T>,
326326
): T => {
327327
const counterStoreContext = useContext(CounterStoreContext)
328328

329329
if (counterStoreContext === undefined) {
330330
throw new Error(
331-
'useCounterStoreContext must be used within CounterStoreProvider'
331+
'useCounterStoreContext must be used within CounterStoreProvider',
332332
)
333333
}
334334

@@ -371,7 +371,7 @@ describe('Counter', () => {
371371

372372
expect(await screen.findByText(/^1$/)).toBeInTheDocument()
373373
expect(
374-
await screen.findByRole('button', { name: /one up/i })
374+
await screen.findByRole('button', { name: /one up/i }),
375375
).toBeInTheDocument()
376376
})
377377

@@ -441,7 +441,7 @@ describe('CounterWithContext', () => {
441441

442442
expect(await screen.findByText(/^1$/)).toBeInTheDocument()
443443
expect(
444-
await screen.findByRole('button', { name: /one up/i })
444+
await screen.findByRole('button', { name: /one up/i }),
445445
).toBeInTheDocument()
446446
})
447447

docs/guides/typescript.md

+18-18
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Imagine you have a scenario like this:
9999

100100
```ts
101101
declare const withError: <T, E>(
102-
p: Promise<T>
102+
p: Promise<T>,
103103
) => Promise<[error: undefined, value: T] | [error: E, value: undefined]>
104104
declare const doSomething: () => Promise<string>
105105

@@ -113,10 +113,10 @@ Here, `T` is inferred to be a `string` and `E` is inferred to be `unknown`. You
113113
```ts
114114
declare const withError: {
115115
<E>(): <T>(
116-
p: Promise<T>
116+
p: Promise<T>,
117117
) => Promise<[error: undefined, value: T] | [error: E, value: undefined]>
118118
<T, E>(
119-
p: Promise<T>
119+
p: Promise<T>,
120120
): Promise<[error: undefined, value: T] | [error: E, value: undefined]>
121121
}
122122
declare const doSomething: () => Promise<string>
@@ -142,7 +142,7 @@ import { combine } from 'zustand/middleware'
142142
const useBearStore = create(
143143
combine({ bears: 0 }, (set) => ({
144144
increase: (by: number) => set((state) => ({ bears: state.bears + by })),
145-
}))
145+
})),
146146
)
147147
```
148148

@@ -181,9 +181,9 @@ const useBearStore = create<BearState>()(
181181
bears: 0,
182182
increase: (by) => set((state) => ({ bears: state.bears + by })),
183183
}),
184-
{ name: 'bearStore' }
185-
)
186-
)
184+
{ name: 'bearStore' },
185+
),
186+
),
187187
)
188188
```
189189

@@ -204,7 +204,7 @@ const useBearStore = create<BearState>()(
204204
myMiddlewares((set) => ({
205205
bears: 0,
206206
increase: (by) => set((state) => ({ bears: state.bears + by })),
207-
}))
207+
})),
208208
)
209209
```
210210

@@ -245,12 +245,12 @@ type Logger = <
245245
Mcs extends [StoreMutatorIdentifier, unknown][] = [],
246246
>(
247247
f: StateCreator<T, Mps, Mcs>,
248-
name?: string
248+
name?: string,
249249
) => StateCreator<T, Mps, Mcs>
250250

251251
type LoggerImpl = <T extends State>(
252252
f: StateCreator<T, [], []>,
253-
name?: string
253+
name?: string,
254254
) => StateCreator<T, [], []>
255255

256256
const loggerImpl: LoggerImpl = (f, name) => (set, get, store) => {
@@ -274,8 +274,8 @@ const useBearStore = create<BearState>()(
274274
bears: 0,
275275
increase: (by) => set((state) => ({ bears: state.bears + by })),
276276
}),
277-
'bear-store'
278-
)
277+
'bear-store',
278+
),
279279
)
280280
```
281281

@@ -298,7 +298,7 @@ type Foo = <
298298
Mcs extends [StoreMutatorIdentifier, unknown][] = [],
299299
>(
300300
f: StateCreator<T, [...Mps, ['foo', A]], Mcs>,
301-
bar: A
301+
bar: A,
302302
) => StateCreator<T, Mps, [['foo', A], ...Mcs]>
303303

304304
declare module 'zustand' {
@@ -309,7 +309,7 @@ declare module 'zustand' {
309309

310310
type FooImpl = <T extends State, A>(
311311
f: StateCreator<T, [], []>,
312-
bar: A
312+
bar: A,
313313
) => StateCreator<T, [], []>
314314

315315
const fooImpl: FooImpl = (f, bar) => (set, get, _store) => {
@@ -445,11 +445,11 @@ const bearStore = createStore<BearState>()((set) => ({
445445
function useBearStore(): BearState
446446
function useBearStore<T>(
447447
selector: (state: BearState) => T,
448-
equals?: (a: T, b: T) => boolean
448+
equals?: (a: T, b: T) => boolean,
449449
): T
450450
function useBearStore<T>(
451451
selector?: (state: BearState) => T,
452-
equals?: (a: T, b: T) => boolean
452+
equals?: (a: T, b: T) => boolean,
453453
) {
454454
return useStore(bearStore, selector!, equals)
455455
}
@@ -473,12 +473,12 @@ const bearStore = createStore<BearState>()((set) => ({
473473

474474
const createBoundedUseStore = ((store) => (selector, equals) =>
475475
useStore(store, selector as never, equals)) as <S extends StoreApi<unknown>>(
476-
store: S
476+
store: S,
477477
) => {
478478
(): ExtractState<S>
479479
<T>(
480480
selector: (state: ExtractState<S>) => T,
481-
equals?: (a: T, b: T) => boolean
481+
equals?: (a: T, b: T) => boolean,
482482
): T
483483
}
484484

docs/integrations/immer-middleware.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const useCountStore = create<State & Actions>()(
4747
set((state) => {
4848
state.count -= qty
4949
}),
50-
}))
50+
})),
5151
)
5252
```
5353

@@ -99,7 +99,7 @@ export const useTodoStore = create<State & Actions>()(
9999
set((state) => {
100100
state.todos[todoId].done = !state.todos[todoId].done
101101
}),
102-
}))
102+
})),
103103
)
104104
```
105105

docs/integrations/persisting-store-data.md

+26-26
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export const useBearStore = create(
3030
{
3131
name: 'food-storage', // name of the item in the storage (must be unique)
3232
storage: createJSONStorage(() => sessionStorage), // (optional) by default, 'localStorage' is used
33-
}
34-
)
33+
},
34+
),
3535
)
3636
```
3737

@@ -72,8 +72,8 @@ export const useBoundStore = create(
7272
{
7373
// ...
7474
storage: createJSONStorage(() => AsyncStorage),
75-
}
76-
)
75+
},
76+
),
7777
)
7878
```
7979

@@ -98,10 +98,10 @@ export const useBoundStore = create(
9898
// ...
9999
partialize: (state) =>
100100
Object.fromEntries(
101-
Object.entries(state).filter(([key]) => !['foo'].includes(key))
101+
Object.entries(state).filter(([key]) => !['foo'].includes(key)),
102102
),
103-
}
104-
)
103+
},
104+
),
105105
)
106106
```
107107

@@ -117,8 +117,8 @@ export const useBoundStore = create(
117117
{
118118
// ...
119119
partialize: (state) => ({ foo: state.foo }),
120-
}
121-
)
120+
},
121+
),
122122
)
123123
```
124124

@@ -151,8 +151,8 @@ export const useBoundStore = create(
151151
}
152152
}
153153
},
154-
}
155-
)
154+
},
155+
),
156156
)
157157
```
158158

@@ -202,8 +202,8 @@ export const useBoundStore = create(
202202

203203
return persistedState
204204
},
205-
}
206-
)
205+
},
206+
),
207207
)
208208
```
209209

@@ -256,8 +256,8 @@ export const useBoundStore = create(
256256
// ...
257257
merge: (persistedState, currentState) =>
258258
deepMerge(currentState, persistedState),
259-
}
260-
)
259+
},
260+
),
261261
)
262262
```
263263

@@ -285,8 +285,8 @@ export const useBoundStore = create(
285285
{
286286
// ...
287287
skipHydration: true,
288-
}
289-
)
288+
},
289+
),
290290
)
291291
```
292292

@@ -473,7 +473,7 @@ import { useState, useEffect } from 'react'
473473

474474
const useStore = <T, F>(
475475
store: (callback: (state: T) => unknown) => unknown,
476-
callback: (state: T) => F
476+
callback: (state: T) => F,
477477
) => {
478478
const result = store(callback) as F
479479
const [data, setData] = useState<F>()
@@ -505,8 +505,8 @@ export const useBearStore = create(
505505
}),
506506
{
507507
name: 'food-storage',
508-
}
509-
)
508+
},
509+
),
510510
)
511511
```
512512

@@ -625,8 +625,8 @@ export const useBoundStore = create(
625625
{
626626
name: 'food-storage', // unique name
627627
storage: createJSONStorage(() => storage),
628-
}
629-
)
628+
},
629+
),
630630
)
631631
```
632632

@@ -673,8 +673,8 @@ export const useBearStore = create<BearState>()(
673673
{
674674
name: 'food-storage',
675675
storage,
676-
}
677-
)
676+
},
677+
),
678678
)
679679
```
680680

@@ -728,8 +728,8 @@ export const useBearStore = create<MyState>()(
728728
name: 'food-storage', // name of item in the storage (must be unique)
729729
storage: createJSONStorage(() => sessionStorage), // (optional) by default the 'localStorage' is used
730730
partialize: (state) => ({ bears: state.bears }),
731-
}
732-
)
731+
},
732+
),
733733
)
734734
```
735735

0 commit comments

Comments
 (0)