Skip to content

Commit

Permalink
chore: revise Prettier config (#2253)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandren committed Nov 14, 2023
1 parent f5691b5 commit 234dff9
Show file tree
Hide file tree
Showing 119 changed files with 773 additions and 790 deletions.
2 changes: 1 addition & 1 deletion benchmarks/simple-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const main = async () => {
folder: __dirname,
file: `simple-read-${n}`,
format: 'chart.html',
})
}),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/simple-write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const main = async () => {
folder: __dirname,
file: `simple-write-${n}`,
format: 'chart.html',
})
}),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/subscribe-write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const main = async () => {
folder: __dirname,
file: `subscribe-write-${n}`,
format: 'chart.html',
})
}),
)
}
}
Expand Down
14 changes: 7 additions & 7 deletions docs/core/atom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ const writeOnlyAtom = atom(
(get, set, update) => {
// `update` is any single value we receive for updating this atom
set(priceAtom, get(priceAtom) - update.discount)
}
},
)
const readWriteAtom = atom(
(get) => get(priceAtom) * 2,
(get, set, newPrice) => {
set(priceAtom, newPrice / 2)
// you can set as many atoms as you want at the same time
}
},
)
```

Expand Down Expand Up @@ -84,13 +84,13 @@ function atom<Value>(read: (get: Getter) => Value | Promise<Value>): Atom<Value>
// writable derived atom
function atom<Value, Update>(
read: (get: Getter) => Value | Promise<Value>,
write: (get: Getter, set: Setter, update: Update) => void | Promise<void>
write: (get: Getter, set: Setter, update: Update) => void | Promise<void>,
): WritableAtom<Value, Update>

// write-only derived atom
function atom<Value, Update>(
read: Value,
write: (get: Getter, set: Setter, update: Update) => void | Promise<void>
write: (get: Getter, set: Setter, update: Update) => void | Promise<void>,
): WritableAtom<Value, Update>
```

Expand Down Expand Up @@ -140,7 +140,7 @@ const derivedAtom = atom(
} else if (action.type === 'inc') {
set(countAtom, (c) => c + 1)
}
}
},
)
derivedAtom.onMount = (setAtom) => {
setAtom({ type: 'init' })
Expand Down Expand Up @@ -169,7 +169,7 @@ const writableDerivedAtom = atom(
},
(get, set, arg) => {
// ...
}
},
)
```

Expand Down Expand Up @@ -199,7 +199,7 @@ const userAtom = atom(async (get, { signal }) => {
const userId = get(userIdAtom)
const response = await fetch(
`https://jsonplaceholder.typicode.com/users/${userId}?_delay=2000`,
{ signal }
{ signal },
)
return response.json()
})
Expand Down
8 changes: 4 additions & 4 deletions docs/core/use-atom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const Component = () => {
useMemo(
// This is also fine
() => atom((get) => get(stableAtom) * 2),
[]
)
[],
),
)
}
```
Expand All @@ -54,13 +54,13 @@ const Component = () => {
// primitive or writable derived atom
function useAtom<Value, Update>(
atom: WritableAtom<Value, Update>,
options?: { store?: Store }
options?: { store?: Store },
): [Value, SetAtom<Update>]

// read-only atom
function useAtom<Value>(
atom: Atom<Value>,
options?: { store?: Store }
options?: { store?: Store },
): [Value, never]
```

Expand Down
6 changes: 3 additions & 3 deletions docs/guides/composing-atoms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following is another simple example with the `write` function:
const textAtom = atom('hello')
export const textUpperCaseAtom = atom(
(get) => get(textAtom).toUpperCase(),
(_get, set, newText) => set(textAtom, newText)
(_get, set, newText) => set(textAtom, newText),
)
```

Expand All @@ -56,7 +56,7 @@ export const numberAtom = atom(
const nextValue =
typeof newValue === 'function' ? newValue(get(numberAtom)) : newValue
set(overwrittenAtom, nextValue)
}
},
)
```
Expand Down Expand Up @@ -85,7 +85,7 @@ export const persistedAtom = atom(
typeof newValue === 'function' ? newValue(get(baseAtom)) : newValue
set(baseAtom, nextValue)
localStorage.setItem('mykey', nextValue)
}
},
)
```
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/core-internals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ const writeOnlyAtom = atom(
null, // it's a convention to pass `null` for the first argument
(get, set, args) => {
set(priceAtom, get(priceAtom) - args)
}
},
)
const readWriteAtom = atom(
(get) => get(priceAtom) * 2,
(get, set, newPrice) => {
set(priceAtom, newPrice / 2)
// you can set as many atoms as you want at the same time
}
},
)
```

Expand Down
3 changes: 2 additions & 1 deletion docs/guides/initialize-atom-on-render.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const PrettyText = () => {
<text
style={{
color: 'blue',
}}>
}}
>
{text}
</text>
</>
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/persistence.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const strAtomWithPersistence = atom(
(get, set, newStr) => {
set(strAtom, newStr)
localStorage.setItem('myKey', newStr)
}
},
)
```
Expand All @@ -41,7 +41,7 @@ const atomWithLocalStorage = (key, initialValue) => {
typeof update === 'function' ? update(get(baseAtom)) : update
set(baseAtom, nextValue)
localStorage.setItem(key, JSON.stringify(nextValue))
}
},
)
return derivedAtom
}
Expand Down Expand Up @@ -69,7 +69,7 @@ const atomWithAsyncStorage = (key, initialValue) => {
typeof update === 'function' ? update(get(baseAtom)) : update
set(baseAtom, nextValue)
AsyncStorage.setItem(key, JSON.stringify(nextValue))
}
},
)
return derivedAtom
}
Expand Down Expand Up @@ -172,7 +172,7 @@ const serializeAtom = atom(null, (get, set, action: Actions) => {
// needs error handling and type checking
set(
todosAtom,
obj.todos.map((todo: Todo) => atom(todo))
obj.todos.map((todo: Todo) => atom(todo)),
)
}
})
Expand Down
3 changes: 2 additions & 1 deletion docs/guides/resettable.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const TodoList = () => {
checked: false,
},
])
}>
}
>
Add todo
</button>
<button onClick={resetTodoList}>Reset</button>
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const asyncStrAtom = atom<Promise<string>>(async () => 'foo')
*/
const writeOnlyAtom = atom<null, [string, number], void>(
null,
(_get, set, stringValue, numberValue) => set(fooAtom, stringValue)
(_get, set, stringValue, numberValue) => set(fooAtom, stringValue),
)

/**
Expand All @@ -90,7 +90,7 @@ const writeOnlyAtom = atom<null, [string, number], void>(
*/
const readWriteAtom = atom<Promise<string>, [number], void>(
async (get) => await get(asyncStrAtom),
(_get, set, num) => set(strAtom, String(num))
(_get, set, num) => set(strAtom, String(num)),
)
```

Expand Down
9 changes: 6 additions & 3 deletions docs/integrations/location.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const App = () => {
style={{
fontWeight: loc.pathname === '/' ? 'bold' : 'normal',
}}
onClick={() => setLoc((prev) => ({ ...prev, pathname: '/' }))}>
onClick={() => setLoc((prev) => ({ ...prev, pathname: '/' }))}
>
Home
</button>
</li>
Expand All @@ -74,7 +75,8 @@ const App = () => {
pathname: '/foo',
searchParams: new URLSearchParams(),
}))
}>
}
>
Foo
</button>
</li>
Expand All @@ -92,7 +94,8 @@ const App = () => {
pathname: '/foo',
searchParams: new URLSearchParams([['bar', '1']]),
}))
}>
}
>
Foo?bar=1
</button>
</li>
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/relay.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const countriesAtom = atomWithQuery(
}
}
`,
() => ({})
() => ({}),
)

const Main = () => {
Expand Down
11 changes: 6 additions & 5 deletions docs/integrations/urql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const Counter = () => {
<button
onClick={() =>
executeMutation().then((it) => console.log(it.data?.increment))
}>
}
>
Increment
</button>
<div>{operationResult.data?.increment}</div>
Expand Down Expand Up @@ -140,7 +141,7 @@ export const useQueryAtomData = <
Data = unknown,
Variables extends AnyVariables = AnyVariables,
>(
queryAtom: AtomWithQuery<Data, Variables>
queryAtom: AtomWithQuery<Data, Variables>,
) => {
const [opResult, dispatch] = useAtom(queryAtom)

Expand All @@ -155,7 +156,7 @@ export const useQueryAtomData = <
setTimeout(resolve, 10000) // This timeout time is going to cause suspense of this component up until
// new operation result will come. After 10 second it will simply try to render component itself and suspend again
// in an endless loop
})
}),
)
}

Expand All @@ -165,7 +166,7 @@ export const useQueryAtomData = <

if (!opResult.data) {
throw Error(
'Query data is undefined. Probably you paused the query? In that case use `useQueryAtom` instead.'
'Query data is undefined. Probably you paused the query? In that case use `useQueryAtom` instead.',
)
}
return [opResult.data, dispatch, opResult] as [
Expand Down Expand Up @@ -195,7 +196,7 @@ function use(promise: Promise<any> | any) {
(reason: any) => {
promise.status = 'rejected'
promise.reason = reason
}
},
)
throw promise
}
Expand Down
10 changes: 5 additions & 5 deletions docs/integrations/valtio.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const Counter = () => {
<>
count: {state.count}
<button
onClick={() =>
setState((prev) => ({ ...prev, count: prev.count + 1 }))
}>
onClick={() => setState((prev) => ({ ...prev, count: prev.count + 1 }))}
>
inc atom
</button>
<button
onClick={() => {
++proxyState.count
}}>
}}
>
inc proxy
</button>
</>
Expand Down Expand Up @@ -121,6 +121,6 @@ atom(
(get, set) => {
const countProxy = get(countProxyAtom)
++countProxy.value // This is fine
}
},
)
```
2 changes: 1 addition & 1 deletion docs/integrations/xstate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const createEditableMachine = (value: string) =>
const defaultTextAtom = atom('edit me')
const editableMachineAtom = atomWithMachine((get) =>
// `get` is available only for initializing a machine
createEditableMachine(get(defaultTextAtom))
createEditableMachine(get(defaultTextAtom)),
)

const Toggle = () => {
Expand Down
5 changes: 2 additions & 3 deletions docs/integrations/zustand.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ const Counter = () => {
<>
count: {state.count}
<button
onClick={() =>
setState((prev) => ({ ...prev, count: prev.count + 1 }))
}>
onClick={() => setState((prev) => ({ ...prev, count: prev.count + 1 }))}
>
button
</button>
</>
Expand Down
4 changes: 2 additions & 2 deletions docs/recipes/atom-with-broadcast.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function atomWithBroadcast<Value>(key: string, initialValue: Value) {
if (!update.isEvent) {
channel.postMessage(get(baseAtom))
}
}
},
)
broadcastAtom.onMount = (setAtom) => {
const listener = (event: MessageEvent<any>) => {
Expand All @@ -46,7 +46,7 @@ export function atomWithBroadcast<Value>(key: string, initialValue: Value) {
(get) => get(broadcastAtom),
(get, set, update) => {
set(broadcastAtom, { isEvent: false, value: update })
}
},
)
return returnedAtom
}
Expand Down
Loading

1 comment on commit 234dff9

@vercel
Copy link

@vercel vercel bot commented on 234dff9 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.